Hospital Visits is a .NET 6.0 based web application that manages hospital visits. It provides functionalities to retrieve hospital data and patient visits.
You can check out the demo API at this url
Sample call
curl --location 'https://hospitalvisitsexerciseapi.azurewebsites.net/hospital' \
The project follows the principles of Clean Architecture, which is divided into several layers:
- Domain Layer: Contains all entities such as
Hospital
,Doctor
,Patient
,PatientVisit
, andSpecialization
. - Application Layer: Contains application logic and is responsible for handling requests and responses using MediatR. It includes queries like
GetHospitalsQuery
andGetPatientVisitsQuery
. - Infrastructure Layer: Contains classes for accessing the database using Entity Framework. It includes the
HospitalVisitsContext
for database operations andHospitalRepository
for executing queries on the database. - Presentation Layer: Contains all API controllers. The
HospitalController
is responsible for handling HTTP requests.
The project uses Entity Framework for ORM and MediatR for implementing the Mediator pattern, which helps in reducing the coupling between various components of the application.
CQRS pattern has beed implemented in project
- Clone the repository.
- Install .NET 6.0 SDK.
- Run
dotnet restore
to restore the packages. - Add SQL Server Connection string in
appsettings.json
- Run
dotnet run
to start the application.
There are two main pipelines in this project:
-
Infrastructure Deployment Pipeline: This pipeline is responsible for deploying the infrastructure required for the application. It deploys a WebApp with an app plan using Azure Bicep templates. The pipeline is defined in the
.github/workflows/pipeline-infrastructure.yml
file. It can be triggered manually -
API Deployment Pipeline: This pipeline is responsible for deploying the API to the WebApp. It is defined in the
.github/workflows/pipeline.yml
file. It triggers after every PR merge
The project uses XUnit and NSubstitute as test package In this project, tests have been created only for the `GetPatientVisitsQuery`` query. However, it is recommended to create tests for other business logic in solution. It is also well recommended to consider "integration" api tests, but with mocked external services Such a tests can test our api logic end to end in fully isolated and runtime built environment.