Building a Content Management Framework
DDD, Feature Tracking, TDD & Source Generation
A comprehensive technical reference for building a Content Management Framework from scratch using Domain-Driven Design, type-safe requirements tracking, test-driven development, and Roslyn source generation. Written for software architects and senior developers working in enterprise environments.
Table of Contents
Part I: Vision
What is a CMF? How does it differ from a CMS? The journey from Diem (PHP, 2010) to a meta-metamodel-driven framework in C# (.NET 10, 2026). Why combining Requirements as Code, TDD, DDD, and source generation produces something greater than the sum of its parts.
Part II: CMF Feature Catalog
The CMF's own requirements expressed using the Requirements DSL notation. Six epics, thirty features, eighty stories, one hundred and fifty tasks -- a complete product backlog as typed C# code. This is the first real-world validation of the DSL design, not self-hosting.
Part III: Meta-Metamodel Foundation (M3)
The four-layer abstraction hierarchy from OMG MOF. MetaConcept, MetaProperty, MetaReference, MetaConstraint, MetaInherits -- five axioms that everything else is built from. How M2 DSLs emerge from M3 primitives. The self-describing fixed point.
Part IV: DDD DSL -- Domain Modeling
AggregateRoot, Entity, ValueObject, Composition, Association, Aggregation. Commands, events, queries, sagas. Aggregate invariants via [Invariant] methods returning Result. Source-generated entities, builders, validators, EF Core mappings, repositories. The largest chapter -- the DDD DSL is the backbone.
Part V: Content DSL -- Parts & Blocks
Content parts as horizontal composition (Routable, Seoable, Taggable). Content blocks as vertical composition (Hero, Testimonial, RichText). StreamFields as composable sequences. Versioning, draft/publish. Inspired by Orchard Core, Wagtail, and Drupal.
Part VI: Admin DSL -- Auto-Generated UI
AdminModule, AdminField, AdminFilter, AdminAction. From a single [AdminModule] attribute, the compiler generates a complete Blazor CRUD interface: paginated lists, forms with validation, batch operations, and a requirement compliance dashboard.
Part VII: Pages DSL -- Dynamic Composition
The page tree: Page, Layout, Zone, WidgetInstance. PageWidget attributes that compile to Blazor WebAssembly components. Dynamic URL routing from materialized paths. The runtime composition layer that content editors control.
Part VIII: Workflow DSL -- Editorial Pipelines
Workflow, Stage, Transition, Gate, RequiresRole. Per-locale tracking with ForEachLocale. Scheduled publishing. Generated state machines with guard conditions. Workflow gates that check requirement compliance before allowing transitions.
Part IX: Requirements DSL -- The Type-Safe Chain
Requirements as abstract records. Acceptance criteria as abstract methods. Specifications as interfaces. The compiler enforces the chain: Requirements --> Specifications --> Implementation --> Tests. [ForRequirement], [Verifies], [TestsFor] with typeof() and nameof(). IDE navigation from test to requirement in one click.
Part X: Roslyn Analyzers & Quality Gates
REQ1xx through REQ4xx: four analyzer families enforcing the chain at compile time. dotnet quality-gates for post-test validation: pass rate, code coverage, duration, flakiness, fuzz testing. .editorconfig severity configuration. The full CI pipeline.
Part XI: The .Design CLI + Interactive TUI
Standard CLI for CI/automation: cmf new, cmf add, cmf generate, cmf validate, cmf report. Interactive TUI with Spectre.Console: cmf design launches a terminal-based modeling session with aggregate designers, feature wizards, workflow builders, and live code preview.
Part XII: End-to-End Walkthrough
Build an e-commerce platform from scratch. Define requirements. Model the domain. Generate code. Add content types. Build the admin. Create pages. Set up workflows. Write tests. Run quality gates. Deploy. Every step shown in code.
How to Read This Document
Architects should start with Part I (Vision) and Part III (Meta-Metamodel), then read Part IV (DDD DSL) and Part IX (Requirements DSL) for the core design.
Backend developers should focus on Part IV (DDD DSL), Part V (Content DSL), Part VIII (Workflow DSL), and Part XII (Walkthrough) for practical implementation.
Frontend developers should read Part VI (Admin DSL), Part VII (Pages DSL), and Part XII (Walkthrough) for the Blazor generation pipeline.
QA engineers should start with Part IX (Requirements DSL), Part X (Analyzers & Quality Gates), and Part II (Feature Catalog) to understand the testing chain.
Technical leads should read Part II (Feature Catalog) and Part XI (CLI) to understand the developer experience and project planning.
Prerequisites
- C# 12+ / .NET 10
- Roslyn source generators
- EF Core 10
- Blazor (Server + WebAssembly)
- Familiarity with DDD concepts (aggregates, bounded contexts, CQRS)
- Familiarity with OMG MOF / metamodeling is helpful but not required (Part III explains it from scratch)
Conventions
Throughout this document:
- Bold type names like Order or UserRolesFeature are C# types
[Attribute]notation indicates C# attributes that form the DSL surface// Generated:comments show source-generated code (not hand-written)- Mermaid diagrams are rendered inline
- All code targets .NET 10 / C# 12 with nullable reference types enabled
- Nothing in this document is implemented yet -- this is a design specification