# CleanArchitectureWithBlazorServer **Repository Path**: liuyh208/CleanArchitectureWithBlazorServer ## Basic Information - **Project Name**: CleanArchitectureWithBlazorServer - **Description**: cleanζΆζdemo - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-07-26 - **Last Updated**: 2025-07-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ο»Ώ# Clean Architecture Blazor Server [](https://github.com/neozhu/CleanArchitectureWithBlazorServer/actions/workflows/dotnet.yml) [](https://github.com/neozhu/CleanArchitectureWithBlazorServer/actions/workflows/codeql-analysis.yml) [](https://www.nuget.org/packages/CleanArchitecture.Blazor.Solution.Template) [](https://github.com/neozhu/CleanArchitectureWithBlazorServer/actions/workflows/docker-image.yml) [](https://www.nuget.org/packages/CleanArchitecture.Blazor.Solution.Template) > A comprehensive Blazor Server application template built with Clean Architecture principles, featuring advanced code generation, AI-powered development support, and enterprise-grade functionality. ## π― Overview This project is a production-ready Blazor Server application template that demonstrates Clean Architecture implementation with .NET 9. It provides a solid foundation for building scalable, maintainable enterprise applications with modern development practices and AI-enhanced productivity features. ### Key Features - **ποΈ Clean Architecture**: Strict layer separation with dependency inversion - **π€ AI-Powered Development**: Integrated Cursor/Copilot support with comprehensive rules - **π¨ 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: [](https://www.youtube.com/watch?v=hCsHSNAs-70) **Live Demo**: [architecture.blazorserver.com](https://architecture.blazorserver.com/) ### Featured Projects Built with This Template [](https://hse.blazorserver.com/) **HSE Management System** - [GitHub](https://github.com/neozhu/workflow) | [Live Demo](https://hse.blazorserver.com/) [](https://materialpassport.blazorserver.com/) **EU Digital Product Passport** - [Live Demo](https://materialpassport.blazorserver.com/) ## π οΈ Technology Stack | Layer | Technologies | |-------|-------------| | **Frontend** | Blazor Server, MudBlazor, SignalR | | **Backend** | .NET 9, 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 ## π€ AI-Powered Development This project is optimized for AI-assisted development with comprehensive support for modern AI coding tools. ### π― Cursor AI Integration The project includes extensive [Cursor Rules](.cursor/rules/) that provide: - **Architecture Guidelines**: Enforce Clean Architecture principles - **Coding Standards**: Consistent patterns and best practices - **Component Templates**: Pre-configured Blazor component structures - **Security Patterns**: Built-in security implementation guides ### π Development Workflow Enhanced productivity through AI-powered development: - **Intelligent Code Generation**: Context-aware suggestions following project patterns - **Automatic Layer Compliance**: AI ensures proper dependency flow - **Pattern Recognition**: Consistent implementation across features - **Smart Refactoring**: Architecture-aware code improvements ### π‘ Getting Started with AI Development 1. **Install Cursor**: Download from [cursor.sh](https://cursor.sh/) 2. **Load the Project**: Open the repository in Cursor 3. **Enable Rules**: The AI will automatically use the configured rules 4. **Start Coding**: Use natural language to describe features **Example AI Prompts**: ``` "Create a new Product entity with CRUD operations following Clean Architecture" "Add user authentication to the Orders page" "Implement caching for the CustomerService" ``` ### π Development Workflow The project includes a comprehensive [Development Workflow](docs/) 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 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0) - [Visual Studio 2022](https://visualstudio.microsoft.com/) or [Rider](https://www.jetbrains.com/rider/) - [Docker Desktop](https://www.docker.com/) (optional) ### Installation 1. **Install the Template** ```bash dotnet new install CleanArchitecture.Blazor.Solution.Template ``` 2. **Create New Project** ```bash dotnet new ca-blazorserver-sln -n YourProjectName cd YourProjectName ``` 3. **Setup Database** ```bash dotnet ef database update --project src/Migrators/Migrators.MSSQL ``` 4. **Run the Application** ```bash dotnet run --project src/Server.UI ``` 5. **Access the Application** - Navigate to `https://localhost:7152` - Login with default credentials (see documentation) ### π³ Docker Deployment **Quick Start with In-Memory Database**: ```bash docker run -p 8443:443 -e UseInMemoryDatabase=true \ blazordevlab/cleanarchitectureblazorserver:latest ``` **Production Setup**: ```bash docker-compose up -d ``` See [Docker Setup Documentation](#docker-setup-for-blazor-server-application) for detailed configuration. ## π Documentation - **[Architecture Guide](docs/)**: Detailed architecture explanation - **[Development Workflow](docs/)**: Step-by-step development process - **[API Documentation](docs/)**: Complete API reference - **[Deployment Guide](docs/)**: Production deployment instructions - **[Contributing Guidelines](CONTRIBUTING.md)**: How to contribute to the project ## π§ Code Generation Accelerate development with the Visual Studio extension: - **[CleanArchitecture CodeGenerator](https://github.com/neozhu/CleanArchitectureCodeGenerator)** - Automatically generates layers for new entities - Maintains architectural consistency - Reduces boilerplate code by 80%
## ποΈ Database Support | Database | Provider Name | Status | |----------|---------------|---------| | SQL Server | `mssql` | β Fully Supported | | PostgreSQL | `postgresql` | β Fully Supported | | SQLite | `sqlite` | β Fully Supported | Configure in `appsettings.json`: ```json { "DatabaseSettings": { "DBProvider": "mssql", "ConnectionString": "Server=localhost;Database=YourDb;Trusted_Connection=true;" } } ``` ## π Authentication Providers Configure OAuth providers in `appsettings.json`: - **Microsoft**: [Setup Guide](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/microsoft-logins) - **Google**: [Setup Guide](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins) - **Facebook**: [Setup Guide](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) - **Twitter**: [Setup Guide](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/twitter-logins) ## π Docker Setup for Blazor Server Application ### Pull the Docker Image ```bash docker pull blazordevlab/cleanarchitectureblazorserver:latest ``` ### Run the Docker Container For Development (In-Memory Database): ```bash 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): ```bash 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=