ddd-code-generator
v1.0.3
Published
A CLI tool to generate Domain-Driven Design structure for bounded contexts
Maintainers
Readme
DDD Code Generator
A CLI tool to generate Domain-Driven Design structure for bounded contexts.
GitHub: https://github.com/AbrahamVilchesDeLaCruz/bolierplate-ddd
Installation
# Install as a dev dependency in your project
npm install --save-dev ddd-code-generatorUsage
Without Install
# You could also use directly without install
npx ddd-code-generatorCLI
# Generate DDD structure using interactive prompts
ddd-genAdd to npm scripts
Add the following to your package.json:
"scripts": {
"generate:ddd": "ddd-gen",
}Then run commands with:
npm run generate:dddProgrammatic usage
import { promptBoundedContext, createDirectoryStructure } from "ddd-code-generator";
async function generateDDD() {
const boundedContext = await promptBoundedContext();
await createDirectoryStructure(boundedContext);
}
generateDDD();Features
- Interactive CLI prompts for creating DDD structures
- Generates bounded contexts with aggregates
- Creates proper folder structure following DDD principles
- Generates boilerplate code for:
- Aggregates
- Value Objects
- Repositories
- Use Cases
- DTOs
- Controllers
- Event Handlers
Structure Generated
The generator creates a standard DDD folder structure:
src/[bounded-context]/
├── [aggregate]/
│ ├── app/
│ │ └── use-cases/
│ │ ├── [verb]/
│ │ │ ├── dto/
│ │ │ │ ├── request-[aggregate]-[verb].dto.ts
│ │ │ │ └── response-[aggregate]-[verb].dto.ts
│ │ │ └── [aggregate]-[verb].use-case.ts
│ ├── domain/
│ │ ├── event/
│ │ ├── exceptions/
│ │ ├── repository/
│ │ └── [aggregate].repository.ts
│ │ ├── value-objects/
│ │ └── [aggregate]-[property].value-object.ts
│ │ └── [aggregate].ts
│ ├── infra/
│ │ ├── controllers/
│ │ └── [verb]-[aggregate]-[http-method].controller.ts
│ │ ├── event-handlers/
│ │ ├── exceptions/
│ │ └── typeorm/License
MIT
Contributing
We welcome contributions! Since this is a public repository, feel free to:
- Open issues to report bugs or suggest features.
- Fork the project and submit a Pull Request (PR) with your improvements.
Note: All changes must go through a pull request. Direct edits to the main branch are restricted.
Please follow standard GitHub flow: fork → commit → PR → review → merge.
