moh-projectgen
v1.0.27
Published
Project generator for DDD-based Node/TS architecture
Maintainers
Readme
moh-projectgen
moh-projectgen is a TypeScript-based project scaffolding tool designed to generate fully structured, production-ready Node.js microservices following Domain-Driven Design (DDD), modular architecture, and GraphQL-first patterns.
This generator is the evolution of an earlier Bash-based setup script. It preserves 100% of the original output, but is now cross‑platform, more maintainable, and packaged as a CLI utility that can be shared across the engineering team.
Features
Generates a complete Node.js microservice
- Express + GraphQL
- Sequelize + MySQL
- RabbitMQ integration
- DDD folder structure
- Error handling middleware
- Token/session validation
- Logger configuration
- Full ready-to-run application
Part of a 3‑tool ecosystem
This package works alongside:
| Package | Purpose | | ---------------- | ------------------------------------------------------------------------------------------------------ | | moh-modelgen | Connects to MySQL and automatically generates Sequelize model files. | | moh-codegen | Generates CRUD modules based on a model: controllers, services, usecases, validations, resolvers, etc. |
Together, these tools drastically reduce boilerplate, enforce architecture standards, and accelerate development.
Package Structure (CLI Tool)
Your package has the following structure:
moh-projectgen/
│
├─ bin/
│ └─ cli.js # Compiled CLI entry
│
├─ src/
│ ├─ index.ts # Exports the generator
│ ├─ generator.ts # Generator logic
│ └─ templates/ # All project template files
│ ├─ package.json.txt
│ ├─ tsconfig.json.txt
│ ├─ .env.example.txt
│ ├─ src/app.ts.txt
│ ├─ src/server.ts.txt
│ ├─ src/config/... (all config templates)
│ ├─ src/utils/... (all utility templates)
│ ├─ src/api/... (GraphQL schema/resolvers templates)
│ └─ ... (EVERY file from the original Bash script)
│
├─ package.json
├─ tsconfig.json
└─ README.mdDDD Architecture Overview
The generator creates a project using a clean Domain-Driven Design (DDD) structure.
src/
├─ api/ # GraphQL schemas + resolvers
├─ config/ # Config + env loaders
├─ database/ # Models, migrations, seeders
├─ interfaces/ # Contracts / abstractions
│ ├─ events/
│ ├─ repositories/
│ ├─ service/
│ └─ usecases/
├─ repositories/ # Sequelize repository implementations
├─ services/ # Business logic services
├─ usecases/ # Application logic
├─ utils/ # Helpers, filters, errors, etc.
└─ types/ # Shared TS typesWhy DDD?
- Separation of business logic from infrastructure
- Encourages modularity
- Easier to scale and test
- Enables code generators (like moh-codegen)
Part of the MOH Development Ecosystem
moh-modelgen (Database → Models)
moh-modelgen connects to a live MySQL database and automatically generates Sequelize model files.
Features:
- Auto-detects tables
- Auto-detects columns + types
- Generates TypeScript model definitions
- Generates associations (belongsTo, hasMany, etc.)
- Produces output compatible with
moh-projectgen
Usage:
npx moh-modelgen --host localhost --user root --password pass --db mydb --out src/database/modelsThis reduces hours of manual model writing down to a single command.
moh-codegen (Module Creator)
moh-codegen generates a full CRUD module with:
- GraphQL schema
- GraphQL resolvers
- Service layer
- Use cases
- Repository logic
- Input validation
- DTOs
- Types
Usage
moh-codegen make:module <name> --model <ModelName> --validateExample
moh-codegen make:module Customer --model CustomerModel --validateThis will generate:
src/modules/customer/
├─ customer.schema.ts
├─ customer.resolver.ts
├─ customer.service.ts
├─ customer.usecase.ts
├─ customer.repository.ts
├─ customer.validation.ts
└─ index.tsAll wired together and ready to integrate.
🛠 Installation
Install globally:
npm install -g moh-projectgenGenerate a new project:
moh-projectgen MyService🧪 Development (for contributors)
To work on the generator itself:
npm install
npm run build
npm linkThen test locally:
moh-projectgen test-serviceSummary
moh-projectgen is the foundation of your service ecosystem.
Together with:
- moh-modelgen (database → models)
- moh-codegen (models → modules)
You now have a complete, automated, production-grade development workflow.
If you want, I can also:
- generate the full template folder, filled with all 120+ files
- generate documentation for modelgen and codegen separately
- add schematics or presets for microservice types
- publish this as a ready npm package
Just let me know! 🚀
