arch-ddd
Skill4 starsChanged 5 months agoMITView on GitHub
Tactical DDD patterns for clean Python architecture including Domain Model, Repository, Service Layer, Unit of Work, and Aggregates. Use for backend architecture decisions, implementing data access layers, separating business logic from infrastructure, or reviewing code separation.
In this repository101 other files it gives its agents.
- ai-video-understandingSkill
- apple-foundation-modelsSkill
- arch-decision-recordsSkill
- arch-diagramsSkill
- arch-eventsSkill
- arch-mvp-roadmapSkill
- arch-python-modernSkill
- aws-app-runnerSkill
- aws-cicd-patternsSkill
- aws-security-hardeningSkill
- azure-functions-python-v2Skill
- azure-identity-m2m-authSkill
- azure-service-bus-messagingSkill
- azure-workflow-execution-modelsSkill
- caddy-tls-proxySkill
- compliance-frameworksSkill
- design-system-workflowSkill
- dev-debugging-strategiesSkill
- dev-standardsSkill
- docker-python-poetrySkill
- docker-pythonSkill
- fastapi-patternsSkill
- ffmpeg-laravel-videoSkill
- formik-yup-react-nativeSkill
- frontend-accessibilitySkill
- frontend-angular-aiSkill
- frontend-angularSkill
- frontend-angular-toolingSkill
- frontend-design-systemsSkill
- frontend-material-chatSkill
- frontend-material-design-3Skill
- frontend-svelteSkill
- gcp-cicd-patternsSkill
- gcp-cloud-runSkill
- gcp-cloudsql-infrastructureSkill
- gcp-finopsSkill
- gcp-observabilitySkill
- gcp-security-hardeningSkill
- github-actions-cicdSkill
- healthkit-biofeedbackSkill
- infra-terraformSkill
- ios-app-qualitySkill
- ios-audio-hapticsSkill
- jest-nestjs-testingSkill
- langchain-azure-openai-patternsSkill
- laravel-auth-hardeningSkill
- laravel-ci-mysqlSkill
- laravel-mix-webpackSkill
- laravel-modern-patternsSkill
- laravel-pint-patternsSkill
- laravel-s3-storageSkill
- laravel-sail-dockerSkill
- mobile-app-deploymentSkill
- mobile-e2e-testingSkill
- mobile-offline-syncSkill
- mobile-push-notificationsSkill
- mobile-video-uploadSkill
- mongodb-asyncmongoclient-patternsSkill
- mongodb-atlas-patternsSkill
- nestjs-patternsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 79
When deciding where to place new features, domain ownership typically outweighs infrastructure convenience.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Domain-Driven Architecture
Architectural patterns for building maintainable Python applications with clean separation between business logic and infrastructure.
Core Principle
"Behavior should drive storage, not the reverse." Focus on what the system does, not just its data model.
The Four Pillars
1. Domain Model Pattern
The heart of your application - pure business logic, no infrastructure dependencies.
- Entities: Objects with long-lived identity (User, Order)
- Value Objects: Immutable, defined by attributes (Money, Address)
- Domain Services: Logic spanning multiple entities
2. Repository Pattern
Abstraction over persistent storage with simple interface.
- Decouple domain from data access
- Enable testing with fake implementations
- Hide persistence complexity
3. Service Layer Pattern
Orchestrates use cases and defines application boundaries.
- Thin orchestration, not business logic
- Handles transaction boundaries
- Clear API for use cases
4. Unit of Work Pattern
Atomic operations and transaction lifecycle management.
- Explicit transaction boundaries
- Single entry point to repositories
- Ensures consistency
Aggregate Pattern
Consistency boundaries - clusters of objects that must remain consistent together.
- One aggregate = one repository
- Modify one aggregate per transaction — spanning several in one transaction couples their consistency boundaries and complicates rollback
- Reference other aggregates by ID, not object reference — cross-boundary object references trigger unintended cascade loads
The Dependency Rule
Dependencies point inward:
Entrypoints → Service Layer → Domain Model
↓ ↓
Adapters ← ← ← ← ←When to Apply
| Scenario | Pattern |
| Complex business rules | Domain Model |
| Multiple data sources | Repository |
| Multiple entry points | Service Layer |
| Transaction management | Unit of Work |
| Complex invariants | Aggregates |
Multi-Service Architecture
Service Placement Decision Framework
When deciding where to place new features, domain ownership typically outweighs infrastructure convenience.
Decision criteria (priority order):
- Domain Ownership - Which service owns the business capability?
- Data Ownership - Which service owns the authoritative data?
- Infrastructure Reuse - Which service has needed infrastructure already?
- Deployment Coupling - Which choice minimizes cross-service deployments?
Example:
| Option | Domain | Data | Infrastructure | Decision |
| gateway-service | No (real-time) | No | Yes (has DB) | Reject |
| migrations-service | No (schemas) | No | Yes (has batch) | Reject |
| analytics-service | Yes (analytics) | Yes (owns data) | No (needs new) | Accept |
Trade-off: Infrastructure setup is one-time cost; wrong service boundaries compound over time.
Aggregate Write Boundaries — Client Side
Splitting an aggregate root + children across two requests re-introduces the failure class the boundary prevents: failed child → orphaned parent; retry without checking → duplicate parent. Prefer the single transactional nested-create endpoint. Verify the contract exists before assuming split endpoints are required; a retry id-guard treats the symptom, not the disease.
See reference.md § "Aggregate Write Boundaries — Client Side" for failure modes and retry-guard analysis. See arch-decision-records § "API Consumption Patterns" for the client-side consumption rule.
See reference.md for detailed explanations and examples.md for implementations.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

