// real-time web app
TeamFlow
A real-time, keyboard-first agile workspace on a single Postgres database.
TeamFlow is a planning workspace for software teams: a board, a list, a calendar and sprint planning over the same tasks, with live updates, presence and descriptions written together character by character. Version 2 rewrites my first NestJS API as a Bun monorepo: a contract-first API that also serves REST and OpenAPI, a transactional outbox feeding WebSockets, one PostgreSQL database that also runs the job queue, and an Astro site with Starlight docs. The original API, which ranked first in its backend cohort, is kept at v1.0.0.
- year
- 2026
- type
- real-time web app
- group
- platforms and backends
- status
- v2 complete; runs locally, not hosted by decision
- tests
- 489
//in plain words
TeamFlow is a planning board for a software team, like a lighter Jira. When one person moves a card or edits a task, everyone looking at the same board sees it within a second, and two people can write the same description at once without overwriting each other. Everything works from the keyboard, and the whole product runs on a single database.
for small product teams, and engineers who want to see real-time sync done carefully
the problem
//01the problem
Most task boards are fine for one person and quietly wrong for five. Two people drag the same card, one save overwrites another, and a refresh is the only way to learn what changed. I wanted a board where concurrent work converges by design, and where every change can be explained after the fact.
how it works
//02how it works
- 01
One contract for every caller
Every procedure is declared once in an oRPC contract with Zod schemas, including the errors it can return. The web app calls it with inferred types through TanStack Query, and the same contract serves a REST API under /api/v1, an OpenAPI document and a Scalar reference, with personal access tokens that can be read-only and expire.
- 02
A request, layer by layer
Hono middleware adds a request id, structured logs and secure headers. Better Auth resolves the session or token, oRPC middleware builds the actor, the active organization and a tenant scope, the procedure validates input, a service authorizes against the loaded resource, and only the repository touches tables.
- 03
Changes that cannot get lost
Each mutation writes the change, its activity row and its outbox event in one transaction. A worker relays the outbox through LISTEN/NOTIFY to every API node's WebSocket gateway, so a restart drops nothing, and a client only applies an update whose version is newer than the one it holds. A stale write is a conflict, never a silent overwrite.
- 04
Writing together
Task descriptions are Yjs documents edited in Tiptap, with each person's caret labelled by name. The API hosts the Yjs provider on the same socket server, persists merged state with debounced writes and projects it to plain text for full-text search.
- 05
Order without renumbering
Board order is a fractional index, so a move writes one row and the client can compute the same key before the server answers. A random suffix keeps two people inserting into the same gap apart, and a nightly job re-keys any column whose keys have grown long, under a per-column advisory lock that moves share.
- 06
Metrics replayed, not counted
Burndown, scope change, cumulative flow, velocity and cycle time are pure functions over a sprint's append-only activity, in a domain package with no I/O. Nothing drifts, because nothing is a running total.
- 07
One database does the rest
pg-boss runs email, daily or weekly digests and maintenance in the same Postgres, presence is shared between API nodes over NOTIFY, and search is Postgres full-text with trigram matching. The only other stateful service is S3-compatible storage for attachments.
- 08
Tenancy by construction
Every tenant-owned table carries the organization, repositories only accept a scope bound to one, foreign keys between tenant tables are composite so a row cannot point across workspaces, and a test walks the schema to make sure no table escapes the isolation suite.
- 09
A monorepo with one-way dependencies
Four apps (api, worker, web, site) over eight packages: contract, db, domain, auth, realtime, email, ui and shared configs. Apps depend on packages, the domain depends on nothing but Zod, and the web app can never import the database.
- 10
Built for hands on the keyboard
React Aria components throughout, drag and drop that works by keyboard and screen reader, a ⌘K palette, shortcuts for every view, light and dark themes, and a layout that folds down to a phone.
- 11
Documented where people look
An Astro landing page, Starlight docs with guides and the architecture, a generated API reference, fourteen decision records, and a README whose screenshots and demo are produced from the seeded stack by Playwright.
screens
//03screens
13 captured from the running product

01The board, with a task openCards move by pointer, keyboard or screen reader, and the panel beside them is the same task everyone else sees, live. 
02The listVirtualized, sorted by priority and filtered by person, label and status; the result can be saved as a private or shared view. 
03The calendarTasks by due date. Drag a card to another day, or into the tray to clear its date. 
04Sprint planningThe active sprint above the backlog, with work dragged between them by mouse or keyboard. 
05A sprint reportBurndown, scope change, cumulative flow, velocity and cycle time, all replayed from the activity log rather than stored as totals. 
06The command paletteOne search across tasks, projects, actions and what was said in comments, with typo tolerance. 
07The inboxMentions, comments and assignments, written in the same transaction as the change that caused them and pushed as live toasts. 
08The audit logWho changed what in the workspace, including the membership and invitation changes the auth library makes on its own. 
09On a phoneThe sidebar folds into a drawer, the board scrolls sideways and a task opens full screen. 
10The board in the dark themeA palette chosen step by step for dark, not the light one inverted. 
11The landing pageAn Astro page with near-zero JavaScript and a small board you can drive from the keyboard while a teammate's card moves on its own. 
12The docsStarlight: getting started, a guide for every view, the architecture with tenancy and real-time explained, roles and configuration. 
13The API referenceGenerated from the same contract the web app calls, so it cannot drift: every operation with its schema, its errors and a request to copy.
measured
//04measured
- 431
- unit and integration tests
- bun test across eight packages, api tests against real postgres, including lock-order tests, counted on 30 oct 2026
- 58
- browser tests
- playwright journeys against a fresh, seeded stack: two people on one board, guests, failures, phone layouts
- 53
- rest operations
- from the openapi document the contract generates, served at /api/v1
- 14
- architecture decisions
- written as adrs before or with the code they govern
decisions
//05decisions
what was chosen, and what it cost
- 01
chose one PostgreSQL for data, jobs and fan-out
over Redis with a separate queue
pg-boss and LISTEN/NOTIFY carry this load easily and leave one thing to run and back up. Patchgrid uses Redis and BullMQ, so between them the two projects show both sides of that choice.
- 02
chose a transactional outbox
over publishing events after the commit
An event written in the same transaction as its change can be late but never lost or invented. The cost is a relay process and a table to prune.
- 03
chose a contract-first API with oRPC
over hand-written routes and a separate schema
One declaration gives the web app its types, third parties their REST endpoints and everyone the OpenAPI document. The contract has to be designed before the handler, which is the point.
- 04
chose tenancy enforced in the application
over row level security in the database
Patchgrid already puts the boundary in Postgres. Here a scope every repository must take, composite foreign keys through the organization and a schema-walking test carry it, and the cost is that the discipline lives in review and tests.
- 05
chose fractional ranks for order
over integer positions
A move writes one row and never renumbers its neighbours, which keeps optimistic updates simple. Keys can grow under repeated inserts into one gap, so a rebalance job exists, and it needed a lock shared with moves to stay correct.
- 06
chose Yjs for descriptions
over last write wins on a text field
Two people typing in the same paragraph merge instead of overwriting each other. The document lives as binary state with a plain-text projection, so search still works.
- 07
chose notifications written in the causing transaction
over a job that creates them later
A comment is never saved without the notifications it causes, or the other way round. Only email, which can wait and retry, is left to a job.
- 08
chose a Vite single-page app
over a server-rendered framework
Everything is behind sign-in and live over a socket, so server rendering buys little. The public pages that do need indexing are a separate Astro site with Starlight docs.
try it
//06try it
//clone it and start the services
bun 1.4 or later and docker; postgres, s3-compatible storage and mailpit
git clone https://github.com/KhaledSaeed18/team-flow.git && cd team-flow && bun install && cp .env.example .env && bun run infra:upbun 1.4 or later and docker; postgres, s3-compatible storage and mailpit
//migrate, seed and run
sign in at localhost:5173 as demo@teamflow.dev with teamflow-demo
bun run db:migrate && bun run db:seed && bun run devsign in at localhost:5173 as demo@teamflow.dev with teamflow-demo
highlights
//07highlights
- Live board updates and presence over WebSockets, fed by a transactional outbox
- Descriptions written together with Yjs and named carets
- Contract-first API: typed RPC for the app, REST, OpenAPI and a generated reference for everyone else
- Sprint reports replayed from an append-only activity log
- Postgres for data, jobs, fan-out and search; no Redis
- Accessible drag and drop, a command palette and shortcuts everywhere
- Astro site, Starlight docs and fourteen architecture decision records
- 489 tests, unit and integration on real Postgres plus Playwright journeys
built with
- Bun
- Hono
- oRPC
- Drizzle
- PostgreSQL
- Better Auth
- pg-boss
- WebSockets
- Yjs
- React
- TanStack
- React Aria
- Astro
- Playwright
- Turborepo
on githubteam-flow
- stars
- 14
- forks
- 1
- license
- MIT
- language
- TypeScript
- latest tag
- v2.0.8 oct 30, 2026
- last push
- dec 1, 2026
printings
//08printings
7 entries
First commit
The NestJS API, started in a 96-hour backend program where it ranked first in the cohort.
v1 complete
78 documented endpoints, notifications over Server-Sent Events and email, and 119 commits merged through pull requests.
v1.0.0 kept, v2 specified
The API tagged as v1.0.0. A vision, an architecture, a roadmap of ten milestones and the first decisions were written before the monorepo.
v2.0.0
All ten milestones released: workspaces, projects and workflows, the web app, real-time, planning and reports, collaboration, shared descriptions, search, the public API and the docs site.
v2.0.1 to v2.0.4
Fixes from a three-way bug review, full-width layouts with a layout guard, and one brand across the app, docs, email and README.
v2.0.5
Rank rebalancing, the last deferred ordering job; a drawer layout for phones; and a recorded demo of two people on one board.
v2.0.7 and v2.0.8
Two full review rounds and a hands-on QA pass: deadlocks, read-only archives, auth hardening and failure states fixed, each with a test that reproduces it. 2.0.8 refreshed every screenshot to the current app.
questions
//09questions
- How do live updates reach everyone?
- A change and its event are committed together. A worker relays new events through Postgres LISTEN/NOTIFY to every API node, which pushes them over WebSockets to people subscribed to that project. Clients patch their cache only when the version moves forward, so a late event never undoes a newer one.
- What happens when two people edit the same task?
- Fields carry a version, so the second save of a stale copy is refused as a conflict; the board refreshes and says why. Descriptions merge character by character instead, and two cards dropped into the same gap get distinct positions.
- How is the code organised?
- A Bun and Turborepo monorepo: api, worker, web and site apps over contract, db, domain, auth, realtime, email and ui packages. Each API feature goes contract, repository, service, router and integration test, and dependencies only point from apps to packages.
- How is it tested?
- Unit and integration tests with bun test, the integration ones against real Postgres: each file gets a fresh database cloned from a migrated template in milliseconds. Playwright runs journeys against a seeded stack, including two people on one board and layout guards at desktop and phone sizes, and CI runs all of it on every pull request.
- Is there documentation?
- Yes, in three places: Starlight docs with guides and the architecture, a generated API reference served by the API, and a docs folder with the vision, roadmap, conventions and fourteen decision records.
- Can I try it?
- It is not hosted, by decision. Locally it is Docker for Postgres, storage and mail, then migrate, seed and one dev command. The seed has six weeks of history; open a second browser as maya@northwind.test to watch changes arrive.
- What happened to the first version?
- The NestJS and Prisma API is tagged as v1.0.0 and kept in the repository. Version 2 is a rewrite, not an upgrade: a new stack, a web app, real-time, docs and tests.
- How is it different from Patchgrid?
- On purpose, in almost every layer. Patchgrid is NestJS, Next.js, Prisma with row level security, Redis and BullMQ, and server-sent events. TeamFlow is Bun, Hono with oRPC, Drizzle with application-level tenancy, Postgres alone for jobs and fan-out, and WebSockets with Yjs.
related sheets
//10related sheets
- PatchgridMulti-tenant IT service management with isolation enforced by the database.saas platform
- Node auth templatePasskeys, OpenID Connect and revocable sessions in an authentication backend ready to fork.authentication service
- Express boilerplateA production-grade Express and TypeScript starter that other developers actually fork.open source template
//11contact
Say hello.I read everything.
Email is the fastest way to reach me. For anything that needs a conversation, book a call.
to
- name
- Khaled Saeed
- country
- Lebanon