Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

243 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Blazor CRUD Demo

A comprehensive Blazor Server application demonstrating enterprise-level CRUD operations with JWT authentication, role-based authorization, audit logging, and real-time features. This project showcases modern web development best practices using .NET 8 and Blazor Server.

Blazor CRUD Demo .NET C# SQLite JWT SignalR

Features

πŸ” Authentication & Authorization

  • Hybrid Authentication: Cookie-based (Blazor Server) + JWT (API endpoints)
  • User Registration & Login: Complete authentication system with email/password
  • Password Recovery: Forgot password functionality with email reset
  • User Management: Admin panel for user administration
  • Role-Based Access Control (RBAC): Admin and User roles with policy-based authorization
  • Profile Management: User profile editing and settings
  • Token Refresh: Secure refresh token mechanism with automatic renewal
  • Account Security: Account lockout protection, password hashing (PBKDF2)
  • Audit Logging: Complete tracking of all authentication events

πŸ“– Complete Authentication Documentation | Testing Guide

πŸ“Š Dashboard

  • Real-time Statistics: Live metrics and data visualization
  • Activity Feed: Recent user and system activities
  • Quick Actions: Fast access to common tasks
  • Responsive Design: Optimized for all screen sizes

🏷️ Product Management

  • Complete CRUD Operations: Create, Read, Update, Delete products
  • Advanced Search & Filtering:
    • Multi-category filtering with checkboxes
    • Price range sliders
    • Date range selection
    • Real-time search with instant results
    • Tag-based filtering system
  • Image Upload: Product image management with preview
  • Rich Text Editor: HTML content support for product descriptions
  • Bulk Operations: Multi-select and batch actions

πŸ“ Category Management

  • Hierarchical Categories: Parent-child category relationships
  • Category Organization: Drag-and-drop ordering
  • Icon Support: Custom icons for visual categorization
  • Display Management: Category visibility and ordering controls

πŸ‘₯ Admin Panel

  • User Administration: Complete user management interface
  • Audit Logging: Comprehensive system audit trail
  • System Monitoring: Performance metrics and health checks
  • Configuration Management: Application settings interface

πŸ” Advanced Features

  • Real-time Notifications: SignalR-powered live updates
  • Background Services: Automated maintenance and cleanup tasks
  • Error Handling: Global exception handling with user-friendly error pages
  • Offline Support: Network status detection and offline mode
  • State Management: Global application state container
  • Audit Trail: Complete activity logging for compliance
  • Data Validation: Comprehensive client and server-side validation
  • Currency Input: International currency formatting and validation

πŸš€ Technical Features

  • Clean Architecture: Layered architecture with separation of concerns
  • Dependency Injection: Comprehensive DI container setup
  • Middleware Pipeline: Request/response logging and global error handling
  • Entity Framework Core: Advanced ORM with migrations and seeding
  • AutoMapper: Object-to-object mapping for DTOs
  • FluentValidation: Model validation with custom rules
  • Serilog: Structured logging with detailed context
  • Responsive Design: Bootstrap 5 with mobile-first approach
  • Component Library: Reusable UI components and controls

Getting Started

Prerequisites

  • .NET 8.0 SDK or later
  • Visual Studio 2022 / VS Code / JetBrains Rider
  • SQLite (included) or SQL Server
  • Node.js (for frontend dependencies)

Installation

  1. Clone the repository
git clone https://github.com/yourusername/BlazorCrudDemo.git
cd BlazorCrudDemo
  1. Database Setup

    • SQLite is used by default (no additional setup required)
    • For SQL Server, update the connection string in appsettings.json
    • Run database migrations (see Database Setup)
  2. Run the application

# Start the application
cd BlazorCrudDemo.Web
dotnet run

The database file (blazorcrud.db) will be created automatically with seed data.

4. Run the application

cd BlazorCrudDemo.Web
dotnet watch

5. Access the application

  • Open your browser and navigate to http://localhost:5120
  • Default Admin Account:
    • Email: admin@demo.com
    • Password: Admin123!
  • The dashboard will load with sample data for demonstration

Project Structure

BlazorCrudDemo/
β”œβ”€β”€ BlazorCrudDemo.Data/          # Data access layer
β”‚   β”œβ”€β”€ Configurations/          # Entity Framework configurations
β”‚   β”œβ”€β”€ Contexts/                # Database context & interceptors
β”‚   β”œβ”€β”€ Interfaces/              # Repository interfaces
β”‚   └── Repositories/            # Data repository implementations
β”‚
β”œβ”€β”€ BlazorCrudDemo.Shared/       # Shared models and utilities
β”‚   β”œβ”€β”€ DTOs/                   # Data Transfer Objects
β”‚   β”œβ”€β”€ Models/                 # Domain models (Product, Category, User, Audit)
β”‚   β”œβ”€β”€ Validators/             # Input validation rules
β”‚   └── Exceptions/             # Custom exception types
β”‚
└── BlazorCrudDemo.Web/          # Blazor Server application
    β”œβ”€β”€ BackgroundServices/      # Automated background tasks
    β”‚   └── MaintenanceServices.cs
    β”‚
    β”œβ”€β”€ Components/             # Reusable UI components
    β”‚   β”œβ”€β”€ Categories/         # Category management components
    β”‚   β”œβ”€β”€ Dashboard/         # Dashboard widgets and charts
    β”‚   β”œβ”€β”€ Layout/            # Navigation and layout components
    β”‚   β”œβ”€β”€ Products/          # Product form and display components
    β”‚   β”œβ”€β”€ Search/            # Advanced search and filter components
    β”‚   └── Shared/            # Common UI elements (inputs, modals, etc.)
    β”‚
    β”œβ”€β”€ Configuration/         # Application configuration
    β”‚   └── IdentityServerConfig.cs
    β”‚
    β”œβ”€β”€ Hubs/                  # SignalR hubs for real-time features
    β”‚   └── NotificationHub.cs
    β”‚
    β”œβ”€β”€ Middleware/            # Custom middleware
    β”‚   β”œβ”€β”€ GlobalExceptionHandlerMiddleware.cs
    β”‚   └── RequestResponseLoggingMiddleware.cs
    β”‚
    β”œβ”€β”€ Pages/                 # Application pages
    β”‚   β”œβ”€β”€ Account/           # User profile and settings
    β”‚   β”œβ”€β”€ Admin/             # Administrative functions
    β”‚   β”œβ”€β”€ Auth/              # Authentication pages (Login, Register, etc.)
    β”‚   β”œβ”€β”€ Categories.razor   # Category management
    β”‚   β”œβ”€β”€ Dashboard/         # Main dashboard
    β”‚   β”œβ”€β”€ Error.razor        # Error handling
    β”‚   └── Products/          # Product management
    β”‚
    β”œβ”€β”€ Services/              # Business logic services
    β”‚   β”œβ”€β”€ AuthenticationService.cs
    β”‚   β”œβ”€β”€ AuditService.cs
    β”‚   β”œβ”€β”€ CategoryService.cs
    β”‚   β”œβ”€β”€ ProductService.cs
    β”‚   β”œβ”€β”€ UserService.cs
    β”‚   └── NotificationService.cs
    β”‚
    └── wwwroot/               # Static assets
        β”œβ”€β”€ css/              # Custom stylesheets
        β”œβ”€β”€ js/               # JavaScript files
        └── lib/              # Third-party libraries (Bootstrap, Font Awesome)

Technologies Used

Frontend

  • Blazor Server - .NET web framework for interactive web UIs
  • Bootstrap 5 - Responsive CSS framework with mobile-first design
  • Font Awesome 6 - Comprehensive icon library
  • JavaScript Interop - Client-side functionality integration

Backend

  • .NET 8.0 - Cross-platform development framework
  • ASP.NET Core - Web framework for hosting and middleware
  • Entity Framework Core 8.0 - Object-relational mapping with advanced features
  • SignalR - Real-time web functionality for live updates
  • AutoMapper - Object-to-object mapping for DTOs
  • FluentValidation - Model validation with custom business rules

Database & Storage

  • SQLite - Lightweight, file-based database with full EF Core support
  • Entity Framework Core Migrations - Database schema management and versioning
  • Audit Trail - Complete activity logging and change tracking

Authentication & Security

  • ASP.NET Core Identity - User management and authentication
  • Duende IdentityServer - OAuth 2.0 and OpenID Connect framework
  • Password Hashing - Secure password storage and validation
  • Role-Based Authorization - Permission-based access control

Development & Monitoring

  • Serilog - Structured logging with rich context information
  • Background Services - Automated tasks and maintenance operations
  • Error Boundaries - Graceful error handling and recovery
  • Request/Response Logging - HTTP traffic monitoring and analysis
  • Network Status Detection - Online/offline state management

Additional Libraries

  • System.Text.Json - High-performance JSON processing
  • Microsoft.Extensions - Dependency injection and configuration
  • Humanizer - Human-friendly text formatting
  • Blazor Components - Rich UI component library

Development

Code Quality

  • Comprehensive error handling with custom middleware
  • Structured logging with detailed context information
  • Input validation using FluentValidation
  • Clean architecture with separation of concerns

Performance

  • Efficient database queries with Entity Framework
  • Background services for maintenance tasks
  • Optimized component rendering and state management

Deployment

The application can be deployed to various hosting environments:

Development Deployment

cd BlazorCrudDemo.Web
dotnet publish -c Release

Production Deployment Options

  • IIS (Windows): Traditional Windows hosting with process isolation
  • Kestrel (Cross-platform): Lightweight cross-platform deployment
  • Docker containers: Containerized deployment with consistent environments
  • Azure App Service: Cloud hosting with scaling and monitoring
  • Linux hosting: Native Linux deployment with systemd

Docker Support

# Build the Docker image
docker build -t blazorcruddemo -f BlazorCrudDemo.Web/Dockerfile .

# Run the container
docker run -d -p 5120:80 --name blazor-app blazorcruddemo

Environment Configuration

  • Development: Uses appsettings.Development.json with relaxed security
  • Production: Uses appsettings.Production.json with enhanced security settings
  • Connection Strings: Configurable for different database providers
  • Logging: Environment-specific logging levels and outputs

Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with clear, descriptive commit messages
  4. Test your changes thoroughly across different scenarios
  5. Update documentation for any new features or changes
  6. Submit a pull request with a detailed description

Development Guidelines

  • Follow the existing code style and architectural patterns
  • Add comprehensive tests for new functionality
  • Update documentation for any new features
  • Ensure all tests pass before submitting
  • Follow security best practices for authentication and data handling

Code Quality Standards

  • Use meaningful variable and method names
  • Add XML documentation to public APIs
  • Handle exceptions gracefully with appropriate logging
  • Follow SOLID principles and clean code practices
  • Implement proper separation of concerns

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

If you encounter any issues or have questions:

  • πŸ“š Documentation: Check the Wiki for detailed guides
  • πŸ› Bug Reports: Report issues on GitHub
  • πŸ’¬ Discussions: Start a Discussion for questions
  • πŸ“§ Email: Contact the maintainers for private inquiries

Built with ❀️ using Blazor and .NET 8

Show your support by starring this repository! ⭐

Share on X Share on LinkedIn

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages