π Announcing exp-mvc v1.2.0 - Express MVC Architecture Builder!
A CLI tool to generate and scaffold Express.js applications with MVC architecture.
β¨ Features:
- One-command project generation
- Automatic component scaffolding
- Auto dependency and package installation
- Ready-to-use basic ejs view templates
- Built-in Mongodb support
Get it now:
npm install exp-mvc
GitHub: https://github.com/ZaheerAhmedkhan65/exp-mvc
npm: https://www.npmjs.com/package/exp-mvc
After installing exp-mvc globally , run the following command:
expmvc new myapp
Or
npx exp-mvc new myapp
This will create:
./myapp
with the full project structure.
Navigate to the project folder:
cd myapp
Inside your project folder, install dependencies:
npm install
configure the mongodb connection in the .env file
MONGODB_URI=mongodb://localhost:27017/myapp
Run the server:
npm start
or
npm run dev
Run the watch command to automatically install dependencies on file save:
npm run watch
Open the browser at http://localhost:3000
π₯ CLI Commands Reference
Once inside your generated project, use the expmvc command to generate components:
Generate Complete CRUD Scaffold
Create a full CRUD module with controller, model, service, route, and validation files:
expmvc generate scaffold User name:string email:string password:string age:number
Generate Individual Components
Generate a controller
expmvc generate controller Product
Generate a model with fields
expmvc generate model Category name:string description:string
Generate a route
expmvc generate route Order
Generate a service
expmvc generate service Auth
Generate a validation file
expmvc generate validation User
Generate a view (EJS template)
expmvc generate view home/index
Relations Between Models
1. Generate Individual Models with References:
# Generate User model
expmvc generate model User name:string email:string password:string
# Generate Post model with User reference
expmvc generate model Post title:string content:string user:ref:User
# Generate Comment model with User and Post references
expmvc generate model Comment content:string user:ref:User post:ref:Post
2. Create Relationships Between Existing Models:
# Add belongsTo relationship from Post to User
expmvc rel belongsTo Post User --field author
# Add hasMany relationship from User to Post
expmvc rel hasMany User Post --field posts
# Add belongsToMany relationship (for tags, categories, etc.)
expmvc rel belongsToMany Post Tag --field tags[]
3. Complete Relationship Scaffold:
# Scaffold User-Post relationship (One-to-Many)
expmvc sr User Post hasMany
# Scaffold Post-Comment relationship (One-to-Many)
expmvc sr Post Comment hasMany
# Scaffold User-Comment relationship (One-to-Many)
expmvc sr User Comment hasMany
4. Generate Complete CRUD with Relationships:
# Generate User scaffold
expmvc generate scaffold User name:string email:string password:string
# Generate Post scaffold with User reference
expmvc generate scaffold Post title:string content:string user:ref:User
# Then add the reverse relationship
expmvc rel hasMany User Post --field posts
Field Types Supported
# Available field types:
name:string # String field
age:number # Number field
isActive:boolean # Boolean field
createdAt:date # Date field
tags:array , Array field
userId:objectid # ObjectId reference
β¨ Why Use This Generator?
Saves Hours: Skip repetitive setup and focus on business logic
Consistent Architecture: Enforces clean, maintainable structure
Production Ready: Includes validation, services, and middleware patterns
Scalable: Perfect for growing applications
Developer Friendly: Intuitive CLI with helpful commands
Perfect For:
Students learning Express.js
Backend developers starting new projects
Startups needing rapid prototyping
API bootstrapping and hackathons
Enterprise applications requiring structure
Top comments (0)