Defining the application flow of the Clean Architecture Project

Defining the application flow of the Clean Architecture Project

Clean Architecture Series

Continuing with the Clean Architecture Series, in this article we are going to create an API REST in nodejs and typescript for an imaginary business of an "Insurance Company".

So, let define the system components and the application flow to implement the Clean architecture concepts.

System Components

Frameworks: Express as a web server and Sqlite3 as a Database.

Adapters: CreatePolicyController and ExpressAdapter to adapt the express request into the controller and use-case needs.

Use Cases: CreatePolicyUseCase with the all business logic related the insurance policy's creation process.


  • PolicyRepository: Database communication to persist and fetch the insurance policy data.

  • PolicyEntity: Encapsulate all the business rules needed to store a new insurance policy into the system.

Application Flow

  1. App: Run the express webserver and makes the necessary objects to satisfy the inner layer's dependencies

  2. ExpressAdapter: Adapt the express request object into the controller format.

  3. CreatePolicyController: Adapt the data into the CreatePolicyUseCase format and inject the use case dependencies from the external layers.

  4. CreatePolicyUseCase: Apply the business logic using the PolicyRepository and PolicyEntity.

  5. PolicyEntity: Apply the business rules which every policy holder needs to satisfy.

  6. PolicyRepository: Define the SQL queries and execute it into the database.

All right, let's hit the code now. See you in the next article.