This repository contains a demonstration of a simple Node.js project structured following clean architecture principles. Clean architecture promotes separation of concerns and modularization of code, resulting in more maintainable and scalable applications.
Clean architecture is an architectural pattern that emphasizes the separation of concerns within a software application. It divides the application into layers, each with distinct responsibilities, such as interfaces, application logic, domain entities, and infrastructure.
This repository serves as a demonstration of implementing clean architecture principles in a Node.js project. It provides a structured approach to organizing code, making it easier to understand, maintain, and extend.
The project is structured as follows:
- src/interfaces: Contains controllers responsible for handling HTTP requests and responses.
- src/application: Houses use cases and services representing the application's business logic.
- src/domain: Defines entities representing core domain concepts.
- src/infrastructure: Provides implementations for interacting with external dependencies like databases.
- config: Stores configuration files for the application.
To get started with this project, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/nodejs-clean-architecture-demo.git
-
Navigate to the desired branch:
- Without Clean Architecture:
git checkout without-clean-architecture
- With Clean Architecture:
git checkout with-clean-architecture
- Without Clean Architecture:
-
Install dependencies:
npm install
-
Run the project:
npm start
-
Access the API endpoints using a tool like Postman or cURL.
This project exposes the following endpoints:
GET /users
: Retrieves a list of users.POST /users
: Creates a new user.
Ensure to include the necessary request body parameters when making a POST /users
request (name
and email
).
Contributions are welcome! Feel free to open issues or pull requests for any improvements or fixes you'd like to see in the project. Please adhere to the code of conduct in all interactions.
This project is licensed under the MIT License.