nodejs-clean
nodejs-clean copied to clipboard
Clean Architecture with Node.js + Express.js
Node.js + Express.js + Clean Architecture
This is the spike code to architect node.js, express.js using clean architecture.
Architecture Overview
This project's architecture is based on Uncle Bob's The Clean Architecture. Please at least skim through his blog as you will have a better understanding of how it works.
We are separated this application into 4 different layers
- Domains (highest)
- Use cases
- Interfaces
- Infrastructure (lowest)
The gist of it is a separation of concerns. Outer layer (lower) can reference (or know) the inner (highest) layer, however, the inner layers can not know about outer layer. We accomplished this by using Dependency Injection and Duck Typing since Javascript doesn't have the concept of Interface.
(highest) (lowest, most detail implementation)
domains ---> user cases ---> interfaces ---> infrastructure
Run the server
$ npm install
$ NODE_ENV=development node server.js