CleanArchitectureWithBlazorServer
This repository is designed to create an enterprise Blazor Server application that follows the principles of Clean Architecture and implements Blazor Clean Architecture best practices for scalability, maintainability, and testability.
Install / Use
/learn @neozhu/CleanArchitectureWithBlazorServerREADME
Clean Architecture Blazor Server application template
A production-ready Blazor Server application template built on Clean Architecture principles, offering advanced code generation, AI-assisted development workflows, and enterprise-grade capabilities for building scalable and maintainable systems.
🎯 Overview
This repository provides a production-grade Blazor Server solution template designed in strict accordance with Clean Architecture principles and modern enterprise application standards.
Built on .NET 10, the template demonstrates a well-structured, scalable, and maintainable architecture for developing complex business systems. It integrates advanced code generation capabilities, AI-assisted development workflows, and specification-driven design patterns, enabling teams to accelerate development while preserving architectural consistency and code quality.
The solution is intended to serve both as a reference implementation for Blazor Clean Architecture best practices and as a ready-to-use foundation for enterprise-level applications that require long-term maintainability, extensibility, and high development efficiency.
Key Features
- 🏗️ Clean Architecture: Strict layer separation with dependency inversion
- 🎨 Modern UI: Beautiful, responsive interface built with MudBlazor
- ⚡ Real-time Communication: SignalR integration for live updates
- 🔐 Enterprise Security: Multi-factor authentication, role-based access control
- 🌐 Multi-tenancy: Built-in tenant isolation and management
- 📊 Advanced Data Grid: Sorting, filtering, pagination, and export capabilities
- 🎨 Code Generation: Visual Studio extension for rapid development
- 🐳 Docker Ready: Complete containerization support
- 📱 Progressive Web App: PWA capabilities for mobile experience
🌟 Live Showcase
Experience the application in action:
Live Demo: architecture.blazorserver.com
Featured Projects Built with This Template
Enabling collaboration between employers, suppliers, and HR management with integrated attendance, work hours, and billing in a seamless online closed loop.
BLAZOR PARKING SYSTEM - GitHub | Live Demo
HSE Management System - GitHub | Live Demo
EU Digital Product Passport - Live Demo
🛠️ Technology Stack
| Layer | Technologies | |-------|-------------| | Frontend | Blazor Server, MudBlazor, SignalR | | Backend | .NET 10, ASP.NET Core, MediatR, FluentValidation | | Database | Entity Framework Core, MSSQL/PostgreSQL/SQLite | | Authentication | ASP.NET Core Identity, OAuth 2.0, JWT | | Caching | FusionCache, Redis | | Background Jobs | Hangfire | | Testing | xUnit, FluentAssertions, Moq | | DevOps | Docker, GitHub Actions |
🏗️ Architecture Overview
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Server.UI │ │ Application │ │ Domain │
│ (Blazor) │───▶│ (Business) │───▶│ (Entities) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
│ ┌─────────────────┐
└─────────────▶│ Infrastructure │
│ (Data/IO) │
└─────────────────┘
Layer Responsibilities
- Domain: Core business entities and rules (no dependencies)
- Application: Business logic, interfaces, and DTOs
- Infrastructure: External concerns (database, email, file system)
- Server.UI: Blazor components and user interface
📋 Development Workflow
The project includes a comprehensive Development Workflow with:
- Task Management: Structured approach to feature development
- Code Review Guidelines: Quality assurance processes
- Testing Strategies: Unit and integration testing patterns
- Deployment Procedures: CI/CD pipeline configurations
🚀 Quick Start
Prerequisites
- .NET 10 SDK
- Visual Studio 2022 or Rider
- Docker Desktop (optional)
Installation
-
Install the Template
dotnet new install CleanArchitecture.Blazor.Solution.Template -
Create New Project
dotnet new ca-blazorserver-sln -n YourProjectName cd YourProjectName -
Setup Database
dotnet ef database update --project src/Migrators/Migrators.MSSQL -
Run the Application
dotnet run --project src/Server.UI -
Access the Application
- Navigate to
https://localhost:7152 - Login with default credentials (see documentation)
- Navigate to
🐳 Docker Deployment
Run with configured database provider (In-Memory removed):
docker run -p 8443: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" \
blazordevlab/cleanarchitectureblazorserver:latest
Production Setup (docker compose):
docker-compose up -d
See Docker Setup Documentation for detailed configuration.
📚 Documentation
- Architecture Guide: Detailed architecture explanation
- Development Workflow: Step-by-step development process
- API Documentation: Complete API reference
- Deployment Guide: Production deployment instructions
- Contributing Guidelines: How to contribute to the project
📐 Using OpenSpec for Feature Development
OpenSpec enables spec-driven, reviewable changes with clear proposals, deltas, and tasks. This repo includes guidance in openspec/AGENTS.md and a project context in openspec/project.md.
- Read the quickstart:
openspec/AGENTS.md - Project conventions and patterns:
openspec/project.md(see "New Entity/Feature Guide (Contacts Pattern)")
Workflow
- Plan a change
- Review specs and pending changes
openspec list --specsopenspec list
- Pick a unique, verb-led change id (e.g.,
add-customer-management).
- Create the change folder and docs
- Create:
openspec/changes/<change-id>/ - Add files:
proposal.md– Why, What Changes, Impacttasks.md– Implementation checklist- Optional
design.md– Architecture decisions when needed - Spec deltas:
openspec/changes/<change-id>/specs/<capability>/spec.md
- Spec delta format must include sections like:
## ADDED|MODIFIED|REMOVED Requirements- At least one
#### Scenario:per requirement (use the exact header text)
- Validate and iterate
openspec validate <change-id> --strict- Fix any issues before requesting review/approval.
- Implement after approval
- Follow the tasks in
tasks.mdsequentially and mark them complete. - Use the patterns in
openspec/project.md:- For data access in handlers use
IApplicationDbContextFactoryand per-operation context lifetime:await using var db = await _dbContextFactory.CreateAsync(cancellationToken);
- Follow MediatR pipeline behaviors, caching tags, and specification patterns.
- Mirror the Contacts module for a new entity's DTOs, commands, queries, specs, security, and UI pages/components.
- For data access in handlers use
- Archive after deployment
- Move
openspec/changes/<id>/toopenspec/changes/archive/YYYY-MM-DD-<id>/(or use the CLI archive helper if available). - Re-run
openspec validate --strict.
Example change scaffold
- Change id:
add-customer-management - Files:
openspec/changes/add-customer-management/proposal.mdopenspec/changes/add-customer-management/tasks.mdopenspec/changes/add-customer-management/specs/customers/spec.md
proposal.md skeleton:
## Why
Introduce Customer management to track client records.
## What Changes
- Add Customer entity, CRUD flows, and pages
- Add permissions and navigation
## Impact
- Affected specs: customers


