You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This project demonstrates how to apply Uncle Bob's Clean Architecture principles in a Node.js REST API. It is designed as an educational resource to help developers structure their projects for maximum testability, maintainability, and scalability. The codebase shows how to keep business logic independent from frameworks, databases, and delivery mechanisms.
13
10
14
-
15
11
## Stack
16
12
17
13
-**Node.js** (Express.js) for the REST API
@@ -39,36 +35,6 @@
39
35
- The product use case receives a `createProductDbHandler` as a parameter. In production, this is the real DB handler; in tests, it's a mock function.
40
36
- Lower layers (domain, use cases) never import or reference Express, MongoDB, or any framework code.
41
37
42
-
=======
43
-
44
-
## Stack
45
-
46
-
-**Node.js** (Express.js) for the REST API
47
-
-**MongoDB** (MongoClient) for persistence
48
-
-**Jest** & **Supertest** for unit and integration testing
49
-
-**ESLint** & **Prettier** for linting and formatting
50
-
-**Docker** & **Docker Compose** for containerization
51
-
-**GitHub Actions** for CI/CD
52
-
53
-
## Why Clean Architecture?
54
-
55
-
-**Separation of Concerns:** Each layer has a single responsibility and is independent from others.
56
-
-**Dependency Rule:** Data and control flow from outer layers (e.g., routes/controllers) to inner layers (use cases, domain), never the reverse. Lower layers are unaware of upper layers.
57
-
-**Testability:** Business logic can be tested in isolation by injecting dependencies (e.g., mock DB handlers) from above. No real database is needed for unit tests.
58
-
-**Security & Flexibility:** Infrastructure (DB, frameworks) can be swapped without touching business logic.
59
-
60
-
> **✨ Ultimate Flexibility:**
61
-
> This project demonstrates that your core business logic is never tied to any specific framework, ORM, or database. You can switch from Express to Fastify, MongoDB to PostgreSQL, or even move to a serverless environment—without rewriting your business rules. The architecture ensures your codebase adapts easily to new technologies, making future migrations and upgrades painless. This is true Clean Architecture in action: your app’s heart beats independently of any tool or vendor.
62
-
63
-
## How Testing Works
64
-
65
-
-**Unit tests** inject mocks for all dependencies (DB, loggers, etc.) into use cases and controllers. This means you can test all business logic without a real database or server.
66
-
-**Integration tests** can use a real or in-memory database, but the architecture allows you to swap these easily.
67
-
-**Example:**
68
-
- The product use case receives a `createProductDbHandler` as a parameter. In production, this is the real DB handler; in tests, it's a mock function.
69
-
- Lower layers (domain, use cases) never import or reference Express, MongoDB, or any framework code.
0 commit comments