SourceGuild is a high-performance, domain-driven e-learning backend engineered with ASP.NET Core. It provides secure, scalable RESTful APIs for course authoring, hierarchical section/lesson curricula, polymorphic multimedia content delivery, role-based student enrollments, progress tracking, and reviews.
The architecture has been refactored and modernized to strictly enforce Domain-Driven Design (DDD) Aggregate Boundaries, Vertical Slice Feature Handlers, the Result Pattern (eliminating exception-based flow control), zero-allocation static compile-time mappings, and containerized persistence using Microsoft SQL Server 2022.
The solution adopts modern enterprise standards, utilizing .slnx solution format, Clean Architecture layer boundaries, and Feature-driven organization:
SourceGuild/
├── src/
│ ├── SourceGuild.Domain/ # Pure Domain layer: Rich Aggregate Roots, Value Objects, Enums, Result Pattern
│ ├── SourceGuild.Application/ # Vertical Slices / Feature Handlers, DTOs, FluentValidation, Static Mappings
│ ├── SourceGuild.Infrastructure/ # EF Core DbContext, Split-Query Repositories, Identity JWT, Data Seeders
│ └── SourceGuild.API/ # ASP.NET Core Controllers, RFC 7807 ProblemDetails, OpenAPI/Swagger Docs
├── tests/
│ └── SourceGuild.Tests/ # Automated Test Suite: 20 Unit & Feature Tests (xUnit + Moq + FluentAssertions)
├── docs/ # Docs-as-Code: PlantUML Domain Models, Logical ERD, C4 Diagrams, Architecture Roadmap
└── scripts/ # DevOps automation: setup-secrets.sh, run-migrations.sh
-
Rich Aggregate Roots vs. Anemic Domain:
-
Courseacts as the strict Aggregate Root protecting all consistency boundaries for its child entities (Section,Lesson,ContentBlock). - Mutating child entities, re-indexing orders, or altering lifecycle states (
Draft$\to$ Published) is strictly encapsulated within the aggregate root, eliminating orphan records.
-
-
Result Pattern & RFC 7807 ProblemDetails:
- Replaced performance-heavy runtime exceptions (
ServiceExceptions) with an explicit, zero-dependencyResult<T>and domainErrorrecord pattern. -
ResultExtensionsdynamically maps domain errors (Error.NotFound,Error.Validation,Error.Conflict) to standard HTTP ProblemDetails (404, 400, 409, 401, 403).
- Replaced performance-heavy runtime exceptions (
-
Zero-Allocation Compile-Time Mappings:
- Completely eliminated
AutoMapperand its reflection overhead in favor of static extension methods (MappingExtensions.ToDto()) utilizing C# pattern matching for polymorphic content blocks (TextContent,VideoContent), ensuring full Native AOT readiness.
- Completely eliminated
-
EF Core Query Optimization:
- Configured
QuerySplittingBehavior.SplitQueryto eliminate Cartesian explosions when querying deep aggregate graphs (Course$\to$ Sections$\to$ Lessons$\to$ ContentBlocks).
- Configured
-
Security & Secrets Governance:
- Zero hardcoded credentials. All connection strings, SA passwords, and JWT private keys are resolved dynamically via
dotnet user-secretsin development and parameterized.envfiles for Docker.
- Zero hardcoded credentials. All connection strings, SA passwords, and JWT private keys are resolved dynamically via
| Concern | Technology / Pattern |
|---|---|
| Language & Runtime | C# 14 / .NET 10.0 SDK |
| Architectural Style | Domain-Driven Design (DDD) + Vertical Slice Architecture |
| Web API & Routing | ASP.NET Core Controllers with OpenAPI / Swagger XML Documentation |
| Authentication & IAM | ASP.NET Core Identity + JWT Bearer Tokens (Role-Based Access Control) |
| ORM & Data Access | Entity Framework Core |
| Database Engine | Microsoft SQL Server 2022 (Linux Container via Docker Compose) |
| Validation & Error Handling | FluentValidation + Functional Result Pattern (Result<T>, Error) |
| Testing Frameworks | xUnit, Moq 4.20, FluentAssertions |
| Documentation & Tooling | PlantUML, Docker Compose, Shell Automation |
- .NET 10.0 SDK
- Docker Engine & Docker Compose
git clone https://github.com/Novav20/source-guild-backend.git
cd source-guild-backend# Copy the environment template
cp .env.example .env
# Start SQL Server 2022 container on host port 1434 (configured in .env)
docker compose up -d# Automated secrets configuration script
./scripts/setup-secrets.sh# Run automated interactive migration script (Option 1)
./scripts/run-migrations.shThe database will be created and automatically populated with realistic test data (Instructors, Students, Categories, Courses with full curricula, and Reviews).
dotnet run --project src/SourceGuild.APINavigate to http://localhost:5037/swagger to explore and execute the interactive OpenAPI specification.
Run the complete test suite (Domain Aggregate Invariants & Application Feature Handlers):
dotnet testComprehensive technical diagrams and evolution roadmaps are available in the docs/ folder:
- Domain Model Class Diagram (DDD)
- Logical Entity-Relationship Diagram (ERD)
- Course Enrollment Sequence Diagram
- Content Blocks Architectural Roadmap
This project is open-source and available under the MIT License.