CleanArchitecture.Blazor.Solution.Template
1.0.2
dotnet new install CleanArchitecture.Blazor.Solution.Template::1.0.2
Clean Architecture With Blazor Server
This repository hosts a Blazor Server application designed using Clean Architecture principles, featuring a sophisticated user interface and an efficient code generator. The application is built on .NET 9, which brings enhanced performance, improved developer productivity, and new features that make the development process smoother. Blazor Server, now supported on .NET 9, combines the power of C# with a modern web development experience, eliminating the need to switch between languages like JavaScript and C#. This setup simplifies development and enables fast, responsive, and highly interactive web applications. Leveraging Blazor’s real-time communication capabilities and .NET’s robust ecosystem, developers can rapidly create feature-rich, scalable applications with a seamless user experience.
Explore the Live Demo
Experience the application in action in Blazor Server mode by visiting:
MS SQL Database: architecture.blazorserver.com
PostgreSQL Database: architecture.blazors.app
Additional Note:
If you're also interested in exploring a version built with Blazor WebAssembly, it's now available! Please visit CleanAspire Repository for more details.
Projects Based on This Template
Here are some projects that have been developed based on this Clean Architecture Blazor Server template:
- HSE Management System (Workflow Application)
2. The DPP Application (EU Digital Product Passport)
Visual Insights
Explore the application's features and design through screenshots and a video walkthrough.
Development Setup
To get started with development, ensure you have the following tools and environments set up:
Authentication Setup
Use the following topics to configure your application to use the respective providers:
- Facebook instructions
- Twitter instructions
- Google instructions
- Microsoft instructions
- Other provider instructions
Docker Setup for Blazor Server Application
Pull the Docker Image
First, pull the latest version of the Blazor Server Docker image:
docker pull blazordevlab/cleanarchitectureblazorserver:latest
Run the Docker Container
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 (<Your...>) with your actual configuration details.
Docker Compose Setup
For easier management, use a docker-compose.yml file:
```yaml
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
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=YourStrongPassword!
ports:
- "1433:1433"
volumes:
- mssql_data:/var/opt/mssql
volumes:
files_volume:
mssql_data:
Notes:
Replace <Your...> placeholders with actual values from your environment. The files_volume volume is used for persistent storage of application files. Adjust or extend volumes based on your specific needs. This optimized guide should help in setting up your Blazor Server application with either an in-memory or MSSQL database, configured SMTP server for email functionalities, and OAuth authentication for Microsoft, Google, and Facebook.
Supported Databases
- PostgreSQL (Provider Name:
postgresql
) - Microsoft SQL Server (Provider Name:
mssql
) - SQLite (Provider Name:
sqlite
)
How to select a specific Database?
- Open the
appsettings.json
file located in the src directory of theServer.UI
project. - Change the setting
DBProvider
to the desired provider name (See Supported Databases). - Change the
ConnectionString
to a connection string, which works for your selected database provider.
Docker Compose HTTPS Deployment
Create self-signed development certificates for the project
cmd:dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\CleanArchitecture.Blazor.Server.UI.pfx -p Password@123
- cmd:
dotnet dev-certs https --trust
- cmd:
- Manage User secrets to save the password
- cmd:
dotnet user-secrets init
- cmd:
dotnet user-secrets -p Server.UI.csproj set "Kestrel:Certificates:Development:Password" "Password@123"
- cmd:
Code Generator Extension for Visual Studio 2022
The CleanArchitecture CodeGenerator for Blazor App is a powerful Visual Studio extension that helps developers streamline the creation of Blazor applications based on Clean Architecture principles.
<div><video controls src="https://user-images.githubusercontent.com/1549611/197116874-f28414ca-7fc1-463a-b887-0754a5bb3e01.mp4" muted="false"></video></div>
Features of CodeGenerator
- Automatically generates standard code for:
- Application Layer
- Domain Events
- Blazor UI Layer
- Simplifies the process of adding new entities and business logic.
- Enhances productivity by minimizing repetitive coding tasks.
Install CleanArchitecture CodeGenerator For Blazor App
- Open Manage Extensions Search with
CleanArchitecture CodeGenerator For Blazor App
- Download to Install
How to install solution templates
- Install the project template
- run CLI:
dotnet new install ./
- run CLI:
dotnet new list
- run CLI:
<img width="828" alt="image" src="https://github.com/neozhu/CleanArchitectureWithBlazorServer/assets/1549611/f23022e0-3fd6-475a-96ab-84b0d3328e4c">
create a solution with the template
- run CLI:
dotnet new ca-blazorserver-sln
ordotnet new ca-blazorserver-sln -n NewProjectName(root namespaces)
- run CLI:
build a project template with nuget.exe
- run CLI:
.\nuget.exe add -Source .\ CleanArchitecture.Blazor.Solution.Template.1.0.0-preview.1.nupkg
<img width="1329" alt="image" src="https://github.com/neozhu/CleanArchitectureWithBlazorServer/assets/1549611/7c56dec5-5935-4fc5-ad81-8bcb65e9d0dc"> - create a new project from Clean Architecture for Blazor Server Solution <img width="769" alt="image" src="https://github.com/neozhu/CleanArchitectureWithBlazorServer/assets/1549611/ed7eb20f-aec2-4f69-95b7-d47c2eb20428">
- run CLI:
Tutorial: Removing a cutomer Object from a Project
Tutorial: Adding a contact Entity in the project
Why I chose Blazor Server
I prefer Blazor Server because I dislike switching between C# and JavaScript during development. Blazor Server allows me to focus on C#.
Characteristics
- Real-Time Updates
- Avoid repeating work
- Focus on story implementation
- Integration with the Hangfire dashboard
- Implementation of OCR image recognition
- org chart
About
Coming up.
License
MIT License
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.2 | 138 | 1/20/2025 |
1.0.0-preview.26 | 161 | 8/9/2024 |
1.0.0-preview.21 | 111 | 4/18/2024 |
1.0.0-preview.20 | 805 | 2/21/2024 |
1.0.0-preview.19 | 275 | 2/13/2024 |
1.0.0-preview.18 | 336 | 2/2/2024 |
1.0.0-preview.17 | 1,524 | 12/6/2023 |
1.0.0-preview.16 | 1,396 | 10/14/2023 |
1.0.0-preview.15 | 95 | 9/22/2023 |
1.0.0-preview.14 | 98 | 8/28/2023 |
1.0.0-preview.12 | 91 | 8/15/2023 |
1.0.0-preview.11 | 95 | 8/10/2023 |
1.0.0-preview.10 | 96 | 8/9/2023 |
1.0.0-preview.9 | 128 | 8/9/2023 |
1.0.0-preview.8 | 84 | 8/8/2023 |
1.0.0-preview.7 | 82 | 8/8/2023 |
1.0.0-preview.6 | 123 | 7/21/2023 |
1.0.0-preview.5 | 97 | 7/16/2023 |
1.0.0-preview.4 | 92 | 7/11/2023 |
1.0.0-preview.3 | 101 | 7/5/2023 |
1.0.0-preview.2 | 106 | 7/5/2023 |
1.0.0-preview.1 | 134 | 7/3/2023 |
1.0.2
- 🌈 Integrate Stl.Fusion for real-time updates
- 🐛 fixed ocr process issue
- 🌈 Implement Google and Microsoft External Provider Authentication