App Architecture
How the look is built, from the design tokens up, is on its own page: UI architecture.
The shape of the whole application in one page: what each part owns, which
way the dependencies point, and the rules that keep it that way. The
records under this one in the sidebar explain the individual decisions;
this is the map they hang from. It is also the answer to the promise the
README made when the build started, that a written architecture and style
would exist and be enforced rather than remembered.

A preview. Open the data flow diagram in a new page
to zoom in and follow it. The infrastructure has its own drawing.
In plain words
This page is the map of the whole application: which part owns what, and which way the parts depend on each other. The server code is built in rings (an onion architecture) where every dependency points inward, and a short set of rules keeps it that way, such as working facts out from stable ids instead of storing them.
The result: a developer can tell where a change belongs before writing it, and the organization can swap a piece at its seam, as when the catalogue moved from JSON files to SQLite without one line changing in the inner layers.
The topology, in the document
The two drawings above are pictures. This one is text: it lives in this file,
changes in the same commit as the thing it describes, and shows up in a diff
when the topology moves. That is the whole reason it is here in a format a
reviewer can read as source rather than open in an editor.
Solid lines are what serves a request today. Dotted lines are the deploy path
and the identity path, which are real but not on the request's critical route.
flowchart LR
B["Browser<br/>theyard.stevenstout.biz"]
subgraph edge["Phase 1 edge: Netlify, free tier"]
TLS["TLS termination, Let's Encrypt<br/>rewrite proxy: / with its query to the rendering service, /* to the one web app with X-Yard-Host"]
end
GHCR[("GitHub's registry, ghcr.io<br/>public: theyard and theyard-render")]
subgraph azure["Azure, resource group RG-THEYARD-SS"]
ACI["Web app for containers, APP-THEYARD-ONE-SS: both sites and The Shed<br/>on PLAN-THEYARD-SS, Linux B2, West US 3<br/>2 vCPU and 3.5 GB shared with the rendering service<br/>the store follows the name, or X-Yard-Store"]
RENDER["Web app for containers, the rendering service<br/>on the same plan, its own image: draws every page<br/>for either site, naming its store on every read"]
ACR[("Container Registry<br/>the same tags, kept for the undo")]
MI["Managed identity<br/>id-theyard-ss"]
AI["Application Insights<br/>appi-theyard-ss, 0.1 GB daily cap"]
LAW[("Log Analytics<br/>log-theyard-ss, no daily quota of its own")]
end
subgraph sql["Azure SQL Database, the first site's store, West US 3"]
SQL[("Azure SQL Database<br/>sqldb-theyard-ss-basic, Basic, 5 DTU<br/>catalogue, photo manifest, accounts, bids<br/>and the job hunt's campaign, card and jobhunt schemas")]
end
subgraph cosmos["Azure Cosmos DB, the Cosmos DB site's store, West US 2"]
COSMOS[("Azure Cosmos DB<br/>cosmos-theyard-ss, free tier, no keys<br/>the same four things, as documents")]
end
subgraph box["Inside the container"]
API["ASP.NET Core minimal API, .NET 11"]
SPA["React 19 bundle, served as static files"]
SEED[("data/vehicles.json<br/>200 records, seeds the database on first boot")]
FILE[("JSON seed in memory<br/>until the store attaches; no bids kept")]
end
B -->|HTTPS, session cookie| TLS
TLS -->|a page: HTTPS, under the site's name| RENDER
RENDER -->|the API's page, /api/version and the view's reads, the cookie forwarded| ACI
TLS -->|everything else: HTTPS| ACI
ACI --> API
API --> SPA
API -->|a page per query; the store holds all 100,000| SQL
API -->|the other store, chosen by the name or X-Yard-Store| COSMOS
API -.->|when SQL is unreachable| FILE
MI -.->|db_datareader, db_datawriter| SQL
SEED -.->|first boot only| SQL
GHCR -.->|image pulled on every roll, no credential| ACI
GHCR -.->|its own image, theyard-render, on the same push| RENDER
ACI -.->|token from the plan's identity endpoint| MI
MI -.->|Reader, Monitoring Reader| AI
API -.->|requests, dependencies, exceptions| AI
AI --> LAW
Mermaid source. It renders as a picture on GitHub, and it is kept here as text
on purpose: it lives in this file, so it changes in the same commit as the
topology and shows up in a diff. The drawn version of the same thing, to zoom
in on, is the infrastructure diagram.
Why the renderer is not in the bundle is measured in ADR: Style, enforced.
The database is reached as the managed identity, with no password anywhere in
the connection string, and the schema it maps to is published from
api/TheYard.Database rather than created by the container (ADR: The SQL Server
backend, and ADR: Data first).
The two things that are not on this picture are on it on purpose. Cloudflare
is a staged, dormant zone that cannot take over until the registrar transfer
(ADR: Front Door origin), and Azure Front Door is written in Bicep and
deliberately undeployed because the free trial forbids it (ADR: Deployment
strategy). Drawing either as though it were serving traffic would make this
diagram a wish rather than a map.
The data, as tables
What the database actually holds, which is four tables of this application's own
plus the seven ASP.NET Core Identity brings with it. The authority for this
picture is api/TheYard.Database, and a conformance test holds the Entity
Framework model to it, so this diagram cannot stop being true without
something failing (ADR: Data first, and the database in source control).

A preview. Open the database diagram in a new page
to zoom in and read the column types. It is drawn by
docs/images/erd.mjs
from a table of facts, so a column that changes is a one-line edit rather than a
drawing exercise. There is no PNG copy beside it, unlike the older two drawings:
raw.githubusercontent serves an SVG as an image, so a second file would be one
more thing to keep in step for nothing.
The same thing as text, which is what shows up in a diff:
erDiagram
AspNetUsers ||--o{ Bids : places
AspNetUsers ||--o{ AspNetUserClaims : has
AspNetUsers ||--o{ AspNetUserLogins : has
AspNetUsers ||--o{ AspNetUserTokens : has
AspNetUsers ||--o{ AspNetUserRoles : joins
AspNetRoles ||--o{ AspNetUserRoles : joins
AspNetRoles ||--o{ AspNetRoleClaims : has
Vehicles }o..o{ Photos : "chosen by hash, never stored"
Vehicles ||..o{ Bids : "no constraint, see below"
Vehicles {
nvarchar_64 Id PK "the seed id"
int Seq UK "seed order, clustered"
varchar_17 Vin "ISO 3779"
int Year
nvarchar_64 Make
nvarchar_64 Model
nvarchar_64 Trim
nvarchar_32 BodyStyle
nvarchar_32 ExteriorColor
nvarchar_32 InteriorColor
nvarchar_128 Engine
nvarchar_64 Transmission
nvarchar_16 Drivetrain
int OdometerKm
nvarchar_32 FuelType
decimal_3_1 ConditionGrade
nvarchar_1024 ConditionReport
nvarchar_max DamageNotes "JSON array"
nvarchar_32 TitleStatus
nvarchar_64 Province
nvarchar_64 City
datetime2_0 AuctionStart
int StartingBid
int ReservePrice "null means no reserve"
int BuyNowPrice "null means no buy now"
nvarchar_max Images "JSON array"
nvarchar_128 SellingDealership
nvarchar_32 Lot
int CurrentBid "null until the first bid"
int BidCount
}
Photos {
nvarchar_128 File PK
int Seq UK "manifest order, clustered"
nvarchar_32 Style "the body-style pool"
nvarchar_256 Title "the source title"
}
Bids {
nvarchar_128 UserId PK "FK to AspNetUsers"
nvarchar_64 VehicleId PK "no FK, see below"
int Amount
int BidCount
bit WonBuyNow
bigint AtMs
rowversion RowVersion "concurrency token"
}
AspNetUsers {
nvarchar_128 Id PK
bigint CreatedAtMs "this application's one addition"
nvarchar_256 UserName
nvarchar_256 NormalizedUserName UK
nvarchar_256 Email
nvarchar_256 NormalizedEmail
nvarchar_max PasswordHash
nvarchar_max SecurityStamp
nvarchar_max ConcurrencyStamp
bit EmailConfirmed
bit TwoFactorEnabled
bit LockoutEnabled
datetimeoffset LockoutEnd
int AccessFailedCount
}
AspNetRoles {
nvarchar_128 Id PK
nvarchar_256 Name
nvarchar_256 NormalizedName UK
nvarchar_max ConcurrencyStamp
}
AspNetUserRoles {
nvarchar_128 UserId PK
nvarchar_128 RoleId PK
}
AspNetUserClaims {
int Id PK
nvarchar_128 UserId
nvarchar_max ClaimType
nvarchar_max ClaimValue
}
AspNetRoleClaims {
int Id PK
nvarchar_128 RoleId
nvarchar_max ClaimType
nvarchar_max ClaimValue
}
AspNetUserLogins {
nvarchar_128 LoginProvider PK
nvarchar_128 ProviderKey PK
nvarchar_max ProviderDisplayName
nvarchar_128 UserId
}
AspNetUserTokens {
nvarchar_128 UserId PK
nvarchar_128 LoginProvider PK
nvarchar_128 Name PK
nvarchar_max Value
}
Mermaid uses underscores where SQL uses brackets and parentheses, so
nvarchar_64 is nvarchar(64) and decimal_3_1 is decimal(3,1). The types
themselves are the ones in
api/TheYard.Database.
Two relationships on that diagram are dotted, and both are dotted because the
database does not enforce them.
Vehicles to Bids has no foreign key. The Vehicles table holds the 200-row
seed catalogue, SyntheticVehicleSource expands it in memory to 100,000 by
deriving ids from it, and a visitor bids on the expanded set. A constraint would
reject 99.8 per cent of legitimate bids. It becomes correct the day the expansion
is persisted, and a test asserts its absence so that day is noticed.
Vehicles to Photos has no join table. A vehicle's gallery is chosen at
request time by hashing its id against the pool for its body style, so the
association is computed and never stored. Vehicles.Images holds the dataset's
own image URLs, which are not manifest file names, so there is nothing to point a
foreign key at.
Everything else is a real constraint. Deleting an account cascades to its bids,
its claims, its logins, its tokens and its role memberships.
The dependency direction inside the API, which is the other half of the shape:
flowchart RL
Api["TheYard.Api<br/>host, endpoints, composition"]
Infra["TheYard.Infrastructure<br/>adapters"]
App["TheYard.Application<br/>use cases and ports"]
Domain["TheYard.Domain<br/>rules, pure functions"]
Data["TheYard.Data<br/>records, no logic"]
Cosmos["TheYard.Infrastructure.Cosmos<br/>the document store's adapters"]
Api --> Infra
Api --> Cosmos
Api --> App
Api --> Domain
Api --> Data
Cosmos --> Infra
Cosmos --> App
Infra --> App
Infra --> Domain
Infra --> Data
App --> Domain
App --> Data
Domain --> Data
Every arrow points inward and none points back. TheYard.Data has no
dependencies at all, which is what makes it safe for every other layer to hold
its records. The one arrow between adapters, the Cosmos DB project's reference
to the relational one, exists for the one account entity it shares,
YardUser (ADR: Accounts on a document store). It is a known cost, not a
layer: YardUser is an Identity type, so it cannot move into Application
without Application taking the Identity package, and a test allows that one
type and nothing else (ADR: Onion and SOLID, how this codebase holds them).
One picture in words
A browser asks the API for a page of vehicles. The API owns the data, the
rules and the derived facts; the browser formats what it is given and
counts down clocks. Nothing about an auction is decided twice.
The architecture, four records and the tests that hold them
Four records name the structure, and each is held by a test in both processes, the site and the job hunt's Function. A rule with no test in one process is said in its record, not skipped.
The rule bodies the two suites share live once, under tests/rules/, and both test projects compile them by a link (ADR-075, the addendum of 1.0.4.70).
The layers, and which way they point
The API is an onion: every arrow points inward, and the innermost layer
knows nothing about the ones around it.
The build holds that direction. api/TheYard.Tests/OnionTests.cs reads the
compiled assemblies with NetArchTest and runs ten rules: each ring depends
only on the rings inside it, Domain never reaches the disk, the network or the
clock, Application never reaches the disk or the network, the document store's adapter borrows only the
shared user from the relational one, an endpoint never reaches a store or the service container and reaches the
auction only through Application, the host never queries a database itself,
and services are registered only in Shared/ and the slices' modules. A break fails the gate
and names the type that broke it. The rings, the ten rules and where each
SOLID principle shows are in
ADR-088, Onion and SOLID,
and the rings are drawn on their own page.
What the rings mean, and the principles under them, are two pages of their own:
Onion and Clean Architecture reads the
pattern beside this codebase ring by ring, and
SOLID Principles takes the five one at a time, with
the code each one shows in and the place it stops.
The rings have a second axis. Every feature is one folder with the same name in every ring that has
a part of it, and what two features share sits in Shared/<Concern>/ of that ring (from 1.0.4.46,
ADR-107's addendum of that version; only the types Entity Framework maps stay at the relational
adapter's root), and in the host that folder holds the feature's
endpoints and a Module.cs that registers and maps it:
Features/Accounts, Features/Bids, Features/Blog, Features/Docs, Features/Health, Features/Links,
Features/Vehicles, Features/Visitors and the Admin tab's Features/Admin/Operations, Features/Admin/Plan, Features/Admin/Cloud and, from 1.0.4.82,
Features/Admin/Foreman, whose nightly agent (from the version that records ADR: The Foreman gets a model) runs on
Microsoft Agent Framework in this process over a Foundry deployment, with its port in Application and its adapter in
Infrastructure. What
every feature shares is in Shared/. Program.cs registers the shared parts by name and loops over
the modules, and SliceTests fails the gate when a slice reaches into another. The shape is drawn on
its own page and argued in
ADR-107, The onion cut into vertical slices.
The test for whether a layer is earning its place is whether something can
be swapped at its seam. Three things have been: the 100,000-record scale-up
is a decorator on IVehicleSource and nothing above it changed, the test
suite hands the same services in-memory fakes, and the catalogue moved from
JSON files to SQLite without one line changing in Application or Domain
(ADR: The relational store).
public interface IVehicleSource
{
Task<IReadOnlyList<Vehicle>> LoadAsync(CancellationToken cancellation);
}
public interface IPhotoManifestSource
{
Task<IReadOnlyList<PhotoEntry>> LoadAsync(CancellationToken cancellation);
}
public interface IBidStore
{
Task<IReadOnlyList<StoredBid>> LoadAsync(CancellationToken cancellation);
Task<IReadOnlyList<StoredStanding>> LoadStandingsAsync(CancellationToken cancellation);
Task<StoredStanding?> ReadStandingAsync(string vehicleId, CancellationToken cancellation);
Task<IReadOnlyList<StoredBid>> BidsOnAsync(string vehicleId, CancellationToken cancellation);
Task<bool> TrySaveAsync(string userId, string vehicleId, BidState state, VehicleStanding standing, string? expectedVersion, CancellationToken cancellation);
Task ClearAsync(string userId, CancellationToken cancellation);
}
public interface IVehicleCatalogue
{
int Target { get; }
CatalogueFillPace Pace { get; }
Task<int> FilledAsync(CancellationToken cancellation);
Task FillAsync(IReadOnlyList<CatalogueEntry> batch, CancellationToken cancellation);
Task<SegmentCounts> CountAsync(CatalogueFilter filter, CancellationToken cancellation);
Task<IReadOnlyList<CatalogueEntry>> PageAsync(CatalogueFilter filter, CatalogueOrder order, int skip, int take, CancellationToken cancellation);
Task<IReadOnlyList<CatalogueEntry>> FindAsync(IReadOnlyCollection<string> ids, CancellationToken cancellation);
Task<InventoryFacets> FacetsAsync(CancellationToken cancellation);
}
Live from api/TheYard.Application/Shared/Auction/Ports.cs, region ports, read from this build at 99df7a8.
The rules that keep it that way
Derive, do not store. Auction windows, statuses, galleries and the
100,000 vehicles are all computed from stable ids. Nothing is persisted,
so nothing can drift out of date, and the same id always produces the same
answer. The seed file is never modified.
One authority per rule. A rule lives in TheYard.Domain and nowhere
else. The browser once mirrored the auction math in TypeScript and the two
disagreed twice, across time zones and then on a daylight-saving day. The
derived facts now travel on the wire (auction_starts_at,
auction_ends_at, auction_status, min_next_bid, sold) and the browser
only formats them.
The wire is the contract. snake_case in the dataset, snake_case on the
wire, snake_case in the browser: nothing is renamed in transit. The
envelope is { total, vehicles }; a failure is a ProblemDetails body
(ADR: Error handling). The settings that hold that contract are in
api/TheYard.Api/Shared/Wiring/ApiRegistration.cs (ADR: Program.cs, explained).
Endpoints bind and delegate. A MapGet in a slice under api/TheYard.Api/Features/
validates its parameters and asks Application, one handler per request (ADR-115). If a rule
appears in the host, it is in the wrong place, and OnionTests fails an endpoint that reaches
the auction's parts itself or reaches a store.
The address bar is the application state. Filters, sort, the open
vehicle and the Admin tab are all query parameters, mirrored by
src/app/hooks/useAddressBar.ts and read back by src/lib/inventory.ts. There is no router
and no state library; Back and Forward work because the URL is the truth.
One seam to the API for the inventory. Every fetch for vehicles,
facets and bids is in src/lib/data.ts, with its cache, its debounce and its
abort signal. The seam is per concern rather than one file: accounts fetch
through src/lib/auth.ts, the store list through src/lib/stores.ts, and
the Admin tab, the error boundary, the document viewer and the build stamp
each read their own endpoint directly, because a cache and a debounce built
for the listing would be the wrong tool for a health check. No component
computes an auction fact; that rule is the one that matters, and it holds.
Nothing ships untested. Three suites, one per level: pure rules in
xunit, the browser's logic in Vitest, the real stack in Playwright. The
ship's gate runs all three once per version and nothing reaches the
deploy without them (ADR: The tests, explained).
Where a file lives
The host's root holds Program.cs and nothing else (ADR: The host root holds one file).
- A file one slice uses lives in that slice, under
api/TheYard.Api/Features/<Slice>/, and declares that slice's namespace.
- A file more than one place uses lives under
api/TheYard.Api/Shared/<Concern>/, in the folder named for what it serves, and declares TheYard.Api.Shared.<Concern>.
- The concerns are the rows of the table in ADR-114; a new concern is a new row there first.
- The registrations, the request pipeline and the settings they read are
Shared/Wiring/.
- Neither
Features/ nor Shared/ holds a loose file.
HostLayoutTests fails the build when any of this stops being true, and SliceTests rule 1 says which slice a lonely shared type belongs to.
What is deliberately not here
No durable volume. The stores are outside the container, Azure SQL Database
and Azure Cosmos DB. Until its store attaches, a container serves the JSON
seed held in memory with no bid store, so nothing a visitor does depends on
a disk the roll throws away. SQLite is the store a clone runs on when no
connection string is configured (ADR: The relational store; ADR: A second
store on Cosmos DB, and what it costs).
No password store of its own: accounts are ASP.NET Core Identity with a
signed cookie (ADR: Accounts and per-user bids). No state library, router,
component library or CSS framework. No server-rendered React inside the API:
the pages are drawn by a service beside it that reads the API like any other
client, and the API does not know it exists (ADR: A rendering service beside
the API). Each of those is a decision with a record behind it, not an
oversight; ADR: Deployment strategy and the Hosting page cover the hosting
side of the same question.