Module 10 ended with a list of missing pieces and an application that still lives on your machine. This module finishes it and ships it. Before writing a single line, it's worth stopping: after ten modules there are many decisions scattered across fifty lessons, and whoever joins the project tomorrow, which could be you six months from now, isn't going to read them.
In this lesson you'll do the work that separates a set of features that run from a product that can be operated: an honest inventory of what exists, the scope of version 1.0, the requirements you can't see on screen turned into numbers, the architecture map, a table that says how each route is served and who can see it, the decisions in writing, and an ordered work list. They're short documents. Their value is that they can be checked.
- Where we are
The inventory is taken by looking at the code, not at your memory. These commands list what the application exposes:
find app -name 'page.tsx' | sort # Screens
find app -name 'route.ts' | sort # Endpoints
grep -rlE "^'use server'" actions | sort # Action files
ls drizzle/*.sql # Schema history
npm run typecheck && npm run lint && npm test && npm run test:db && npm run e2e:allThe last line is part of the inventory: a project that doesn't pass its own checks isn't "almost done", it's in an unknown state. This is the result, grouped by what matters to the people who use it:
| Area | Done | Missing |
|---|---|---|
| Public portal | Home page, guide with filters and search, event pages, venues, quick view, favorites, calendar | What happens when an event fills up |
| Bookings | Book, cancel, confirmation email | Waitlist; making sure no mandatory notification gets lost |
| Dashboard | Create, edit drafts, poster, submit for review, overview | Correcting and canceling what's published, attendees, occupancy per event |
| Administration | Review and publish | Nothing for 1.0 |
| Accounts | Sign-up, sign-in, external provider, sessions | Password recovery (outlined in 08-02) |
| Integrations | v1 API, venues webhook, weather forecast |
Nothing |
| Quality | Tests at three levels, budget, metrics, logs, health checks | Running on their own with every change |
| Operations | Local PostgreSQL container | Everything: environment, deployment, backups, rollback |
The right-hand column is the module. Two rows are solved with code (11-02 and 11-03), the operations row with deployments (11-04 and 11-05), and the quality row with automation (11-06).
1.1. Known debt
An inventory that only lists what's missing is misleading. There are also things done with an accepted limit, and they must be written down so that nobody discovers them as surprises:
| Limit | Where it was decided | Consequence |
|---|---|---|
CSP with 'unsafe-inline' |
08-05 | An injected script would run; the defense is not being able to inject it |
| An event can be edited while it's in review | 08-04, exercise 3 | A text nobody read could get published |
| Uploaded images aren't re-encoded | 06-05 | They could keep the photo's metadata |
The regular audit log is written in after |
07-04 | A row may get lost |
| Roles are changed in the database | 08-04, exercise 2 | There's no screen; whoever administers the server does it |
| The test data dates are in 2028 | 10-04 | The tests will expire that year |
| English only, on every route | 09-05 | Spanish lives on a branch, not in the product |
- The scope of 1.0
The temptation at the end of a project is to add. The useful question is the opposite one: what's the minimum we can ship without being embarrassed or doing harm? Each candidate is classified with a single sentence that starts with "if it's not there…":
| Candidate | If it's not in 1.0… | Decision |
|---|---|---|
| Canceling a published event and notifying people | Someone will turn up at a locked door | In |
| Correcting a published event | A typo in the description means touching the database | In |
| Attendee list | The organizer doesn't know who to let in | In |
| Waitlist | Canceled spots are lost, and with them public capacity | In |
| Password recovery | Every forgotten password is an email to the administrators | In (exercise 2 of 11-02) |
| Favorites in the account | They're stored in the browser, as they are now | Later |
| Spanish | The city loses visitors, not residents | Later |
| Reminder the day before | More empty seats | Later, on top of the outbox from 11-02 |
| Changing the date or venue of something published | It's canceled and a new one is created | Later, and carefully |
| Payments | The product is free | Out |
The last two rows show two kinds of "no". Payments aren't part of the product. Changing the date could be, but doing it properly means asking the people who booked whether it still suits them, and doing it badly is worse than not having it.
- Non-functional requirements
"Fast", "secure" and "available" aren't requirements: nobody can say whether they're met. A real one has a number, a way of measuring it and a consequence when it isn't reached.
| Requirement | Target | How it's measured | If it fails |
|---|---|---|---|
| Loading | LCP ≤ 2.5 s, INP ≤ 200 ms and CLS ≤ 0.1 at the 75th percentile | metric, per route (10-01) |
It's fixed before adding anything |
| JavaScript | Whatever is set in scripts/budget.mjs (10-02) |
On every change (11-06) | It isn't merged |
| Booking | Under 1 s at the 95th percentile, with 50 people at once on the same event | The bookings.create trace (10-05) |
Alert |
| Overbooking | Zero | Concurrency tests and a database constraint | Incident |
| Freshness | Whoever changes something sees it at once; everyone else, on their next load | Publishing test (10-04) | The tags are reviewed |
| Mandatory notifications | 100% of cancellations, in under 30 minutes | Pending rows in the outbox (11-02) | Alert |
| Availability | 99.5% per month (about three and a half hours of margin) | External check every minute | The plan is reviewed |
| Data loss | 24 hours at most (RPO) | Date of the last restored backup | Alert |
| Recovery | Under 4 hours (RTO) | A drill every quarter | The runbook is fixed |
| Accessibility | WCAG 2.2, level AA | axe on every change, manual review per release | It's a defect, not an improvement |
| Critical patches | In production within 24 hours | Date of the advisory and of the deployment | The process is reviewed (11-06) |
| Personal data | Logs 30 days; audit log 12 months | Deletion task | Ask compliance |
Some numbers deserve an explanation:
- 99.5% and not 99.99%. The second one is four minutes a month and demands several machines in different places, on-call rotations and a lot of money. A municipal events guide doesn't need it. Choosing a high number without the budget is choosing to miss it.
- RPO and RTO are business decisions. "How much can we lose" and "how long can it take" are questions for whoever pays. The backup frequency and the type of server, in 11-05, follow from the answer.
- Zero overbooking isn't achieved by measuring, but with a lock and a
CHECK. It's in the table so that nobody negotiates it. - The retention periods are a technical proposal. They're set by whoever is in charge of data protection, and often by a law as well.
- The map
flowchart TB
V["Browser"] --> P["NGINX or platform<br/>TLS, limits, static files"]
I["Integrators"] -->|"API v1"| P
R["Venue system"] -->|"signed webhook"| P
P --> X["proxy.ts<br/>id, 404, private area"]
X --> A["app/<br/>pages, actions, endpoints"]
A --> D["lib/data/<br/>permissions and queries"]
A --> C["Cache<br/>use cache + tags"]
C --> D
D --> B[("PostgreSQL")]
A --> F["lib/storage/<br/>posters"]
T["Scheduler"] -->|"POST with key"| A
A -->|"outbox"| M["Email"]
D --> W["Weather API"]
A -.-> O["Logs, traces, errors"]
A map is only useful if rules come out of it. AgendaViva's fit in six lines, and all of them can be checked with one of the commands from 08-06:
- Pages compose;
lib/data/decides. No file inapp/,components/oractions/importslib/db/. - Every data function finds out who's asking and puts ownership in the
where. - Queries are cached, not components, and with the lifetime written down. Tags come from
lib/tags.ts. - Notify after committing and before redirecting, through
lib/revalidation.ts. - Whatever comes from outside is validated at the boundary: forms,
bindarguments, JSON bodies, responses from other APIs and the environment. - What we owe someone is written in the transaction; the rest can go in
after.
The sixth one is new. It appears because 1.0 includes notifications that can't be lost, and you'll build it in the next lesson.
4.1. External dependencies
| Service | If it goes down… | It's covered in |
|---|---|---|
| PostgreSQL | The shells are still served; the holes fail, and so does everything that writes | 10-05, exercise 1 |
| Nothing gets blocked; mandatory notifications wait in the outbox | 07-03 and 11-02 | |
| Weather API | The event page says so in one line | 04-01 |
| Identity provider | People sign in with a password | 08-03 |
| Poster storage | Cards without an image; uploads aren't possible | 06-05 |
| Error service | Errors stay in the log | 10-05 |
It's a short table and very useful at night. If a row said "the application goes down", there'd be work to do before going live.
- Route, rendering, cache and permission
This table brings modules 2, 5 and 8 together. Each route answers four questions; a blank cell is a decision not yet made:
| Route | Served as | Data and cache | Holes in the request | Who |
|---|---|---|---|---|
/ |
◐ shell | Upcoming: listings, tags events and venues |
District, account, notice | Everyone |
/events |
◐ shell | Filters cached up to page 5; search uncached | Filters and results | Everyone |
/events/[slug] |
◐, 50 at build time | Event page: hours, event:slug and venue:slug |
Spots, booking and waitlist | Everyone; booking, signed in |
/venues, /venues/[slug] |
◐, all at build time | days and listings |
Account, notice | Everyone |
/sign-in, /sign-up/** |
◐ | None | The form | Signed out |
/my-bookings, /account |
◐ title | None | Everything personal | Signed in |
/dashboard, /dashboard/events/** |
◐ skeleton | None | Everything | organizer, their own |
/dashboard/events/[id]/attendees.csv |
ƒ | no-store |
organizer, their own |
|
/admin |
◐ skeleton | None | Everything | admin |
/api/v1/filters |
○ | days, at build time |
Everyone | |
/api/v1/**, availability, suggestions |
ƒ | Depends on the function | Everyone | |
/api/webhooks/**, /api/tasks/** |
ƒ | None | Signature or key | |
/api/health, /api/health/ready |
ƒ | no-store |
Infrastructure | |
/images/** |
ƒ | One year in the browser, immutable | Whoever has the address | |
sitemap.xml |
○ with revalidation | hours, events |
Everyone |
It's checked in three ways. The symbols, with the npm run build table; if a row says ƒ where you expected ◐, someone has added instant = false or one boundary too many. The cache, with the instant() tests (10-04). And the permissions, with e2e/permissions.spec.ts: every row whose last column doesn't say "Everyone" must have a case there.
5.1. Who invalidates what
The other half of caching is invalidation. The table from 05-04 grows with what's missing:
| Operation | Notification |
|---|---|
| Booking, canceling, spot assigned from the waitlist | refresh and notifyIfAvailabilityChanges |
| Joining or leaving the waitlist | refresh: nothing public changes |
| Publishing (admin) | invalidateEvent(slug) |
| Correcting or canceling something published, changing its poster | invalidateEvent(slug) |
| Capacity change from outside | notifyCapacityChange, with 'max' |
Notice that the metadata, the social image, the calendar and the sitemap aren't on the list. They read the same cached functions, with the same tags, so they renew themselves (09-03 and 09-04). That's the payoff of not having cached components.
- Decisions in writing
An architecture decision record (ADR) is a dated page that says what was decided, why, and what we accepted losing. It isn't edited: if it changes, you write another one that supersedes the first. It's kept with the code, in docs/decisions/, because it changes with it and is reviewed with it.
docs/decisions/0009-outbox.md
Title Outbox for mandatory notifications
Status Accepted (partly supersedes 0006, email in after)
Date 2026-12-02
Context When an event is canceled, everyone who booked has to be
notified. after doesn't retry or survive a restart. The
mail provider limits how many messages can be sent per second.
Decision The notification is inserted as a row in the same transaction
that cancels. A task takes batches with SKIP LOCKED, sends them
with an idempotency key and marks them. after triggers it right
away; the scheduler repeats it every five minutes.
Alternatives Managed queue: one more piece to operate and pay for, for few
messages.
Sending inside the action: it blocks it and doesn't retry.
Consequences + No notification is lost as long as the database is fine.
- A message may be sent twice; the provider's key prevents it.
- Rows that don't go out have to be monitored.The part people are most grateful for is Alternatives. Without it, the next person will propose the managed queue thinking nobody considered it. These are the decisions in force; the first six were made during the course and the rest belong to this module:
| No. | Decision | What was accepted |
|---|---|---|
| 1 | Cache Components from the start (module 5) | Database at build time |
| 2 | Sessions in PostgreSQL rather than JWT (08-01) | One query per signed-in request |
| 3 | Spots by polling, not SSE (07-01) | Up to 20 seconds of delay |
| 4 | CSP without a nonce (08-05) | 'unsafe-inline' in exchange for the shell |
| 5 | A single language in 1.0 (09-05) | The languages branch will drift further away |
| 6 | Confirmation email in after (07-04) |
One may get lost |
| 7 | Waitlist with automatic assignment (11-02) | Someone may receive a spot they no longer want |
| 8 | Canceling keeps the bookings (11-03) | Rows that no longer take up useful capacity |
| 9 | Outbox for mandatory notifications (11-02) | A table and a task to monitor |
| 10 | Only the summary, description, capacity and poster of published events can be corrected (11-03) | Changing the date means canceling |
| 11 | One instance in 1.0; the second one, with a shared cache (11-05) | A few seconds of downtime when deploying |
Decision 10 leaves a gap: a published description can be changed without the administrators seeing it. It's accepted because it's audited and because the alternative, sending the event back to review, would take it off the site over a typo. Writing it down like this lets someone from the content team say no.
- The work list
Prioritizing isn't scoring from one to ten. It's done with three questions, in this order: can it do harm if it's missing? Does it block another task? How much does it cost to find out whether it works? They give you a sequence in which the risky things come early, while there's still time:
| Order | Work | Why it's here | Done when… |
|---|---|---|---|
| 1 | Deploy what exists to a staging environment | The risk is in what's never been done | It responds over HTTPS and passes the checklist from 11-06 |
| 2 | Pipeline with the current tests | Everything else rests on it | A broken change can't be merged |
| 3 | Outbox | The waitlist and cancellation need it | With email down, nothing gets lost |
| 4 | Waitlist | Uses the outbox | Concurrency test passing |
| 5 | Correcting, canceling and attendees | Uses the outbox and the waitlist | Extended permission matrix |
| 6 | Password recovery | Independent; essential for opening sign-up | Test showing it ends sessions |
| 7 | Backups and a rehearsed restore | Before there's data to lose | It's been restored on another machine |
| 8 | Legal texts and privacy policy | Someone else writes them: ask for them now | Reviewed by compliance |
| 9 | External security review | With everything above done | No serious findings open |
| 10 | Go live |
In the lessons we'll follow a different order, from the inside out, because it's easier to explain: first the code and then the deployment. In a real project, the first deployment happens on day one, even if there's only a home page. Deploying is a risk that grows the longer it's put off, because the day it's done for the first time every assumption is discovered at once.
Rows 8 and 9 aren't programming, and they're the ones that most often delay a launch. A guide that stores names, email addresses and attendance at events handles personal data; having it on record that someone attended a talk on a particular subject can be, depending on the subject, especially sensitive. Whoever handles compliance must see it before there's real data.
7.1. What "done" means
The last column avoids arguments, but there are shared conditions that aren't repeated in every row. AgendaViva's definition of "done" is a list that fits in the change template:
- It passes types, ESLint rules, tests and the budget.
- It has its row in the matrix from section 5 and in the entry points table from 08-06.
- If it writes, it has a test for someone else's permission and, if it competes for something, a concurrency test.
- If it changes the schema, the previous version of the code works with the new schema (11-04).
- If it adds an environment variable, it's in
.env.exampleand in the schema. - If it makes a debatable decision, there's an ADR.
- It can be used with the keyboard and understood without color.
Common Mistakes and Tips
- Taking inventory from memory. What gets forgotten is usually what isn't protected.
- Requirements without a number, or with a number nobody measures.
- Copying a big company's targets. Every extra nine of availability multiplies the cost.
- Drawing boxes without rules. A diagram from which nothing forbidden follows is decoration.
- Considering the cache documented without saying who invalidates it.
- ADRs without alternatives, or rewritten to make it look as if it was always known.
- Prioritizing by appetite. The fun stuff first, deployment last.
- Leaving the legal side for the last week.
- Growing the scope because "while we're at it".
- Planning as if the plan were going to come true. It's reviewed after finishing each row.
Exercises
Exercise 1: extending the matrix
11-03 will add the /dashboard/events/[id] page, with the occupancy, the attendee list and the cancel button. Write its complete row, say which symbol you expect in npm run build and why, which permission tests it requires, and what would change if someone proposed caching the attendee list for one minute.
Solution
Row: /dashboard/events/[id] | ◐ skeleton | none | everything | organizer, their own.
You'd expect ◐: it hangs from dashboard/events/loading.tsx, which is the boundary it streams under, and the dashboard's menu and bar are in the shell. It has no generateStaticParams, because there's nothing to prerender per event.
Tests: signed out, a redirect to /sign-in?returnTo=…; visitor and administrator, "not found"; another organizer with a valid identifier, "not found" and, looking at the HTML, not a single attendee name. The page shows third-party data, so the integration test must check that listAttendees for someone else's event returns null.
Caching the list would require passing the organizer's identifier as an argument to an internal, non-exported function (08-04), because the cache is shared. Even then, names would be stored in an unencrypted cache with its own lifetime, which you'd have to explain to compliance, and you'd see a list from a minute ago at the door of the event, just when it matters most that it's accurate. The query uses an index and takes milliseconds: there's no problem to solve.
Exercise 2: writing a decision
Someone proposes storing favorites in the account so they show up on every device. Write the ADR deciding not to do it in 1.0, with context, alternatives, consequences and the condition that would reopen it. Mention what effect it would have on the home page cache.
Solution
Title Favorites in the browser during 1.0
Status Accepted
Context FavoriteButton stores them in localStorage (03-02). It works
without an account and without a server. Someone who uses
two devices has two lists.
Decision They stay in the browser.
Alternatives a) Only in the account: loses people who don't sign up, who
are the majority.
b) In both places, merging on sign-in: conflicts have to be
resolved, and someone has to decide what happens on
signing out of a shared computer.
Consequences + The cards stay inside the shell: the star is drawn in the
browser and doesn't depend on the session.
+ We don't store what each person is interested in.
- They're lost when the browser data is cleared.
Reopen if More than 10% of accounts sign in from several devices, or
if the interest-based newsletter enters the plan.The important part is the first consequence. If the state came from the database, every card would have a hole that depends on the request, or the list would be loaded once in the browser with SWR. The second approach would keep the shell; it's worth noting it down for whoever reopens the decision. And the condition is written with a number, so that it doesn't depend on who insists the most.
Exercise 3: putting numbers on it
Turn these three client sentences into testable requirements: "it has to hold up on the day festival tickets go on sale", "nothing must be lost" and "everyone has to be able to use it". For each one, say what you'd ask first and what raising the number costs.
Solution
- Festival day. Ask: how many people, over how long, what's acceptable if it's exceeded. Requirement: "500 people open the event page in the first minute and 200 book in the following five; the 95th percentile for booking doesn't exceed 2 s and there's no overbooking". It's measured with a load test in the staging environment. The event page holds up thanks to the shell; the bottleneck is the lock on one row, which queues the bookings. At a few milliseconds per transaction there's plenty of room. If it were fifty times more, the design would have to change, for example with a waiting room, and that's another budget.
- Nothing must be lost. Ask: nothing since when? With a daily backup you can lose 24 hours. With continuous archiving of the PostgreSQL log, a few minutes. Requirement: "RPO of 24 h for everything". If the answer is "not a single booking", you need continuous archiving or a managed service with point-in-time recovery, which costs more and has to be operated.
- Everyone. Requirement: "WCAG 2.2 AA on every public page and on the dashboard, checked with axe on every change and with a manual review, using a keyboard and a screen reader, before each release". Asking for AAA everywhere isn't realistic, and the standard itself doesn't recommend it; what does make sense is testing with people, which is cheap and teaches more than any tool.
Conclusion
A project is finished by knowing what exists, what's missing and what we've accepted losing. The inventory comes from the code; requirements carry a number, a measure and a consequence; the map boils down to rules a command can check; and the matrix says, route by route, how it's served, what's cached, who invalidates it and who can see it. Decisions are dated along with their alternatives, and the work list starts with whatever would do the most harm if it were missing.
Time to build. The first piece runs across the whole application, from the table to the email: what happens when an event fills up and someone cancels. You'll build it in Building the Public Portal.
