A production-ready Node.js backend template built with Clean Architecture principles to help you build applications that are:
- Maintainable
- Scalable
- Testable
- Framework-independent
Inspired by industry best practices and Uncle Bob’s Clean Architecture.
API Routes / Page Routes
│
▼
Controllers
│
▼
Use Cases
│
▼
Domain Services
│
▼
Repositories
│
▼
Database(s)
This project follows a layered architecture with a clear separation of concerns.
Routes, Controllers, Middleware, Serializers
Use Cases, Orchestration, Business Flow
Entities, Business Rules, Core Services, Interfaces
Repositories, Databases, External Integrations
Business logic is completely independent of Express, databases, or external services.
Use the same use cases across:
- REST APIs
- CLI tools
- Background workers
- Cron jobs
Easily replace technologies without touching core logic:
- Express → Fastify / NestJS
- MongoDB → PostgreSQL / MySQL
- Redis / S3 / Firebase
The structure supports large applications and smooth evolution into microservices.
Clear conventions make onboarding easier and keep long-term projects healthy.
This template is ideal for:
- Startups building scalable APIs
- Teams adopting Clean Architecture
- Projects expected to grow in complexity
- Node.js
- Express.js (default, swappable)
- Sequelize (SQL)
- Mongoose (MongoDB)
- Passport.js
- JWT Authentication
- CSRF Protection
- Rate Limiting
- Multer (file uploads)
- Socket support
- Redis caching
- Bootstrap frontend support
- Mocha testing framework
- Node.js 14+
- MongoDB
- MySQL
- Redis
Clone the repository:
git clone https://github.com/waiphyo285/nodejs-template.git
cd nodejs-template
npm install
cp .env.example .envBefore running the application, configure your database credentials in the .env file.
This template supports MongoDB and MySQL, configured independently.
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_USER=your_mongo_user
MONGO_PASS=your_mongo_password
MONGO_DB_NAME=your_mongo_databaseMYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_mysql_user
MYSQL_PASS=your_mysql_password
MYSQL_DB_NAME=your_mysql_databaseStart the development server:
npm run start:devVisit:
http://localhost:8765
Run tests with:
npm run unit:test
npm run load:testThe architecture allows you to test business logic without mocking frameworks or databases.
You can easily add:
- New databases
- Message queues
- External APIs
- Background workers
without changing existing core logic.
Contributions, issues, and feature requests are welcome.
MIT License
