Architecture DDD modulaire

VérifiéSûr

Guide expert pour concevoir et analyser l'architecture logicielle en utilisant le Domain-Driven Design (DDD) et les principes d'architecture modulaire.

Spar Skills Guide Bot
DeveloppementIntermédiaire
23/07/2026
Claude CodeCursorWindsurfCopilotCodex
#ddd#modular-architecture#domain-modeling#bounded-contexts#codebase-analysis

Recommandé pour

Synthèse automatique

Guide la conception et l'analyse d'architectures logicielles selon les principes du Domain-Driven Design stratégique et de l'architecture modulaire, en mode conception ou en mode analyse.

Points forts

  • Deux modes explicites (conception et analyse) déclenchés par l'intention exprimée par l'utilisateur
  • Indépendant du langage, avec des conventions de nommage adaptées (kebab-case, snake_case, PascalCase)
  • Fournit une arborescence de module prête à l'emploi (business/api/data/async/integration) et un arbre de décision pour les feature folders
  • Délimite clairement son périmètre en excluant l'infrastructure, le schéma de base de données et le design d'API

Limites

  • S'appuie sur des fichiers de référence internes (ddd-strategic-design.md, etc.) qui doivent être disponibles pour l'analyse détaillée
  • Purement consultatif : ne génère pas de code et n'automatise aucune vérification de cohésion
  • L'identification des domaines reste une interprétation subjective du vocabulaire métier
Quand l'utiliser

Pour définir des contextes délimités et une structure de modules sur un nouveau projet, ou pour auditer la cohésion et les frontières de domaine d'un code existant.

Quand l'éviter

Pour des tâches d'infrastructure ou de DevOps, de conception de schéma de base de données ou de design d'endpoints API, que la compétence exclut explicitement.

Analyse de sécurité

Sûr
Score qualité85/100

This is a pure instructional/guidance skill about Domain-Driven Design and modular architecture. It declares no allowed-tools and contains no executable commands, no shell invocations (no curl|sh, no rm -rf), no network or credential handling, and no obfuscated payloads. It merely directs an agent to read reference files and produce architectural analyses. The text ends abruptly at 'Never a' but this appears to be truncation, not a hidden directive. No meaningful execution risk.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Identify domains in an existing codebase
Analyze this codebase and identify our business domains and bounded contexts. Group the entities, services and handlers by ubiquitous language, then classify each subdomain as core, supporting or generic.
Design a new module
Design the folder structure for a new Billing module in our TypeScript monolith. It has around eight services, so tell me whether to use feature folders and show me the full folder tree with the reasoning behind each decision.
Review cross-module coupling
Review how our modules communicate with each other and flag any place where one module imports another module's concrete implementation instead of an interface. Show me how to apply the Public API Provider pattern to fix it.

name: modular-ddd-architecture description: Expert guide for designing and analyzing software architecture using Domain-Driven Design (DDD) and modular architecture principles. Use when someone asks to design a new module, identify domains, analyze code cohesion, plan folder structure, define bounded contexts, create feature folders, or review architecture. Also use when someone says "analyze this codebase", "what domains do we have", "how should I structure this module", "identify bounded contexts", "create a new module", or asks about modular monolith design. Do NOT use for infrastructure/DevOps, database schema design, or API endpoint design. license: CC-BY-4.0 metadata: author: Luiz Nascimento version: 1.0.0

Modular DDD Architecture

Guide an agent to design new modules or analyze existing codebases using Domain-Driven Design (DDD) strategic principles, modular architecture, and feature folder organization. Language-agnostic.

Modes of Operation

This skill operates in two modes based on user intent:

Design Mode

Trigger: User wants to create a new module, structure a project, or organize code.

Analysis Mode

Trigger: User wants to analyze an existing codebase for domain boundaries, cohesion, or architectural issues.


Instructions

Step 1: Determine the Mode

Ask or infer from context:

  • Design Mode: "create a module", "structure this project", "how should I organize...", "add a new domain"
  • Analysis Mode: "analyze this code", "identify domains", "check cohesion", "review architecture", "what domains exist"

Step 2: Design Mode Workflow

When designing new modules or structuring a project:

  1. Identify the Domain — Determine which business domain the code belongs to. Read references/ddd-strategic-design.md for DDD theory if needed.

  2. Classify the Domain — Is it Core (competitive advantage), Supporting (essential but not differentiating), or Generic (common functionality)?

  3. Define the Module Structure — Apply the layered architecture from references/architecture-guidelines.md:

    module-name/
    ├── business/        # Business logic, services, use cases, models
    ├── api/             # REST/GraphQL/gRPC handlers, DTOs
    ├── data/            # Models, repositories, migrations
    ├── async/           # Queue producers/consumers (optional)
    └── integration/     # External service providers (optional)
    
  4. Apply Feature Folders (if module is complex) — When the module has 5+ services, use vertical slices. Read references/feature-folders-guidelines.md for the decision tree and rules:

    • Each feature folder is JUST a folder (not a separate module/deployment unit)
    • Single module definition registers ALL components
    • Use shared/ only for code used by 3+ features
  5. Define Cross-Module Communication — Use the Public API Provider pattern from references/modular-architecture-principles.md:

    • Define interfaces in shared location
    • Implement in the owning module
    • Inject interfaces, never concrete implementations across modules
  6. Apply Naming Conventions — Choose consistent naming based on language:

    • kebab-case (JavaScript/TypeScript/Ruby)
    • snake_case (Python/Go)
    • PascalCase (Java/C#)
  7. Present the Structure — Show the complete folder tree with explanations for each decision.

Step 3: Analysis Mode Workflow

When analyzing an existing codebase:

  1. Extract Concepts — Scan for entities, services, use cases, and controllers/handlers. Read references/domain-identification-guidelines.md for the full methodology.

  2. Group by Ubiquitous Language — Cluster concepts by business vocabulary (e.g., subscription/plan/invoice = Billing, movie/video/episode = Content).

  3. Identify Domains and Subdomains — Map clusters to domains. Classify each subdomain as Core, Supporting, or Generic.

  4. Measure Cohesion — Score each domain using the 4 metrics:

    • Linguistic Cohesion (0-3): Shared vocabulary
    • Usage Cohesion (0-3): Concepts used together
    • Data Cohesion (0-2): Entity relationships
    • Change Cohesion (0-2): Files changed together
    • Total: X/10 (8-10 High, 5-7 Medium, 0-4 Low)
  5. Detect Low Cohesion Issues — Check for:

    • Linguistic mismatch (different vocabularies in same module)
    • Cross-domain tight coupling (direct service imports between domains)
    • Mixed responsibilities (one service handling multiple domains)
    • Generic concepts in Core Domain
    • Unclear boundaries
  6. Generate Report — Produce:

    • Domain Map (domains, subdomains, types, cohesion scores)
    • Cohesion Matrix (cross-domain relationships)
    • Low Cohesion Issues (with prioritized recommendations)
    • Read references/domain-identification-example.md for a complete worked example.

Step 4: Validate Against Principles

For both modes, validate the architecture against the 10 Modular Architecture Principles from references/modular-architecture-principles.md:

  1. Well-Defined Boundaries — No internal details exposed
  2. Composability — Modules work independently or together
  3. Independence — No tight coupling, interface-based communication
  4. Individual Scale — Each module scales based on its needs
  5. Explicit Communication — All inter-module contracts are explicit
  6. Replaceability — Modules swappable behind interfaces
  7. Deployment Independence — No hard-coded deployment assumptions
  8. State Isolation — Each module owns its database/schema
  9. Testability — Each module testable in isolation
  10. Simplicity — Minimum complexity for current needs

Key Architectural Rules

These rules apply universally regardless of mode:

  1. Domain-based organization, not technical layers — Organize by billing/, content/, identity/, NOT by controllers/, services/, models/.

  2. Business logic independent of frameworks — The business layer has no framework imports.

  3. Repository Pattern for all data access — Never access the database directly from services.

  4. Lean Controllers/Handlers — Handlers only handle request/response, delegate to services or use cases.

  5. Use Cases are optional — Only for complex orchestration across multiple services. Simple operations use services directly.

  6. Cross-module communication via interfaces — Never import another module's internal services. Use the Public API Provider pattern.

  7. Feature Folders are just folders — NOT separate deployment units. One module definition per domain.

  8. shared/ requires 3+ consumers — Don't prematurely abstract. Wait for a 3rd usage before moving to shared.

  9. State isolation — Each module owns its database schema. No shared tables between modules.

  10. Evolutionary design — Start modular monolith, extract microservices only when proven necessary.


Reference Files

Load these on demand based on what the task requires:

| File | When to Load | |------|-------------| | references/architecture-guidelines.md | When designing module structure, layers, naming conventions, or folder organization | | references/modular-architecture-principles.md | When validating architecture, defining cross-module communication, or checking principles | | references/feature-folders-guidelines.md | When a module is complex (5+ services) and needs vertical slice organization | | references/ddd-strategic-design.md | When identifying domains, defining bounded contexts, or understanding DDD theory | | references/domain-identification-guidelines.md | When analyzing an existing codebase for domain boundaries and cohesion | | references/domain-identification-example.md | When you need a complete worked example of domain analysis |


Examples

Example 1: Design a New Module

User says: "I need to create a notifications module"

Actions:

  1. Classify: Notifications is typically a Generic/Supporting subdomain
  2. Design the structure:
    notifications/
    ├── module-definition.*
    ├── business/
    │   ├── services/
    │   │   └── notification-service.*
    │   ├── models/
    │   │   └── notification.*
    │   └── enums/
    │       └── notification-channel-enum.*
    ├── api/
    │   └── rest/
    │       └── handlers/
    │           └── notification-handler.*
    ├── data/
    │   ├── models/
    │   │   └── notification.*
    │   └── repositories/
    │       └── notification-repository.*
    └── integration/
        └── providers/
            ├── email-provider.*
            └── sms-provider.*
    
  3. Define public API interface for other modules to send notifications
  4. No feature folders needed (simple module)

Example 2: Analyze a Codebase

User says: "Analyze this codebase and identify the domains"

Actions:

  1. Scan the codebase for entities, services, use cases, handlers
  2. Group by business vocabulary
  3. Produce domain map with cohesion scores
  4. Identify cross-domain coupling issues
  5. Recommend improvements with priority levels

Example 3: Restructure with Feature Folders

User says: "My billing module has 12 services, how do I organize it?"

Actions:

  1. Read references/feature-folders-guidelines.md
  2. Apply decision tree to each service
  3. Group into features: subscription/, invoice/, credit/, payment/
  4. Move shared utilities to billing/shared/
  5. Keep SINGLE module definition registering all components

Troubleshooting

Problem: Circular dependencies between modules

Cause: Direct service imports between modules instead of interfaces. Solution: Use Public API Provider pattern. Define interface in shared, implement in owning module.

Problem: Unclear which domain a concept belongs to

Cause: The concept may span multiple domains or the boundary is wrong. Solution: Check the Ubiquitous Language — which domain's vocabulary does it use? If ambiguous, it may need to be split or placed at a domain boundary with clear ownership.

Problem: Module too large and hard to navigate

Cause: Domain has grown without internal organization. Solution: Apply Feature Folders (vertical slices) within the module. NOT separate modules — just folders for organization.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/modular-ddd-architecture-mrx3xy8n' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/modular-ddd-architecture-mrx3xy8n/download' --output '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md.part' && mv '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md.part' '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && test -s '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/modular-ddd-architecture' && cp -R '.skill-downloads/modular-ddd-architecture-mrx3xy8n' '.claude/skills/modular-ddd-architecture'

Cursor
test -f '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && test -s '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/modular-ddd-architecture' && cp -R '.skill-downloads/modular-ddd-architecture-mrx3xy8n' '.cursor/skills/modular-ddd-architecture'

Codex
test -f '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && test -s '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/modular-ddd-architecture' && cp -R '.skill-downloads/modular-ddd-architecture-mrx3xy8n' '.agents/skills/modular-ddd-architecture'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/modular-ddd-architecture-mrx3xy8n'

openskills read 'modular-ddd-architecture-mrx3xy8n'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires