v0.1 · cross-IDE · Claude Code · Cursor · Windsurf
Markdown→HTML artifact
before · markdown2,431 lines · 18 sections · scroll forever
plan.md — agent output
# Add real-time chat to the dashboard
A small, end-to-end feature: drop a chat panel into the existing
dashboard so support engineers can talk to a customer while they're
looking at the same data. The plan below walks through schema,
transport, UI, and rollout. Approve the steps you want and tweak
the rules — the agent will use your decisions before it starts.
## Architecture
A quick look at how the pieces connect. The frontend opens a
WebSocket through our existing edge gateway; the gateway routes
to a stateless chat service that fans messages out via Redis
pub/sub and persists to the existing events table.
```mermaidgraph LR Browser["Browser"] -- WSS --> Edge["Edge Gateway"] Edge -- gRPC --> Chat["Chat Service"] Chat <--> Redis[("Redis pub/sub")] Chat -- INSERT --> DB[("events table")] Worker -- LISTEN --> DB```## Backend### Step 1: Add the `chat_messages` schema
Create a new migration that adds:
| Column | Type | Notes
|--------------|-------------|----------------| id | uuid | primary key
| room_id | uuid | indexed
| author_id | uuid | indexed
| body | text | length-checked at write
| created_at | timestamptz | default now()
Add a partial index on (room_id, created_at DESC)
WHERE deleted_at IS NULL to keep the recent-messages query fast.
### Step 2: Stand up the chat service
A tiny stateless Go service. Subscribes to Redis, fans out to
WebSocket connections.
What's the right ceiling for messages per second per user? Bots
will hit whatever we set; aim for something that feels natural
to a human typing.
- messages_per_second: 5
- burst: 20
- ban_on_violation: false
### Step 3: Wire it through the edge gateway
The gateway already terminates TLS and authenticates users. Add
a /chat route that upgrades to WebSocket and forwards to the chat
service via gRPC, preserving the user's bearer token in a metadata
header. (continues for ~1,800 more lines…)
after · html-plannerinteractive · 8 steps · 1 live question
localhost:4321 — Add real-time chat to the dashboard
live
Add real-time chat to the dashboard
3 approved5 pending
💬 Agent question
Which database driver should we use for the chat_messages table?