Skip to content

Boilerplate Clean Architecture is a template for building Node.js applications that embraces the principles of Clean Architecture. It provides a structured and modular approach to development, separating concerns into layers for enhanced maintainability and scalability.

Notifications You must be signed in to change notification settings

ayocodingit/clean-architecture-node

Repository files navigation

Boilerplate Clean Architecture for Node.js

Node.js Logo

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.

GitHub Repository

License

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

Tech Stack

  • Node.js v18.20.4
  • Sequelize (SQL ORM)
  • TypeScript
  • Docker
  • Express (HTTP framework)

Design Pattern: Clean Architecture

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.).

Installation

  1. Clone the repository:

    git clone https://github.com/ayocodingit/boilerplate-clean-architecture.git
  2. Navigate to the project directory:

    cd boilerplate-clean-architecture
  3. Install dependencies:

    npm install
  4. Copy the appropriate environment file::

    cp .env.example .env

    Customize the .env file according to your configuration.

Usage

Development

npm run start:dev

Build

npm run build

Start

npm start

Docker

Build Docker image:

docker -f docker/Dockerfile build -t your-image-name .

Run Docker container:

docker run -p 3000:3000 -d your-image-name

Additional Scripts

  • Linting:

    • Check code formatting:
      npm run lint
    • Fix code formatting:
      npm run lint:fix
  • Database Migration:

    • Run migrations:
      npm run migrate
    • Rollback migrations:
      npm run migrate:rollback
  • 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
  • Seed:

    • Run Seed:
      npm run seed:run --name=your-seed-filename
  • Cron:

    • Run Cron:
      npm run seed:run --name=your-cron-filename
  • Testing:

    • Run tests:
      npm test

Folder Structure

About

Boilerplate Clean Architecture is a template for building Node.js applications that embraces the principles of Clean Architecture. It provides a structured and modular approach to development, separating concerns into layers for enhanced maintainability and scalability.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •