This repository contains the bookservice sample app. This application is built to demonstrate CQRS pattern using Mediatr.
The BookService solution has the following projects
- BookStoreApi
- BooksStoreAPI.Models
- BooksStoreAPI.Application
- BookStoreAPI.Infrastructure
- BooksStoreAPI.DataMigration
The BookStoreAPI project represents the front end API layer of the solution. It has controllers which reposnd to the HTTP verbs Post, Put, Get and Delete. This project is implemented as an asp.net core 3.1 web api.
The BooksStoreAPI.Models project represents the data contract that the API layer uses as part of the HTTP verbs it implements.
The BooksStoreAPI.Application project implements the application layer. It is responsible for creating and dispatching commands that add, remove and updates the models into the persistence layer. It is also responsible for queries which are used to fetch data from the repository layer. This is further used by the Get implementation in the API layer.
The BooksStoreAPI.Infrastructure project implements the repository layer. It implements the repository and the unit of work pattern to persist data into the database. It also uses EFCore to connect to a SQL server database.
The BookStoreAPI.DataMigration project is reponsible to migrate and apply changes to the database schema. This project uses DBUP and embeded scripts to be able to deploy SQL scripts. These SQL scripts are versioned.
Clone this repo to your local machine using
git clone https://github.com/PradeepLoganathan/CQRSSample.git- Pull SQl Server Docker image
docker pull mcr.microsoft.com/mssql/server- Run Sql Server in a docker container
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=*Password@123*" -p 1433:1433 --name book-sqlserver -d mcr.microsoft.com/mssql/server- Check if Sql server is running and can be connected.
sqlcmd -S .,1433 -U SA -P "*Password@123*"- Build the application Run docker build.
Docker build .

