Project Introduction
Relevant source files
The following files were used as context for generating this wiki page:
The DDD project is a comprehensive learning initiative focused on mastering Domain-Driven Design (DDD) and Event-Driven Architecture (EDA) patterns using C# .NET 9. The system implements a healthcare appointment scheduling domain, utilizing microservices-oriented bounded contexts including Scheduling, Billing, and Medical Records.
The architecture is built incrementally through distinct phases, progressing from fundamental DDD tactical patterns to advanced distributed systems concepts such as asynchronous messaging with RabbitMQ, CQRS with MediatR, and centralized authentication via Duende IdentityServer.
Sources: claude.md:1-15, claude.md:27-33
Project Architecture and Tech Stack
The project follows a modular monolith/microservices hybrid approach orchestrated by .NET Aspire. It leverages specialized libraries for domain modeling, persistence, and communication.
Core Technology Stack
| Component | Technology |
|---|---|
| Runtime | .NET 9 / C# 12 |
| Orchestration | .NET Aspire |
| ORM | EF Core 9 (SQL Server) |
| Messaging | MassTransit / RabbitMQ / Wolverine |
| CQRS | MediatR |
| Security | Duende IdentityServer 7.4 (OIDC/OAuth2) |
| Frontend | Angular 21 (Signals, Standalone Components) |
Sources: claude.md:144-162, WebApplications/Billing.WebApi/Program.cs:41-57
System Component Overview
The following diagram illustrates the high-level relationship between the primary architectural components and the orchestration layer.
The system uses .NET Aspire to manage service discovery and resource provisioning, such as RabbitMQ containers and database connection strings.
Sources: Aspire.AppHost/AppHost.cs:17-150, claude.md:118-138
Learning Phases and Development Roadmap
The project is structured into eight completed phases that establish the system's capabilities:
- DDD Fundamentals: Implementation of Entities, Value Objects, Aggregates, and Domain Services.
- Persistence: Integration with EF Core, implementing the Repository and Unit of Work patterns.
- CQRS: Separation of read and write models using MediatR.
- Testing: Establishing a two-tier test base using SQLite in-memory for integration tests.
- Event-Driven Architecture: Asynchronous communication between Bounded Contexts using RabbitMQ and MassTransit.
- Integration: Cohesion of microservices via .NET Aspire and Observability.
- Frontend: Development of an Angular application using Signals and zoneless change detection.
- Auth: Security implementation using a BFF (Backend-for-Frontend) pattern with OIDC and cookies.
Sources: claude.md:17-116
Infrastructure and Development Tools
Database and Persistence
The project uses SQL Server as the primary database, with EF Core for ORM. For integration testing, the TestBase<TContext> class provides an isolated environment using SQLite in-memory connections and transaction-based rollbacks to ensure test independence.
Sources: BuildingBlocks/BuildingBlocks.Tests/TestBase.cs:38-75, claude.md:43-55
Messaging Frameworks
Messaging is flexible, allowing developers to choose between MassTransit and Wolverine. The AppHost.cs configures the messaging broker (RabbitMQ or Azure Service Bus) at startup based on configuration parameters.
Docker Management
A custom PowerShell script (ensure-docker.ps1) and MSBuild targets in Directory.Build.targets ensure that Docker Desktop is running before starting the build. This prevents indefinite hangs and provides clear error messages if the RabbitMQ container cannot be initialized.
Sources: scripts/DOCKER_AUTOSTART_FIX.md:7-35
Authentication and Security
The project implements a robust security model using Duende IdentityServer. It utilizes OIDC for authentication and shared Data Protection keys across WebAPIs to allow cookies to be decrypted by multiple services.
Key security features include:
- BFF Pattern: The SPA never sees tokens; it uses secure, HTTP-only cookies.
- CSRF/XSS Protection: Cookies are configured with
HttpOnly,SecurePolicy.Always, andSameSiteMode.Lax. - Role-Based Access: Role validation is enforced via
ICurrentUserabstractions and FluentValidation rules.
Sources: BuildingBlocks/BuildingBlocks.Infrastructure.Auth/AuthExtensions.cs:38-65, claude.md:92-113
Project Structure
The repository is organized into several logical folders:
- BuildingBlocks: Reusable infrastructure, domain, and application logic shared across bounded contexts.
- Core: Domain-specific logic for bounded contexts (Scheduling, Billing).
- WebApplications: API hosts for the various microservices.
- Frontend: Client applications (Angular).
- Aspire.AppHost: The orchestrator project managing service execution and dependencies.
Sources: claude.md:118-138
Conclusion
The DDD project serves as a comprehensive template for modern .NET development. By integrating tactical DDD patterns with a cloud-native orchestration layer like .NET Aspire and a standard-compliant security model, it provides a scalable architecture for healthcare-related enterprise applications.