-
This solution is implemented using .Net Core version 3.1 and runs as a WebAPI application
-
The data layer is implemented using .Net core entity framework and Sql Server
-
The root directory contains README file, src folder and images.
-
The src folder is a place-holder for a number of services.
-
Under the
services
folder, ZipCOManagingUser
service with all its dependencies is stored -
This structure follows the Microservice and service oriented architecture
-
This structure is open to extension and new isolated services can be added within their
Bounded Context
-
Each services eventually is deployed as a container and is isolated from other services
-
In this exercise,
UserManaging
service is docker ready. Instruction is followed in the end
- UserManaging.Domain
- This project stores everything around the service domain. Examples like POCO classes like
Account
User
AccountType
enumeration etc. - The
AccountType
enumeration values are ZipMoney and ZipPay. The domain CRUD interface is palced here as well
- This project stores everything around the service domain. Examples like POCO classes like
- UserManaging.Infrastructure
- This Project configure the entity framework database and
DbContext
.It also implements the domain interface. The Create operation is in this project and Read oeprations are placed in the next project. It is a standard .net library
- This Project configure the entity framework database and
- UserManaging.CQRS
- This project is based on CQRS pattern and receive incoming request, execute the business logic and return the response to the caller.It utilizes the
MediatR
nugget package for request handling and execute validation rules usingFluentValidation
nugget package.Queries are separated into different folders and all the common queries are managed inside the classUserAccountQueries
.Furthermore this project configures the AutoMapper profile and implements the custom exception classes.
- This project is based on CQRS pattern and receive incoming request, execute the business logic and return the response to the caller.It utilizes the
- UserManaging.API
- This project is the .net core Web API. It resolves the dependencies,
- The
Users
andAccount
controllers are the API gateway for all CRUD operations. - Each controller's action accepts a request and sends it to appropriate request handler
- The request handler triggers each request based on the request type and returns the response.
- This project implements the
Custom error handler
using Asp.net Middleware
- UserManaging.Test
- This is the integration test project of the solution. It uses
SqlLite
database version of .Net core EF - The test project setup a temporary endpoints host and make HTTP requests using
HttpClient
to actual endpoints - Integration tests are covering the following scenarios
- Creating a New user and making sure it persisted to database
- Creating a New user with invalid email address, zero salary and zero expenses and get BadRequest
- Create two users with same email address and ensure second user is getting BadRequest due to duplicate email address
- Create a user and its account and check if user with its accounts persisted to database
- Create a user with salary and expense difference less than $1000 and get BadRequest
- Call
list all users
endpoint and ensure that collection is not empty - Call
list all accounts
endpoint and ensure that collection is not empty - Create user and account and call
Get User
and ensure it returned the correct record
- This is the integration test project of the solution. It uses
- docker-compose project
- This is the docker compose project which pulls sql server and .net core images and build api project
- create the sql server database and run the backend on port 5000.
- In order to run the API and Sql server, run in the
/src
folderdocker-compose build
and after thatdocker-compose up
- When the
docker-compose up
job is finished, access the backend api using http://localhost:5000 url - The endpoints are configured to show swagger
Example screen when API Swagger loads
Tests result