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.
Domain/Entities:
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
App: Run the express webserver and makes the necessary objects to satisfy the inner layer's dependencies
ExpressAdapter: Adapt the express request object into the controller format.
CreatePolicyController: Adapt the data into the CreatePolicyUseCase format and inject the use case dependencies from the external layers.
CreatePolicyUseCase: Apply the business logic using the PolicyRepository and PolicyEntity.
PolicyEntity: Apply the business rules which every policy holder needs to satisfy.
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.