# Clean Architecture With Blazor Server
This repository hosts a Blazor Server application designed with Clean Architecture principles, featuring a sophisticated user interface and an efficient code generator. This setup allows for the swift creation of remarkable web applications using .NET Blazor technology.
Experience the application in action in Blazor Server mode by visiting
MS SQL Database: architecture.blazorserver.com
PostgreSQL Database: architecture.blazors.app
Dive into the application's aesthetics and functionality through screenshots and a video walkthrough.
To get started with development, ensure you have the following tools and environments set up:
This streamlined overview provides all the essential information about the Blazor Server application's repository, live demo, visual insights, and required development environment.
Use the following topics to configure your application to use the respective providers:
First, pull the latest version of the Blazor Server Docker image:
docker pull blazordevlab/cleanarchitectureblazorserver:latest
You can start the container in two modes: using an in-memory database for development purposes or connecting to an MSSQL database for persistent storage and configuring SMTP for email functionalities.
For Development (In-Memory Database):
docker run -p 8443:443 -e UseInMemoryDatabase=true -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_HTTPS_PORTS=443 blazordevlab/cleanarchitectureblazorserver:latest
For Production (Persistent Database and SMTP Configuration):
docker run -d -p 8443:443 \
-e UseInMemoryDatabase=false \
-e ASPNETCORE_ENVIRONMENT=Development \
-e ASPNETCORE_HTTP_PORTS=80 \
-e ASPNETCORE_HTTPS_PORTS=443 \
-e DatabaseSettings__DBProvider=mssql \
-e DatabaseSettings__ConnectionString="Server=127.0.0.1;Database=BlazorDashboardDb;User Id=sa;Password=<YourPassword>;MultipleActiveResultSets=true;Encrypt=false;TrustServerCertificate=false" \
-e SmtpClientOptions__User=<YourSMTPUser> \
-e SmtpClientOptions__Port=25 \
-e SmtpClientOptions__Server=<YourSMTPServer> \
-e SmtpClientOptions__Password=<YourSMTPPassword> \
-e Authentication__Microsoft__ClientId=<YourMicrosoftClientId> \
-e Authentication__Microsoft__ClientSecret=<YourMicrosoftClientSecret> \
-e Authentication__Google__ClientId=<YourGoogleClientId> \
-e Authentication__Google__ClientSecret=<YourGoogleClientSecret> \
-e Authentication__Facebook__AppId=<YourFacebookAppId> \
-e Authentication__Facebook__AppSecret=<YourFacebookAppSecret> \
blazordevlab/cleanarchitectureblazorserver:latest
Replace placeholder values (
For easier management, use a docker-compose.yml file:
version: '3.8'
services:
blazorserverapp:
image: blazordevlab/cleanarchitectureblazorserver:latest
environment:
- UseInMemoryDatabase=false
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80;https://+:443
- ASPNETCORE_HTTP_PORTS=80
- ASPNETCORE_HTTPS_PORTS=443
- DatabaseSettings__DBProvider=mssql
- DatabaseSettings__ConnectionString=Server=127.0.0.1;Database=BlazorDashboardDb;User Id=sa;Password=***;MultipleActiveResultSets=true;Encrypt=false;TrustServerCertificate=false
- SmtpClientOptions__User=<YourSMTPUser>
- SmtpClientOptions__Port=25
- SmtpClientOptions__Server=<YourSMTPServer>
- SmtpClientOptions__Password=<YourSMTPPassword>
- Authentication__Microsoft__ClientId=<YourMicrosoftClientId>
- Authentication__Microsoft__ClientSecret=<YourMicrosoftClientSecret>
- Authentication__Google__ClientId=<YourGoogleClientId>
- Authentication__Google__ClientSecret=<YourGoogleClientSecret>
- Authentication__Facebook__AppId=<YourFacebookAppId>
- Authentication__Facebook__AppSecret=<YourFacebookAppSecret>
ports:
- "8443:443"
volumes:
- files_volume:/app/Files
volumes:
files_volume:
Replace
postgresql
)mssql
)sqlite
)appsettings.json
file located in the src directory of the Server.UI
project.DBProvider
to the desired provider name (See Supported Databases).ConnectionString
to a connection string, which works for your selected database provider.cmd: dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\CleanArchitecture.Blazor.Server.UI.pfx -p Password@123
dotnet dev-certs https --trust
dotnet user-secrets init
dotnet user-secrets -p Server.UI.csproj set "Kestrel:Certificates:Development:Password" "Password@123"
CleanArchitecture CodeGenerator For Blaozr App
The code generator can automatically generate the standard code
dotnet new install ./
dotnet new list
create a solution with the template
dotnet new ca-blazorserver-sln
or dotnet new ca-blazorserver-sln -n NewProjectName(root namesapces)
build a project template with nuget.exe
.\nuget.exe add -Source .\ CleanArchitecture.Blazor.Solution.Template.1.0.0-preview.1.nupkg
Coming up.
MIT License