f-nunez / VeterinaryClinic

Veterinary Clinic in .NET 7 with clean architecture for Blazor Web Assembly ASP.NET Core hosted model and built with Radzen Components
MIT License
6 stars 0 forks source link
blazor clean-architecture ddd domain-driven-design dotnet entity-framework-core identity-server masstransit repository-pattern signalr specification-pattern unit-of-work xunit

Veterinary Clinic

Open sourced solution for Blazor Web Assembly ASP.NET Core hosted model and built with Radzen Components.

About

Hobby project related to a Veterinary Clinic System. Which is designed on a modular monolithic architecture consisting of the following applications:

Demo

Technologies

Backend

Frontend

Deployment

Testing

Getting Started

Pre-requisites before having the solution deployed:

Self Signed Certificate

For local development/testing purposes we need a certificate installed on each device where we'll have a secure communication between client and server. For this example, we're going to register public and internal services in the same certificate. Currently, there are two options to get achieve this:

1. Import existing Self Signed Certificate

Currently, at _docker/certs folder you will find a demo certificate ready to get it installed.

Import the Personal Information Exchange file:

.../VeterinaryClinic/_docker/certs/veterinaryclinic.pfx

where the requested password will be:

VeterinaryClinic123!

and then install the Security Certificate file:

.../VeterinaryClinic/_docker/certs/veterinaryclinic.crt

2. Generate your own Self Signed Certificate

Using OpenSSL open-source cryptographic library, execute the following commands:

Create the Security Certificate (with password set as VeterinaryClinic123!):

openssl req -x509 -newkey rsa:4096 -keyout veterinaryclinic.key -out veterinaryclinic.crt -subj "/CN=vc.local" -addext "subjectAltName=DNS:localhost,DNS:vc.local,DNS:identity-api.vc.local,DNS:clinicmanagement-api.vc.local,DNS:clinicmanagement-blazor.vc.local,DNS:clinicmanagementnotifications-api.vc.local,DNS:scheduling-api.vc.local,DNS:scheduling-blazor.vc.local,DNS:schedulingnotifications-api.vc.local,DNS:schedulingemailsender-api.vc.local,DNS:emailservice-api.vc.local,DNS:public-web.vc.local,DNS:identity-api,DNS:clinicmanagement-api,DNS:clinicmanagement-blazor,DNS:clinicmanagementnotifications-api,DNS:scheduling-api,DNS:scheduling-blazor,DNS:schedulingnotifications-api,DNS:schedulingemailsender-api" -days=365

Export the Personal Information Exchange:

openssl pkcs12 -export -in veterinaryclinic.crt -inkey veterinaryclinic.key -out veterinaryclinic.pfx -name "Veterinary Clinic Development"

Then replace those files in /certs folder and import them:

.../VeterinaryClinic/_docker/certs

After getting the certificate ready you should re-open your browser (if it's already open).

Configure Hosts file

The hosts file (also referred as etc/hosts) is a text file used by operating systems (Linux/Windows) to map IP addresses to domain names. These domain names will allow us to get them linked to our applications.

Hosts file path in Linux:

/etc/hosts

Hosts file path in Windows:

C:\Windows\System32\drivers\etc\hosts

Add the following lines into your hosts file at the end of the document:

127.0.0.1 vc.local
127.0.0.1 identity-api.vc.local
127.0.0.1 clinicmanagement-blazor.vc.local
127.0.0.1 scheduling-blazor.vc.local
127.0.0.1 public-web.vc.local

Flush DNS Resolver Cache

After getting the Hosts file configured. You must flush your DNS records by using your terminal to get changes be reflected immediately.

Using Linux:

sudo systemd-resolve --flush-caches

Using Windows:

ipconfig /flushdns

Deployment

You will find Docker Compose files at the repository root folder which will represent profiles (options) to deploy and run the entire solution.

Those deployment profiles (Deployment options) are:

Just choose your poison, where the first one is the most toxic and the other two options are the less painful deployments.

1. Default deployment (Manual deployment)

The docker-compose.yml file which only deploys a basic infrastructure (RabbitMQ and SQL Server) lets you run each project and set it as preferred.

Open your terminal and set yourself at repository root folder to build the images:

docker compose build --no-cache

After the images were build proceed to create and start containers:

docker compose up -d

Then you will have RabbitMQ and SQL Server containers ready to use them.

Running Identity Api https://localhost:7066

...\Fnunez.VeterinaryClinic.Identity.Api> dotnet run --launch-profile=https

Running Clinic Management Blazor App https://localhost:7004

...\Fnunez.VeterinaryClinic.ClinicManagement.BlazorClient.Server> dotnet run --launch-profile=https

Running Clinic Management Api https://localhost:7229

...\Fnunez.VeterinaryClinic.ClinicManagement.Api> dotnet run --launch-profile=https

Running Clinic Management Notifications Api https://localhost:7082

...\Fnunez.VeterinaryClinic.ClinicManagementNotifications.Api> dotnet run --launch-profile=https

Running Scheduling Blazor App https://localhost:7154

...\Fnunez.VeterinaryClinic.Scheduling.BlazorClient.Server> dotnet run --launch-profile=https

Running Scheduling Api https://localhost:7266

...\Fnunez.VeterinaryClinic.Scheduling.Api> dotnet run --launch-profile=https

Running Scheduling Notifications Api https://localhost:7183

...\Fnunez.VeterinaryClinic.SchedulingNotifications.Api> dotnet run --launch-profile=https

Running Scheduling Email Sender Api https://localhost:7195

...\Fnunez.VeterinaryClinic.SchedulingEmailSender.Api> dotnet run --launch-profile=https

Running Email Service Api https://localhost:7284

...\Fnunez.VeterinaryClinic.EmailService.Api> dotnet run --launch-profile=https

Running Public Web https://localhost:7138

...\Fnunez.VeterinaryClinic.Public.Web> dotnet run --launch-profile=https

Stop and remove the containers:

docker compose down

2. DockerDevelopment deployment (Automatic deployment)

The docker-compose.DockerDevelopment.yml file provides full deploy and gets ready to test the entire solution.

Open your terminal and set yourself at repository root folder to build the images:

docker compose -f docker-compose.DockerDevelopment.yml build --no-cache

After the images were build proceed to create and start containers:

docker compose -f docker-compose.DockerDevelopment.yml up -d

Once containers are created and started, test the access of the following links:

Identity Api https://identity-api.vc.local:7066

Clinic Management Blazor App https://clinicmanagement-blazor.vc.local:7004

Scheduling Blazor App https://scheduling-blazor.vc.local:7154

Public Web https://public-web.vc.local:7138

Stop and remove the containers:

docker compose -f docker-compose.DockerDevelopment.yml down

3. DockerNginx deployment (Automatic deployment)

The docker-compose.DockerNginx.yml has the same deployment infrastructure as the second profile but contains a fancy deployment behind Nginx server as reverse proxy for those applications that need to be protected from the outside (Internet).

Open your terminal and set yourself at repository root folder to build the images:

docker compose -f docker-compose.DockerNginx.yml build --no-cache

After the images were build proceed to create and start containers:

docker compose -f docker-compose.DockerNginx.yml up -d

Once containers are created and started, test the access of the following links:

Identity Api https://identity-api.vc.local

Clinic Management Blazor App https://clinicmanagement-blazor.vc.local

Scheduling Blazor App https://scheduling-blazor.vc.local

Public Web https://public-web.vc.local

Stop and remove the containers:

docker compose -f docker-compose.DockerNginx.yml down

Testing

In every solution folder you can run the test cases. As an example:

...\VeterinaryClinic\ClinicManagement> dotnet test

Unit Tests

Run specified tests for unit.

dotnet test --filter FullyQualifiedName~UnitTests

Integration Tests

Run specified tests for integration. Keep in mind these tests are longests because perform operations against database.

dotnet test --filter FullyQualifiedName~IntegrationTests

Give a Star! :star:

If you liked this project, please give it a star. Thanks! (n_n)/ :star:

Credits

This project was inspired from:

License

MIT License