This boilerplate provides a foundation for Node.js applications using Clean Architecture principles. It utilizes a tech stack including Sequelize, TypeScript, and Docker. The default HTTP framework is Express.
Open Source for you to make app powerful and high scalability, and if you experience difficulties when using this framework, please write in the issue repo
- Node.js v18.20.4
- Sequelize (SQL ORM)
- TypeScript
- Docker
- Express (HTTP framework)
The project follows the principles of Clean Architecture, emphasizing separation of concerns into distinct layers:
- Entities: Representing the core business entities.
- Use Cases: Defining application-specific business rules.
- Interface Adapters: Implementing details for external frameworks and tools.
- Frameworks & Drivers: Implementing details for external frameworks and tools (Express, databases, etc.).
-
Clone the repository:
git clone https://github.com/ayocodingit/boilerplate-clean-architecture.git
-
Navigate to the project directory:
cd boilerplate-clean-architecture
-
Install dependencies:
npm install
-
Copy the appropriate environment file::
cp .env.example .env
Customize the
.env
file according to your configuration.
npm run start:dev
npm run build
npm start
Build Docker image:
docker -f docker/Dockerfile build -t your-image-name .
Run Docker container:
docker run -p 3000:3000 -d your-image-name
-
Linting:
- Check code formatting:
npm run lint
- Fix code formatting:
npm run lint:fix
- Check code formatting:
-
Database Migration:
- Run migrations:
npm run migrate
- Rollback migrations:
npm run migrate:rollback
- Run migrations:
-
Local Database Migration (development):
- Generate migration file:
npm run migration:generate --name=your-migration-name
- Run migrations:
npm run build && npm run migrate
- Rollback migrations:
npm run build && npm run migrate:rollback
- Generate migration file:
-
Seed:
- Run Seed:
npm run seed:run --name=your-seed-filename
- Run Seed:
-
Cron:
- Run Cron:
npm run seed:run --name=your-cron-filename
- Run Cron:
-
Testing:
- Run tests:
npm test
- Run tests: