WORK IN PROGRESS (for now you can try Console or GraphQL on Model for demo purpose)
You will find the value objects, entities and aggregates in domain directory :
- Booking is an aggregate root which contains entities Customer, Vehicle;
- Customer is an entity with a life cycle, at first it could be a simple Prospect (with an ip address) to look for a vehicule to book. If the Customer is a Prospect and wants to effectively book the Vehicule, he then becomes a Professional Customer (with a siret) or an Individual Customer (with an id);
- Vehicle is an entity with a registration id and has a Model;
- Model is a tuple of name and brand.
The application directory contains all the use Cases implementations :
- createModel, updateModel, removeModel, getAllModels;
- createCustomer, updateCustomer;
- createVehicle, updateVehicle;
- checkVehicleAvailability, bookVehicle, unbookVehicle.
For now the Model cycle is fully described, the others are in progress.
See DDD above.
Use Cases and Interfaces for Use Cases : Input Port, Output Port, Repository - layer 1 : depend only on layer 0 objects and eventually objects from same layer -
The application directory contains interfaces for Use Cases Input Ports (Use Cases interfaces to implement) and Output Ports (Presenters interfaces to implement). The repository interfaces are also present in each entity directory under application/interfaces.
These interfaces are useful as no Use Case depends on outside implementations, just on interfaces. For Use Cases implementations see DDD above.
You will find the Output Ports Interfaces implementations in the Presenters directory.
- Data Providers - IRepository implementations -, for now In Memory repositories for demo purpose - could be MongoDB, PostGreSQL, other API, etc. -;
- Controllers - to demonstrate purpose and benefits of this architecture you will have a Console controller and a GraphQL controller -.
After having downloaded the project, launch yarn install
.
yarn run console
: follow the console displayed menu.
yarn run graphql
: open a browser on graphQL server to access playground.
As you can see the business logic is completely isolated from Console app or GraphQL server. If you want to add new repositories implementations - such as MongoDB, PostGreSQL, MariaDB, other API, etc. - or new controllers - Express, Fastify REST API, etc. -, this could be done only in the Infrastructure Layer without changing anything in the Business Logic Layers (Entities/Domain and Use Cases/Application).
If you want to add new Presenters, for example in XML or any format you need, create them without changing anything in Business Logic Layers. You will just have to inject them in your controller.