Jose Selesan 4ed6432f60 feat: push live list changes over server-sent events
Every member viewing a list opens one SSE stream
(`GET /api/lists/:listId/events`) and refreshes the affected queries when
somebody else adds or buys an item, invites a person or renames the list, so
shared lists stay in sync without a reload.

- `@superlist/shared`: `ListEvent` / `ListEventType` contract.
- API: in-process `ListEvents` pub/sub keyed by list id; a `requireListMembership`
  middleware; a `streamSSE` route with a reconnect `ready` frame and a heartbeat,
  plus `server.timeout(req, 0)` so Bun does not close the quiet stream. Use cases
  publish `item.created`, `item.updated`, `list.updated`, `member.added` and
  `invitation.created` after their writes.
- Web: `useListEvents` subscribes with `EventSource` (`withCredentials`) and
  invalidates the matching TanStack Query keys, mounted where a list is shown and
  in the list settings page.

The API is reached through the same-origin `/api` prefix: every module is mounted
under `/api/*`, `apiBaseUrl` always appends `/api` to the optional `VITE_API_URL`,
the BetterAuth client points at the page origin, and Vite proxies `/api` to the
Bun API in dev (nginx does in production).
2026-10-16 14:58:31 -03:00

Superlist

Monorepo with a Bun + Hono API and a React + Vite admin app.

Workspace What it is
apps/api Bun + Hono backend, Prisma (Postgres), Zod validation, Pino logging
apps/web React + Vite + TypeScript frontend, shadcn/ui, TanStack Router + Query
packages/shared @superlist/shared — Result pattern and RFC 9457 Problem Details types

See STACK.md for the stack and AGENTS.md for the architecture conventions.

Requirements

  • Bun (workspace package manager and API runtime)
  • Postgres (only needed once you run migrations)

Getting started

bun install

# API
cp apps/api/.env.example apps/api/.env      # then edit DATABASE_URL / BETTER_AUTH_SECRET
bun run db:generate                          # prisma generate
bun run db:migrate                           # requires a reachable Postgres

# Web
cp apps/web/.env.example apps/web/.env

Run everything in parallel:

bun run dev            # turbo run dev → api on :4100, web on :7153

Or a single workspace: bun run dev --filter=@superlist/web.

Verification

bun run build          # turbo run build
bun run lint           # biome check per package (lint + format + import order)
bun run typecheck      # tsc
bun run test           # bun test (api) / vitest (web, shared)

CI (.github/workflows/ci.yml) runs db:generate → lint:ci → typecheck → test → build on every push to main and every pull request.

Useful scripts

Command Effect
bun run lint:fix Apply Biome fixes: lint, formatting and import sorting (whole repo)
bun run lint:ci biome ci — check the whole repo exactly as CI does
bun run format Format with Biome (format:check to verify only)
bun run db:generate Regenerate the Prisma client into apps/api/src/generated
bun run db:migrate Create and apply a migration (development)
bun run db:studio Open Prisma Studio

Auth

BetterAuth is mounted by the API under /api/auth/* and uses the Prisma adapter. The web app talks to it through apps/web/src/lib/auth-client.ts; the _authenticated route layout redirects to /sign-in when there is no session.

Description
No description provided
Readme 1.3 MiB
Languages
TypeScript 98.3%
CSS 1%
Dockerfile 0.4%
HTML 0.3%