feat: implement real-time booking updates using Server-Sent Events (SSE) and add public booking URL sharing to the dashboard

This commit is contained in:
Jose Selesan
2026-04-17 17:25:46 -03:00
parent a075f13587
commit e0d755bef7
10 changed files with 226 additions and 8 deletions

View File

@@ -53,6 +53,19 @@ The project uses **Better Auth** for session management, replacing the legacy Su
- **Zod v4**: Use `.issues` instead of `.errors` for validation errors.
- **TanStack Router**: Routes are code-generated. Use `--filter frontend build` not raw vite build.
## Real-time Updates (SSE)
The project uses **Server-Sent Events (SSE)** for real-time booking updates in the admin panel.
- **Backend**: `apps/backend/src/lib/sse.ts` provides the `sseManager` and SSE endpoint `/api/events/:channel`.
- **Event flow**: When a public booking is created, the handler emits to channel `complex:{complexId}`.
- **Frontend**: `home-page.tsx` connects to the SSE endpoint and invalidates the bookings query on new events.
**Important - Multi-process limitation**: The current SSE implementation works with a single Bun process only. If you deploy with multiple workers (e.g., clustering in Dokploy), events won't be shared across workers. For production with multiple workers, use Redis for pub/sub:
- Install `@hono/node-server` or a Redis client
- Replace `sseManager` with Redis pub/sub
- Or fall back to Socket.io with Redis adapter
## Docker Deployment (Dokploy)
- **Build Context**: `./` (monorepo root)