How jbuget/nodejs-clean-architecture-app works
Project Type and Purpose
• The project is a backend API built with Hapi.js. It cleanly separates concerns using Clean Architecture principles and integrates Domain Driven Design. It includes layers to handle use cases (application business rules), core business/domain logic, and supporting infrastructure (such as ORMs, security, web server configuration), with adapters (controllers, routes, serializers) for interfacing with external systems.
File Structure
• The top-level files (e.g., index.js, README.md, docker-compose.yml) show that the entry point is index.js while configuration and deployment are facilitated externally.
• Under the /lib directory you have distinct subdirectories:
• application - Contains use cases and security services. These are the business rules (like CreateUser, DeleteUser, etc.).
• domain - Contains your core business objects (e.g., User) and related interfaces (e.g., UserRepository) that define contracts.
• infrastructure - Houses configurations, database ORMs (with support for both Mongoose and Sequelize), repository implementations (in-memory, Mongo, SQLite), security (JWT-based), and the web server components including OAuth strategies.
• interfaces - Contains controllers (route handlers), route definitions, and serializers that format data in/out for HTTP requests.
• The separate test folder further confirms unit/functional tests for key business use cases and controllers.
README for Additional Insights
• The README explicitly documents the Clean Architecture layers, providing examples of how the application is divided.
Final Checklist for the Principal Software Engineer
• That every component (from routes to repositories) is represented and clearly labeled.
• Incorporate notes about the use of multiple ORM options and the Service Locator pattern.