Full-stack Rebuild
ALFRD
I inherited a Fastify backend mid-language-migration and rebuilt the parts that mattered: multi-tenant org management and real-time streaming, while keeping the frontend it powered running the whole time.
- TypeScript
- Next.js
- Fastify
- PostgreSQL
- Server-Sent Events
The problem
ALFRD's backend was mid-migration when I stepped in: an existing Fastify codebase with the scars of a language/framework transition, expected to support multiple organizations and real-time data feeds it wasn't originally designed for.
Constraints
- The migration was already in progress, so the fix had to work inside existing conventions and half-finished patterns, not a clean rewrite.
- Multi-tenant org management had to be bulletproof: one organization's data or session state leaking into another was not an acceptable failure mode.
- Clients needed live updates, and polling wasn't good enough, but the codebase had no existing streaming infrastructure to build on.
Architecture decisions
- 01Rebuilt multi-tenant org management around explicit tenant scoping at the data-access layer, rather than trusting every route handler to remember to filter by org.
- 02Added Server-Sent Events for live updates instead of reaching for a heavier WebSocket layer. SSE fit the one-way, server-to-client update pattern the product actually needed.
- 03Debugged my way through someone else's half-finished migration by instrumenting the boring way first: logs and reproduction, not guesswork, before touching a line of the tenant-scoping logic.
What I'd do differently
In hindsight, I'd have pushed harder up front to finish stabilizing the migration before layering multi-tenancy on top of it. Some early bugs traced back to code that was in an in-between state.