Start here
This page is for a developer who has just been handed this repository and has an hour. It says what to run, what to read, where a change goes and what the gate will ask of it. Everything here is true of the build you are reading it in, because it is served from inside the running app.
In plain words
This page gets a developer new to this code running in two commands and reading in the right order. It also says where each kind of change goes and what the tests that run before every release (the gate) ask of it.
Why it matters: a developer can make a first change within the hour without asking anyone where it goes, and the organization can hand this repository to a new hire with no walkthrough.
Run it
npm install
npm start # the .NET API and the React app together; opens the browser
That is the whole setup. There is no database to install: with no connection string the API writes to a SQLite file in your temp folder and deletes it on shutdown, and the catalogue is read from JSON files in data/, so a fresh clone serves 100,000 vehicles on the first run.
Three more commands, one for each suite the ship's gate runs (the gate adds a store filter and runs xUnit once per store):
npm test # Vitest, the presentation logic
npm run test:api # xUnit on SQLite; the eight live Cosmos DB tests run on the build machine
npx playwright test # the browser suite, which starts both servers itself
The shape, in one minute
The back end is an onion and its dependencies point inward only. TheYard.Data holds records with no behaviour; TheYard.Domain holds the rules; TheYard.Application holds the use cases and the ports they read through; TheYard.Infrastructure and TheYard.Infrastructure.Cosmos implement those ports over Azure SQL Database, SQLite and Azure Cosmos DB; TheYard.Api is the host, with its handlers in Endpoints/ and the composition root in Composition/. OnionTests fails the gate when a dependency points outward (ADR-088, Onion and SOLID). One process serves both stores and The Shed: the name a request arrives on picks the store, theyard for Azure SQL Database and theyard-cosmos for Azure Cosmos DB, an X-Yard-Store header overrides it, and theshed reaches The Shed's own application inside the same process. Hosting, the section "How a request gets answered", follows one request from the address bar to the code that answers it.
The front end keeps the same discipline: components use hooks use lib, and src/lib imports nothing from React, which is what lets the arithmetic be tested without a browser.
Beside the two, render/ is the rendering service: a small Node program that draws any page a visitor can link to, with its data in the HTML, by reading the API like any other client. It is the front end's own code drawn somewhere else, with about 300 lines of its own, and the API does not know it exists (ADR-096, A rendering service beside the API). npm start runs without it; the browser draws every page then, as it did before the service.
The five rules that will bite you first
- Derive, do not store. Auction windows come from the item id by hash, status from the window and the clock. Nothing schedule-related is persisted.
- The server owns every derived fact, and the clock. Never re-implement auction maths in TypeScript. An earlier version did it on both sides and drifted on a daylight-saving change.
- The wire is snake_case and matches the dataset exactly. No mapping layer.
- Empty is valid, null is the error. A collection is never null.
- Money is whole dollars as
int; every instant is milliseconds since the epoch as long, UTC.
Where a change goes
- A rule about bidding goes in
TheYard.Domain/Shared/Auction/BidRules.cs and nowhere else.
- An endpoint is a route in its slice under
api/TheYard.Api/Features/ (ADR: The onion cut into vertical slices), a call to its one handler in TheYard.Application (a query or a command, ADR-115), and a result. No business logic in TheYard.Api.
- Presentation arithmetic goes in
src/lib with a test beside it; a component reads it.
- Anything a page needs read before it is drawn on the server goes in
render/loaders.ts, and nothing the server draws may differ from the browser's first draw; src/app/drawServer.test.ts draws every view with no browser, and tests/e2e/drawn.spec.ts takes each one over in Chrome and fails on a hydration error.
- A colour goes in
src/styles/colors.css, a space or a size in sizes.css, a font size or weight in typography.css, a shadow, blur or opacity in effects.css. A raw hex in a component fails the style test.
- A decision that someone could reasonably disagree with goes in
docs/decisions/ADR-*.md, as a record with what was considered and what it cost. The Decision Records section of this site is that folder.
The loaders, read from this build, because they are the one file on that list a new developer has not met before: one read per view, all at once, under one deadline, and a read that misses it is left to the browser.
export async function loadFirst(
search: string,
cookie: string | null,
apiOrigin: string,
deadlineMs: number,
read: typeof fetch = fetch,
store: string | null = null
): Promise<FirstLoad> {
const signal = AbortSignal.timeout(deadlineMs);
const get = readerFor(apiOrigin, cookie, read, store);
const first = readFirstAddress(search);
const listingQuery = vehicleQueryParams(first.filters, first.sort).toString();
const needsListing = first.inventory || first.vehicleId !== null;
const doc = first.docKey ? DOCS[first.docKey] : null;
const landing =
!needsListing &&
!doc &&
!first.admin &&
!first.account &&
!first.blog &&
!first.review &&
!first.recommendations &&
!first.about;
const blogFirst = async (): Promise<FirstLoad['blog']> => {
const postOf = (slug: string) =>
inTime(get<BlogPost & { body?: string }>(fetchedFor(slug), signal));
const named = first.blogPost ? postOf(first.blogPost) : null;
const list = await inTime(get<BlogList>(listPath(filterFromSearch(search)), signal));
const lead = list?.cards[0]?.slug ?? null;
const post = named ? await named : lead ? await postOf(lead) : null;
if (post) delete post.body;
return { list, post };
};
const [
account,
build,
page,
facets,
vehicle,
markdown,
pulse,
recommendations,
tests,
blog,
author,
lot,
] = await Promise.all([
cookie ? inTime(get<AccountWire>('/api/auth/me', signal)) : Promise.resolve(null),
inTime(get<{ version: string; commit: string }>('/api/version', signal)),
needsListing
? inTime(get<VehiclePage>(`/api/vehicles${listingQuery ? `?${listingQuery}` : ''}`, signal))
: Promise.resolve(null),
needsListing ? inTime(get<InventoryFacets>('/api/facets', signal)) : Promise.resolve(null),
first.vehicleId
? inTime(get<Vehicle>(`/api/vehicles/${encodeURIComponent(first.vehicleId)}`, signal))
: Promise.resolve(null),
doc ? inTime(get<string>(doc.url, signal)) : Promise.resolve(null),
landing || first.review ? inTime(get<unknown>(PULSE_URL, signal)) : Promise.resolve(null),
first.recommendations || first.review || first.about
? inTime(get<unknown>(RECOMMENDATIONS_URL, signal))
: Promise.resolve(null),
landing || first.review || first.about
? inTime(get<unknown>(TESTS_SUMMARY_URL, signal))
: Promise.resolve(null),
first.blog
? blogFirst()
: first.about
? inTime(get<BlogList>(listPath(filterFromSearch('')), signal)).then((list) =>
list ? { list, post: null } : undefined
)
: Promise.resolve(undefined),
first.about ? inTime(get<string>(DOCS.author.url, signal)) : Promise.resolve(null),
first.review ? inTime(get<unknown>(LOT_URL, signal)) : Promise.resolve(null),
]);
const signedIn: Account = account ? toAccount(account) : SIGNED_OUT;
return {
search,
nowMs: Date.now(),
account: signedIn,
build: build ? { version: String(build.version), commit: String(build.commit) } : null,
listing: page && facets ? { page, facets } : null,
vehicle,
doc: first.docKey && markdown ? await renderedDoc(first.docKey, markdown) : null,
pulse,
recommendations,
...(landing || first.review || first.about ? { tests } : {}),
...(first.review ? { lot } : {}),
...(blog ? { blog } : {}),
...(first.about ? { author: author ? await authorLaidOut(author) : null } : {}),
};
}
async function authorLaidOut(markdown: string): Promise<FirstLoad['author']> {
const { authorParts } = await import('../src/lib/author');
return authorParts(await renderDocument(markdown));
}
async function renderedDoc(key: string, markdown: string): Promise<FirstLoad['doc']> {
const rendered = await renderDocument(markdown);
return {
key,
html: layoutDocument(
rendered,
DOCS[key as keyof typeof DOCS]?.title,
DOCS[key as keyof typeof DOCS]?.wide,
DOCS[key as keyof typeof DOCS]?.cards
),
};
}
Live from render/loaders.ts, region loaders, read from this build at 99df7a8.
What the gate asks
Every version runs one gate before anything rolls: Prettier, oxlint, TypeScript, the SQL project, Vitest, xUnit on SQLite, the live Cosmos DB tests, xUnit on Cosmos DB, the browser suite on both stores, and The Shed's own xUnit and Node tests. A build warning is red. A number quoted in a document is read back against the build, so a stale count in prose fails the suite rather than surviving in the page. The evidence strip on the landing page is those counts, read from the file the gate wrote.
Reading order for the rest of the hour
- Project README, for what the thing is and how it is put together.
- ADR: The rules a change has to pass, which lists each rule beside the test that enforces it.
- App Architecture and Projects, for the onion and the ten projects.
- Hosting and What is watched, for how a request reaches the code and what watches it.
- Built with AI, for how this repository was actually written, and what was checked by hand.
- Any decision record whose title sounds like the change you are about to make.
If a document and the code disagree, the code is right and the document is a bug. Fix it in the same commit.