Files
soroush.asadi 36fe158b43 Scaffold the Before-M1 repo skeleton
Stand up the modular-monolith skeleton per docs/V1_BUILD_PLAN.md: one .NET 10
solution with web + worker hosts sharing seven interface-bounded module projects,
PostgreSQL 17 + pgvector via EF Core 10, a React 19 + Vite SPA built into wwwroot,
and Docker Compose for one-command local dev. Skeleton only — no feature code.

Architecture
- One project per module (OrgBoard, Identity, Skills, Assembler, Governance,
  Memory, Integrations); each is its own assembly so non-public types (entities,
  DbContext) are invisible across modules at compile time.
- TeamUp.Bootstrap is the only library that references all modules; both hosts
  reference only Bootstrap. SharedKernel/Infrastructure never reference modules.
- IModule seam: Register(...) runs in both hosts; MapEndpoints(...) only in web.
- PlatformDbContext owns the pgvector extension + the seven module schemas
  (InitialPlatform migration); MigrationRunner applies it then any module context.
- One image, two roles selected by RUN_MODE at the Docker entrypoint.

Verified
- dotnet build green (nullable + warnings-as-errors).
- ArchitectureTests 8/8 — reflection-based boundary rules (no module -> module,
  -> Infrastructure, -> Bootstrap, or -> host references).
- IntegrationTests 10/10 — Testcontainers boots the host against real pgvector:
  migration applies, vector extension + 7 schemas exist, /health 200, every
  /api/<module>/ping 200, /openapi/v1.json served.
- client builds clean (Vite 6 — pinned for Node 22.3.0; Vite 8 needs Node >=22.12).

Packages and base images route through the Nexus mirror (mirror.soroushasadi.com),
reachable from Iran when nuget.org / Docker Hub / MCR are not. CI is intentionally
deferred to a later session.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 06:41:28 +03:30

83 lines
2.8 KiB
C#

using Xunit;
namespace TeamUp.ArchitectureTests;
/// <summary>
/// Encodes the non-negotiable "no cross-module table access" discipline as build-time rules.
/// The <c>internal</c>-per-assembly design is the hard wall (another module's entities/DbContext
/// aren't even visible); these reference checks guard the gate the compiler can't: a module
/// adding a project reference to another module, or to shared Infrastructure/Bootstrap/hosts.
/// </summary>
public sealed class ModuleBoundaryTests
{
[Fact]
public void Modules_do_not_reference_each_other()
{
foreach (var module in ArchitectureFixture.ModuleAssemblies)
{
var references = module.ReferencedAssemblyNames();
foreach (var other in ArchitectureFixture.ModuleAssemblies)
{
if (ReferenceEquals(module, other))
{
continue;
}
var otherName = other.GetName().Name!;
Assert.False(
references.Contains(otherName),
$"{module.GetName().Name} must not reference module {otherName} — collaborate via abstractions in DI.");
}
}
}
[Fact]
public void Modules_do_not_reference_infrastructure_bootstrap_or_hosts()
{
string[] forbidden = ["TeamUp.Infrastructure", "TeamUp.Bootstrap", "TeamUp.Web", "TeamUp.Worker"];
foreach (var module in ArchitectureFixture.ModuleAssemblies)
{
var references = module.ReferencedAssemblyNames();
foreach (var name in forbidden)
{
Assert.False(
references.Contains(name),
$"{module.GetName().Name} must not reference {name} — only SharedKernel is allowed.");
}
}
}
[Fact]
public void Every_module_references_sharedkernel()
{
// Sanity: each module genuinely sits on the kernel (uses IModule / ModulePing).
foreach (var module in ArchitectureFixture.ModuleAssemblies)
{
Assert.Contains("TeamUp.SharedKernel", module.ReferencedAssemblyNames());
}
}
[Fact]
public void SharedKernel_references_no_teamup_projects()
{
var teamUpReferences = ArchitectureFixture.SharedKernel.ReferencedAssemblyNames()
.Where(name => name.StartsWith("TeamUp.", StringComparison.Ordinal));
Assert.Empty(teamUpReferences);
}
[Fact]
public void Infrastructure_references_only_sharedkernel_among_teamup_projects()
{
var teamUpReferences = ArchitectureFixture.Infrastructure.ReferencedAssemblyNames()
.Where(name => name.StartsWith("TeamUp.", StringComparison.Ordinal))
.OrderBy(name => name, StringComparer.Ordinal)
.ToArray();
Assert.Equal(["TeamUp.SharedKernel"], teamUpReferences);
}
}