Skip to content

Latest commit

 

History

History
211 lines (164 loc) · 12.5 KB

File metadata and controls

211 lines (164 loc) · 12.5 KB

MyBlog

A hands-on learning project for .NET Aspire orchestration, Blazor Server rendering, and clean architecture.

.NET 10 MIT License xUnit Tests Latest Release

CI/CD Test Suite

CodeCov Coverage Coverage Trend Coverage Gate

Open Issues Closed Issues Open PRs Closed PRs

⚠️ Training Project — This is a learning exercise focused on .NET practices, not a production application.

Overview

MyBlog is a Blazor Server blog application demonstrating modern .NET patterns: Aspire orchestration, CQRS with MediatR, MongoDB persistence, Redis distributed caching, Auth0 authentication, TailwindCSS v4 theming, and comprehensive testing (unit, architecture, integration, bUnit, E2E).

Features

  • Blog Management: Create, edit, delete, publish/unpublish blog posts with category assignment
  • CQRS with MediatR: All blog operations handled by MediatR command/query handlers with FluentValidation pipeline
  • Redis Caching: L1 (in-memory) + L2 (Redis distributed) cache via IBlogPostCacheService abstraction for BlogPosts and UserManagement
  • MongoDB ObjectId Migration: Category IDs now use native MongoDB ObjectId instead of string GUIDs for optimal performance
  • Auth0 Authentication: Secure login with Authorization Code + PKCE flow; Role-Based Authorization (Admin/User policies)
  • Blazor TailwindCSS Theming: Dark/light/system modes, 4 color schemes (Blue, Red, Green, Yellow), localStorage persistence
  • Aspire Orchestration: MongoDB + Redis as Aspire resources with health checks and OpenTelemetry

Technology Stack

  • .NET 10 (SDK 10.0.300) with C# 14
  • .NET Aspire 13.3.5 — Service orchestration, MongoDB + Redis resources, health checks, distributed caching
  • Blazor Server (Interactive Server Rendering) — Dynamic UI with TailwindCSS v4 theming
  • MongoDB with MongoDB.EntityFrameworkCore 10.0.1 — Blog post persistence with ObjectId migration
  • Redis — Distributed caching (L2 cache via IDistributedCache)
  • MediatR 14.1.0 — CQRS pattern (Create/Update/Delete/GetAll/GetById handlers)
  • FluentValidation 12.1.1 — Validation pipeline behavior
  • Auth0 — Authentication + role-based authorization
  • xUnit v3 + FluentAssertions + NSubstitute — Test framework
  • bUnit 2.7.2 — Blazor component testing
  • NetArchTest.Rules — Architecture validation

Project Structure

MyBlog/
├── src/
│   ├── AppHost/              # .NET Aspire orchestration (MongoDB + Redis resources)
│   ├── Domain/               # BlogPost entity, MediatR handlers, validators, IBlogPostCacheService
│   │   ├── Abstractions/     # Result<T>, IBlogPostRepository, IBlogPostCacheService
│   │   ├── Behaviors/        # ValidationBehavior MediatR pipeline
│   │   ├── Entities/         # BlogPost domain entity
│   │   └── Interfaces/       # Repository and cache interfaces
│   ├── ServiceDefaults/      # OpenTelemetry, health checks, Aspire extensions
│   └── Web/                  # Blazor Server application
│       ├── Features/BlogPosts/  # Vertical slice: commands, queries, Blazor pages
│       ├── Infrastructure/Caching/  # BlogPostCacheService (L1+L2 implementation)
│       ├── Components/Theme/ # TailwindCSS theme components
│       ├── Security/         # Auth0 endpoints
│       └── Styles/           # TailwindCSS input.css
├── tests/
│   ├── Unit.Tests/           # Domain entity + handler unit tests
│   ├── Architecture.Tests/   # Layer dependency enforcement
│   ├── Integration.Tests/    # Aspire integration tests
│   ├── AppHost.Tests/        # Aspire AppHost + E2E tests
│   ├── Web.Tests/            # Web layer unit tests
│   ├── Web.Tests.Bunit/      # Blazor component tests (bUnit)
│   └── Web.Tests.Integration/# Web integration tests
├── docs/                     # Documentation + GitHub Pages blog
├── Directory.Build.props     # Centralized build settings
├── Directory.Packages.props  # Centralized NuGet versioning (CPM)
├── global.json               # SDK version lock (.NET 10.0.202)
├── GitVersion.yml            # Semantic versioning config
└── MyBlog.slnx               # Solution file

Getting Started

Prerequisites

  • .NET 10 SDKDownload
  • Node.js 18+ — for TailwindCSS compilation
  • Auth0 account — required for authentication (free tier). See AUTH0_SETUP.md
  • MongoDB — MongoDB Atlas or local instance (or let Aspire provision via Docker)
  • Redis — Redis instance (or let Aspire provision via Docker)

Setup

  1. Clone the repository

    git clone https://github.com/mpaulosky/MyBlog.git
    cd MyBlog
  2. Restore .NET dependencies

    dotnet restore
  3. Install npm dependencies (for TailwindCSS)

    cd src/Web && npm ci && cd ../..
  4. Build the solution

    dotnet build
  5. Run tests

    dotnet test
  6. Run the application (via Aspire AppHost)

    cd src/AppHost
    dotnet run

    The Aspire dashboard will be available at the URL shown in the console.

Testing

Multiple test tiers, all passing:

  • Unit.Tests — Domain entity logic and MediatR handler behavior
  • Architecture.Tests — Layer dependency enforcement
  • Integration.Tests — Aspire integration tests
  • AppHost.Tests — .NET Aspire host + E2E tests
  • Web.Tests — Web layer unit tests
  • Web.Tests.Bunit — Blazor component tests (bUnit)
  • Web.Tests.Integration — Web integration tests

Run all tests:

dotnet test

Documentation

Dev Blog

Date Title Tags
2026-05-24 Release: v1.7.0 — MongoDB ObjectId Migration & Cache Hardening release, v1.7.0, mongodb, caching, sprint-20
2026-05-23 Release: v1.6.0 — Markdown Editor and Blog Post Categories release, v1.6.0, blazor, ui, categories, markdown, sprint-19
2026-05-23 Release: v1.5.2 — Markdown Editor and Blog Post Categories release, v1.5.2, blazor, ui, categories, markdown, sprint-19
2026-05-08 Release: v1.5.1 — AppHost MongoDB Dev Commands Refactor release, v1.5.1, aspire, mongodb, sprint-18
2026-05-08 Release: v1.5.0 — MongoDB Resource Refactoring and Aspire Dev Commands release, v1.5.0, aspire, mongodb, devops, sprint-14-18
2026-05-08 Release: v1.4.0 — Board Automation and Test Harness Hardening release, v1.4.0, board-automation, testing, ci-cd, sprints-10-13
2026-04-30 Release: v1.3.0 — Complete xUnit v3 Migration and Code Quality release, v1.3.0, testing, xunit, code-quality, sprints-6-8
2026-04-24 Release: v1.2.0 — Redis Caching and L1/L2 Cache Strategy release, v1.2.0, redis, caching, aspire, sprint-5
2026-04-24 Release: v1.1.0 — Blazor Theme System with TailwindCSS v4 release, v1.1.0, blazor, tailwind, theme, testing, sprint-4
2026-04-20 Release: v1.0.0 — Semantic Versioning and Production Readiness release, semver, ci, devops
2026-04-20 Sprint 3: E2E Testing and CI Hardening e2e, aspire, ci, testing, sprint-3
2026-04-20 Sprint 2: CQRS and MediatR Deep Dive cqrs, mediatr, testing, domain, sprint-2
2026-04-18 MyBlog Project Kickoff: Building with .NET 10 and Clean Architecture aspire, blazor, clean-architecture, sprint-1

📖 View the complete development blog → for full post archives, sprint summaries, and release notes.

Release History

Version Date Highlights
v1.7.0 2026-06-06 MongoDB ObjectId Migration & Cache Hardening — Category ObjectId migration, dual-cache UserManagement, Sprint 20 polish
v1.6.0 2026-05-23 Markdown Editor & Categories — Blog post categories, markdown editing, ObjectId adoption
v1.5.2 2026-05-23 Bug fixes — Category and markdown stability patches
v1.5.1 2026-05-08 MongoDB Dev Commands — AppHost diagnostic commands, resource refinement
v1.5.0 2026-05-08 MongoDB Refactoring — Resource abstractions, Aspire dev commands, infrastructure hardening
v1.4.0 2026-05-08 Board Automation — GitHub project automation, test harness hardening, CI/CD improvements
v1.3.0 2026-04-30 xUnit v3 Migration — Complete test framework upgrade, code quality enhancements
v1.2.0 2026-04-24 Redis & Caching — IBlogPostCacheService L1+L2, handler cache integration
v1.1.0 2026-04-24 Themes & Testing — TailwindCSS v4 themes, test project reorganization, E2E fixes
v1.0.1 2026-04-20 Automatic semver versioning enabled
v1.0.0 2026-04-20 First semantic version release

License

Licensed under the MIT License. See LICENSE file for details.


Status: Training Project | .NET 10 | v1.7.0 | Maintained by: @mpaulosky