A simple, self-contained web api to demonstrate how to perform api commands and queries which manipulates different text files. This concept can easily be translated and configured to a local or live database .
- API documentation is automatically generated using Swagger.
- Cross-platform with dotnet core
- Data is contained in text files, attached to the project in the 'Data/' folder.
- Project runs locally, no configuration needed.
- Can perform CRUD Actions.
- ASP.NET Core WebAPI
- Clone or Fork the repo.
- In the downloaded folder, double-click the 'CarWebAPI.sln' file to open the solution.
- Run the solution by clicking the green arrow 'CarWebAPI'.
The Repository Pattern was chosen to decouple the data access layer from domain model layer. This decoupling helps remove any dependencies, repitition of logic and enforces separation. This is done through Dependency Injection in which the repositories are only injected into the required domain layers.
The Service layer was excluded from this project, as the service layer adds an extra layer between the Domain and Repository layer. This layer esssentially duplicates the Respostory layer, which requires duplication of code for each new action or query in the repository. Including the service layer will slow down development and require more effort in adding new logic to the repository layer.
The CQS Pattern was chosen to seperate the action logic (Create, Update, Delete) from the query logic (Read). This seperates the logic of concern and makes it easier to identify and use. New logic for can be easily added by identifying whether it is a command or query, simplifying the development process. With this seperation it also makes it easier to enforce restricted access for the command logic.