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
Copy file name to clipboardExpand all lines: README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,25 @@
1
1
# node.js-clean-architecture
2
2
A use case of Clean Architecture in Node.js comprising of Express.js, MongoDB and Redis as the main (but replaceable) infrastructure.
3
3
4
-
## Overview
4
+
###Overview
5
5
This example is a simple RESTful API application in which a user can create / update / delete / find a post, by using the *Clean Architecture*.
6
6
7
7
The objective of *Clean Architecture* by [Robert C. Martin] is the separation of concerns in software.
8
8
This separation is achieved by dividing the software into layers. Each layer is encapsulated by a higher level layer and the way to communicate between the layers is with the *Dependency Rule*.
This rule says that nothing in an inner circle can know anything at all about something in an outer circle. The dependency direction is from the outside in. Meaning that the *Entities* layer is independent and the *Frameworks & Drivers* layer (Web, UI, DB etc.) depends on all the other layers.
14
-
### Entities
14
+
####Entities
15
15
Contains all the business entities an application consists of. In our example the *User* and the *Post*.
16
-
### Use Cases
16
+
####Use Cases
17
17
Contains application specific business rules. These use cases orchestrate the flow of data to and from the entities. In our example some of the use cases are: *AddPost*, *AddUser*, *DeleteById* etc.
18
-
### Interface Adapters
18
+
####Interface Adapters
19
19
This layer is a set of adapters (controllers, presenters, and gateways) that convert data from the format most convenient for the use cases and entities, to the format most convenient for some external agency such as the DB or the Web. In other words, is an entry and exit points to the Use Cases layer. In our example we implemented controllers and presenters together and these are the PostController and the UserController.
20
-
### Frameworks and Drivers
20
+
####Frameworks and Drivers
21
21
The outermost layer is generally composed of frameworks and tools such as the Database, the Web Framework, etc.
22
-
## How to run it
22
+
###How to run it
23
23
* Make sure you have [mongoDB] installed. At the terminal run the following command:
24
24
```sh
25
25
mongod --dbpath <path_to_data/db_folder>
@@ -34,16 +34,16 @@ npm run dev
34
34
npm run start
35
35
```
36
36
37
-
## How to run it (using Docker)
37
+
###How to run it (using Docker)
38
38
* Make sure you have [docker] installed. At the root folder run the following command:
0 commit comments