feat: implement strangler-fig-demo Session 1 (backend + smoke script)

Builds the four-seam, three-write-path reference demo backend: case-framework
(seam D stand-in), legacy-backend/frontend (SQL Server, seams A/B/C targets),
and new-backend (Domain/Application/Infrastructure.*/Api implementing the
source resolver, take/release-ownership, write-through translator, and owned
assessment flow), wired together via docker-compose with a plain placeholder
frontend standing in for the Angular portal until Session 2.

All 11 Architecture.Tests pass and scripts/smoke.sh passes end-to-end against
a fresh `docker compose up`, covering acceptance criteria 1-3 and 7-22.

Fixes two real domain bugs found only once the stack ran for real: the BSN
eleven-proof checksum trivially passes all-zero digits, and the adoption
mapper silently treated a partial legacy address as absent instead of failing
loudly. Also fixes several environment-specific integration issues (rootless
Podman/SELinux bind-mount permissions, a buildah NuGet layer-caching bug,
SqlClient's invariant-globalization incompatibility, and an nginx path-prefix
mismatch for the legacy frontend).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-07-31 07:57:26 +02:00
co-authored by Claude Sonnet 5
parent 09b27173a7
commit a6a1abbe9c
129 changed files with 6379 additions and 1 deletions
@@ -0,0 +1,186 @@
using CaseFramework.Api;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<CaseDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("CaseFramework")));
var app = builder.Build();
// Self-provision schema against an empty Postgres database on first boot.
using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<CaseDbContext>();
await dbContext.Database.EnsureCreatedAsync();
}
app.MapPost("/cases", async (CreateCaseRequest request, CaseDbContext db) =>
{
var now = DateTimeOffset.UtcNow;
var caseEntity = new CaseEntity
{
Id = Guid.NewGuid(),
CaseTypeCode = request.CaseTypeCode,
ExternalReference = request.ExternalReference,
ProcessStatus = ProcessStatus.InBehandeling,
Participants = request.Participants?.ToList() ?? new List<string>(),
};
caseEntity.TimelineEntries.Add(new TimelineEntryEntity
{
Id = Guid.NewGuid(),
CaseId = caseEntity.Id,
At = now,
Kind = TimelineKind.CaseCreated,
Description = $"Case created with type '{caseEntity.CaseTypeCode}'.",
});
db.Cases.Add(caseEntity);
await db.SaveChangesAsync();
return Results.Ok(new CreateCaseResponse(caseEntity.Id, caseEntity.ProcessStatus));
});
app.MapGet("/cases/{id:guid}", async (Guid id, CaseDbContext db) =>
{
var caseEntity = await db.Cases.AsNoTracking().FirstOrDefaultAsync(c => c.Id == id);
if (caseEntity is null)
{
return Results.NotFound();
}
return Results.Ok(new CaseResponse(
caseEntity.Id,
caseEntity.CaseTypeCode,
caseEntity.ExternalReference,
caseEntity.ProcessStatus,
caseEntity.Participants));
});
app.MapGet("/cases/{id:guid}/timeline", async (Guid id, CaseDbContext db) =>
{
var caseExists = await db.Cases.AnyAsync(c => c.Id == id);
if (!caseExists)
{
return Results.NotFound();
}
var entries = await db.TimelineEntries
.AsNoTracking()
.Where(t => t.CaseId == id)
.OrderBy(t => t.At)
.Select(t => new TimelineEntryResponse(t.At, t.Kind, t.Description))
.ToListAsync();
return Results.Ok(new TimelineResponse(entries));
});
app.MapPost("/cases/{id:guid}/tasks", async (Guid id, CreateTaskRequest request, CaseDbContext db) =>
{
var caseEntity = await db.Cases.FirstOrDefaultAsync(c => c.Id == id);
if (caseEntity is null)
{
return Results.NotFound();
}
var task = new CaseTaskEntity
{
Id = Guid.NewGuid(),
CaseId = id,
Code = request.Code,
Description = request.Description,
IsOpen = true,
};
db.Tasks.Add(task);
db.TimelineEntries.Add(new TimelineEntryEntity
{
Id = Guid.NewGuid(),
CaseId = id,
At = DateTimeOffset.UtcNow,
Kind = TimelineKind.TaskOpened,
Description = $"Task '{task.Code}' opened: {task.Description}",
});
await db.SaveChangesAsync();
return Results.Ok(new CreateTaskResponse(task.Id, task.IsOpen));
});
app.MapPost("/cases/{id:guid}/tasks/{taskId:guid}/complete", async (Guid id, Guid taskId, CaseDbContext db) =>
{
var caseExists = await db.Cases.AnyAsync(c => c.Id == id);
if (!caseExists)
{
return Results.NotFound();
}
var task = await db.Tasks.FirstOrDefaultAsync(t => t.Id == taskId && t.CaseId == id);
if (task is null)
{
return Results.NotFound();
}
task.IsOpen = false;
db.TimelineEntries.Add(new TimelineEntryEntity
{
Id = Guid.NewGuid(),
CaseId = id,
At = DateTimeOffset.UtcNow,
Kind = TimelineKind.TaskCompleted,
Description = $"Task '{task.Code}' completed.",
});
await db.SaveChangesAsync();
return Results.NoContent();
});
app.MapPost("/cases/{id:guid}/closure-request", async (Guid id, CaseDbContext db) =>
{
var caseEntity = await db.Cases.FirstOrDefaultAsync(c => c.Id == id);
if (caseEntity is null)
{
return Results.NotFound();
}
var hasOpenTasks = await db.Tasks.AnyAsync(t => t.CaseId == id && t.IsOpen);
if (hasOpenTasks)
{
return Results.Conflict();
}
caseEntity.ProcessStatus = ProcessStatus.Afgesloten;
db.TimelineEntries.Add(new TimelineEntryEntity
{
Id = Guid.NewGuid(),
CaseId = id,
At = DateTimeOffset.UtcNow,
Kind = TimelineKind.CaseClosed,
Description = "Case closed.",
});
await db.SaveChangesAsync();
return Results.NoContent();
});
app.Run();
internal record CreateCaseRequest(string CaseTypeCode, string ExternalReference, List<string>? Participants);
internal record CreateCaseResponse(Guid Id, string ProcessStatus);
internal record CaseResponse(
Guid Id,
string CaseTypeCode,
string ExternalReference,
string ProcessStatus,
List<string> Participants);
internal record CreateTaskRequest(string Code, string Description);
internal record CreateTaskResponse(Guid TaskId, bool Open);
internal record TimelineEntryResponse(DateTimeOffset At, string Kind, string Description);
internal record TimelineResponse(List<TimelineEntryResponse> Entries);