BackEnd for the Student Profile Feature by Tabitha Jemwa u19294418 - COS-301/graduates GitHub Wiki
BackEnd
Introduction
The following paragraphs will detail the architecture of the service layer and the role of the service engineer in implementing the backend business logic required for the Student Profile feature of the Graduate’s Portal. In short the service layer is where all the relevant business logic will live.
The Service Layer
The service layer will follow the CQRS pattern. In the CQRS pattern the Command Handlers and Event Handlers will need to access data from the database but cannot do so directly therefore the repository layer is the interface between services and the database. Only the repositories will communicate with the database and then pass that data in a standardised format to the service that needs it. Then the services pass the data to the resolvers on the API layer and these resolvers resolve the data they need and present it in a certain way.
The CQRS pattern
Services are the starting point to dispatch CQRS commands,queries and events. On the service layer we will use commands,queries and events of the CQRS pattern. A command is a write to the database. A command handler is responsible for executing the command and this is where the logic will live when handling a specific command. Controllers or services will be used to dispatch the commands in order to update the repositories when needed. A query is a read from the database. A query handler will be used for the logic when handling the specific query.Controllers or services are responsible for handling the specific query.Events react to changes in the data. Much like how commands are dispatched by the service layer or sometimes even the controllers layer, events are dispatched by either Models or the EventBus. Events are responsible for keeping the data in the data store up to date.