Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

ddd-principles

/ddd-principles

Stosuje zasady DDD w obiektowych językach przy projektowaniu warstwy domeny: konteksty ograniczone, agregaty, obiekty wartości, czystość warstw, porty i adaptery oraz kierunek zależności.

Licencja
MIT
Ostatnia zmiana repozytorium
12.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 12.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Stosuje zasady DDD w obiektowych językach przy projektowaniu warstwy domeny: konteksty ograniczone, agregaty, obiekty wartości, czystość warstw, porty i adaptery oraz kierunek zależności.

Wyzwalacze z opisu

domainDDDhexagonalports and adaptersdomain puritybounded contextaggregate
Oryginalny opis (EN)

ACTIVATE when designing the domain layer in OOP languages — bounded contexts, aggregates, value objects, layer purity, ports/adapters, dependency direction. ACTIVATE for 'domain', 'DDD', 'hexagonal', 'ports and adapters', 'domain purity', 'bounded context', 'aggregate'. Provides cross-language OOP-style DDD principles. For functional-style DDD (immutable records, smart constructors, pipelines) see craft:ddd-fp-principles. Language-specific examples live in php-ddd-conventions, nest-ddd-conventions.

Jak działa

  1. 1. Domain Layer Purity
  2. 2. Ports & Adapters
  3. 3. Dependency Direction (always inward)
  4. 4. Bounded Contexts
  5. 5. Aggregates
  6. 6. Value Objects
  7. Quick Reference
Sekcje z nagłówków SKILL.md, w oryginale · 85 linii, 544 słów
Podgląd SKILL.md
---
name: ddd-principles
description: "ACTIVATE when designing the domain layer in OOP languages — bounded contexts, aggregates, value objects, layer purity, ports/adapters, dependency direction. ACTIVATE for 'domain', 'DDD', 'hexagonal', 'ports and adapters', 'domain purity', 'bounded context', 'aggregate'. Provides cross-language OOP-style DDD principles. For functional-style DDD (immutable records, smart constructors, pipelines) see craft:ddd-fp-principles. Language-specific examples live in php-ddd-conventions, nest-ddd-conventions."
---

# DDD — Cross-Language OOP Principles

> The **rules** below are language-agnostic OOP-style DDD. Language-specific examples (forbidden imports, Symbol tokens, module structure) live in:
> - `php-ddd-conventions` (PHP / Symfony)
> - `nest-ddd-conventions` (TypeScript / NestJS)
>
> For **functional-style** DDD (immutable records, curried operations, Result pipelines), see `craft:ddd-fp-principles`.

## 1. Domain Layer Purity

The domain layer contains **business logic only**. Infrastructure leaks into the domain are the most common architectural violation — they make the domain untestable without the framework and impossible to reuse.

### Forbidden in the Domain Layer

- Framework HTTP types (`Request`, `Response`, framework `UploadedFile`, etc.)
- ORM / database classes (Doctrine entities, Drizzle schemas, Prisma client)
- DI decorators / framework annotations (`@Injectable`, `@Module`, `@Inject`, etc.)
- Framework-specific validators
- Any external library tied to a framework

### Allowed in the Domain Layer

- Pure language types (string, int, Date, plain record, etc.)
- Domain value objects (immutable, no framework dependency)
- Domain interfaces (defined in domain, implemented in infrastructure)
- Shared DTOs from contracts packages (typically `packages/shared` or equivalent)
- Enums / constant unions / branded types

**Criterion:** if the domain layer compiles WITHOUT the framework, it's pure.

## 2. Ports & Adapters

The boundary between domain and infrastructure is a set of **interfaces (ports)** defined in the domain, implemented as **adapters** in the infrastructure.

- Ports = pure interfaces, in the domain layer
- Adapters = concrete implementations, in the infrastructure layer
- The domain depends only on its own interfaces
- The infrastructure imports the domain — never the reverse

## 3. Dependency Direction (always inward)

```
Controllers / HTTP   →   Use Cases   →   Domain Services   →   Domain Ports
                                                                     ↑
   Infrastructure Adapters (DB, HTTP clients, …) ───────────────────┘
        (implement the domain ports)
```

**Rule:** dependencies always flow **inward** toward the domain. Outer layers know about inner layers; inner layers know nothing about outer layers.

## 4. Bounded Contexts

A bounded context is a clearly delimited part of the system with its **own ubiquitous language**. Each bounded context maps to a separate module / namespace / directory.

- 1 bounded context = 1 module (NestJS) / 1 namespace (PHP) / 1 directory (others)
- Bounded contexts communicate through explicit contracts (DTOs, events) — never by sharing internals

## 5. Aggregates

An aggregate is a state-bearing cluster of domain objects with:

- A single **transactional boundary** — all invariants of the aggregate must hold at commit time.
- A single **aggregate root** with an identity.
- External references go through the root only.

## 6. Value Objects

Value objects are defined by their **attributes**, not by an identity:

- **Immutable** (use `readonly` / `final readonly` / equivalent).
- Equality is by attribute equality, not by reference.
- May enforce invariants in the constructor (positive amount, valid format, etc.).

## Quick Reference

| Rule | Principle |
|------|-----------|
| Domain purity | No framework / ORM / HTTP in the domain layer |
| Ports & adapters | Interfaces in domain, implementations in infrastructure |
| Dependency direction | Always inward toward the domain |
| Bounded context | 1 module / namespace / directory per context |
| Aggregate | Single transactional boundary + identified root |
| Value object | Immutable, equality by attributes, may enforce invariants |

Wersje

W bazie nie ma innych skilli o nazwie ddd-principles.

Migawka bazy z 13.11.2026 · wersja paczki bdad19b3b765 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100nest-ddd-conventions
    Wprowadza konwencje DDD w NestJS: warstwę domeny, porty i adaptery, konteksty ograniczone jako moduły oraz czystość domeny w TypeScript.
  • 100php-ddd-conventions
    Podpowiada w kodzie domenowym PHP i Symfony obiekty wartości, specyfikacje i serwisy domenowe zgodnie z zasadami DDD.
  • 100clean-ddd-hexagonal
    Projektuje lub przegląda granice domeny i zależności backendu według DDD, Clean Architecture i portów z adapterami: modelowanie agregatów, konteksty ograniczone i izolacja przypadków użycia.
  • 100clean-architecture
    Dostarcza wzorce Clean Architecture, DDD i architektury heksagonalnej dla aplikacji NestJS i TypeScript, od warstwy domeny po porty i adaptery.
  • 100ddd
    Wspiera tworzenie systemów w Domain-Driven Design: projektowanie nowych systemów, refaktoryzacja ku DDD, szkielety kodu (encje, agregaty, repozytoria, zdarzenia), Event Storming, mapy kontekstów i przeglądy kodu.
  • 95architecture-domain-driven-design
    Modeluje złożoną logikę biznesową w podejściu DDD: konteksty ograniczone, agregaty, obiekty wartości i mapy kontekstów.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.