Enforcing Module and SQL Schema Boundaries in CI
Catch illegal cross-module references, public schema leaks, and cross-schema Dapper SQL queries in 5 seconds with 49 .NET architecture tests.
A modular monolith stays modular only if broken boundaries fail the build automatically. Orbit.ArchitectureTests runs 49 deterministic checks in under two seconds—verifying Clean Architecture layer dependencies, .csproj references, EF Core snake_case schema metadata, and raw Dapper SQL queries across all five modules.
Run the 49 boundary and schema guardrails
Execute the fast inner-loop verification script (or target Orbit.ArchitectureTests directly):
./scripts/verify.sh --fast --skip-web
# or on Windows PowerShell:
./scripts/verify.ps1 -Fast -SkipWeb
Four layers of automated protection
- Cross-Module Project & Namespace Isolation (
ModuleIsolationTests): No module may reference another module’sDomain,Application,Presentation, orInfrastructureassemblies—only*.IntegrationEventsandCatalog.PublicApiare permitted seams. Even unused illegal<ProjectReference>entries in.csprojfiles fail immediately. - Clean Architecture Inward Dependency Rules:
Domainhas zero infrastructure dependencies (EntityFrameworkCore,Dapper,AspNetCore);Applicationdepends only onDomainand contracts;EndpointsimplementIEndpointinsidePresentation. - EF Core Metadata & Outbox/Inbox Ownership (
SchemaPerModuleTests): Every module’sDbContextmust map 100% of its entities—includingoutbox_messages,outbox_message_consumers,inbox_messages, andinbox_message_consumers—to its exclusive lowercasesnake_caseschema (users,catalog,inventory,orders,shipments). - Dapper Raw SQL Schema Scanner: Scans every C# source file under
src/Modules/<Module>/for SQL clauses (FROM,JOIN,INTO,UPDATE) and fails if any query touchespublicor a foreign module’s schema.
Summary
- Check both
.csprojproject graphs and compiled types so unused illegal references never slip intomain. - Inspect EF Core
IModelmetadata in unit tests to guaranteesnake_casenaming and Outbox/Inbox tables in every module schema. - Scan raw Dapper SQL statements per module so shared PostgreSQL connection strings cannot bypass module boundaries.
Verified C# source & test evidence
Frequently asked questions
Why aren't C# assembly reference checks enough to protect a modular monolith?
A module with zero project references to Orders can still execute raw Dapper SQL like SELECT * FROM orders.orders over a shared connection string. Orbit scans both compiled assemblies and SQL strings across every module.
What does Orbit verify on every EF Core DbContext?
SchemaPerModuleTests instantiates all five DbContexts and asserts a unique non-public default schema, snake_case table and column names, and schema-owned Outbox and Inbox tables.