Production Readiness Review for TaskBoard
On this page
How to use this lesson
You've built TaskBoard: a shell and two micro-frontends, a BFF with OpenID Connect sign-in and Redis sessions, and a tRPC API split by team, with live updates across instances. This lesson is a production readiness review. Go through each section with your own build, and fix anything that isn't true yet.
Security
- The browser never holds an access or refresh token.
document.cookieis empty for the session, and no response body contains a token. - The session cookie is
__Host-Http-sidwithHttpOnly,Secure,Path=/, noDomain, andSameSite=LaxorStrict. Clearing it uses the same attributes. - Sign-in uses the authorization code flow with PKCE,
stateandnonce.returnToaccepts only local paths, with no//or backslash. - Tokens in Redis are encrypted with a key from the secret store, shared by every instance.
- Every
/trpc,/bffand logout request requiresx-csrf: 1, except event-streamGETs for read-only subscriptions. No CORS is enabled for other origins. - The error formatter masks
INTERNAL_SERVER_ERRORmessages in production, andonErrorlogs the real cause. - Every procedure that needs a user uses
protectedProcedure. Data ownership is enforced by the services, with the user's token.
Types and contracts
- Micro-frontends import only
type AppRouterfrom@taskboard/bff/router. A runtime import fails the build. - The root
tsc -p .runs on every pull request and covers every package. - The contract package defines
Mount,MountProps, the events,CSRF_HEADERandsessionLink, and changes need approval from every team. - Procedure changes follow expand and contract, and the pipeline deploys the BFF before the micro-frontends that depend on it.
Team independence
- Each team owns a micro-frontend and a tRPC sub-router, mapped in CODEOWNERS.
- A team can ship a new field end to end in one pull request without another team's approval, unless the contract changes.
- Each micro-frontend has its own build, its own import map entry and its own rollback.
- No micro-frontend reaches into another's DOM, state or cache. They communicate through typed events and the BFF.
Failure handling
- A micro-frontend that fails to load shows a message in its own area. The shell and the other micro-frontends keep working.
- A downstream timeout becomes
GATEWAY_TIMEOUTand a downstream error becomesBAD_GATEWAY, with a sensible message in the UI. - An expired session produces one "please sign in again" flow from any micro-frontend, through
sessionLinkand the shell. - Subscriptions reconnect after drops, and the list refetches so missed events don't matter.
- Losing Redis is planned for: it's highly available, and the team knows that sign-in and sessions stop without it.
Operations
- Request ids flow from the browser through the BFF to every service, and appear in logs.
- Each team has dashboards and alerts for its own procedures, downstream calls and micro-frontend errors.
- Each piece has a rehearsed rollback.
- Router tests, contract tests and a small end-to-end suite run in CI. The end-to-end suite includes sign-in, a live update across two BFF instances and session expiry.
Questions a reviewer will ask
Be ready to answer these about your build:
- *What happens if the tasks API is down for ten minutes?* The tasks area shows a clear error, the account area and the shell keep working, and alerts reach the tasks backend team.
- *What happens if someone steals a session cookie?* It works only until the idle or absolute timeout, can't be read by page scripts in the first place, and support can end every session for the user.
- *What happens during a BFF deploy?* A rolling update replaces instances one by one. Sessions live in Redis, so users stay signed in. SSE connections drop and reconnect, and lists refetch.
- *Can the tasks team break the account team?* Not at compile time, because the root type check runs on every pull request. At run time, only through the shared BFF host, which the platform team owns and changes rarely.
Where to go from here
TaskBoard is a foundation. Natural next steps, each covered in other courses on this site:
- Observability: OpenTelemetry tracing across the BFF and services, with dashboards per team.
- Security hardening: a Content Security Policy for the shell page, and subresource integrity for the import map's files.
- More teams: when a team's release pace outgrows the shared BFF, give it its own BFF behind a router on the same origin, sharing only the session store.
- Server rendering: render the first view of a micro-frontend on the server, for faster first load on public pages.
Check yourself
The end-to-end journey through real sign-in, which covered the shell, both micro-frontends, the BFF's sign-in, tRPC, CSRF, Redis pub/sub across two instances and session expiry.
A rolling update replaces instances one at a time while the others keep serving. Sessions live in Redis, so users stay signed in whichever instance they reach. Open SSE connections to a replaced instance drop and reconnect to another, and lists refetch, so users at most notice a moment's delay in live updates.
When its release pace or scale needs it to deploy the BFF independently. Then it runs behind a router on the same origin and shares only the session store.
Sign-in and every authenticated call fail, because sessions and tokens live in Redis, and live updates stop because pub/sub runs through it. That's why Redis must be highly available, with a replica and automatic failover, and why the team should know this failure mode before launch.
The CSRF rule, because a mistake silently exposes every mutation, and sharing secrets across instances, because a mismatch breaks every session the moment a second instance starts. Both are cheap to test and expensive to get wrong.