docs(fe): record backend/gateway data-flow contract in AGENTS.md
Build & Deploy (Nix) / build-and-deploy (backend) (push) Successful in 1m36s
Build & Deploy (Nix) / build-and-deploy (discord-gateway) (push) Successful in 2m33s
Build & Deploy (Nix) / build-and-deploy (proxy) (push) Successful in 2m31s
Build & Deploy (Nix) / build-and-deploy (backend) (push) Successful in 1m36s
Build & Deploy (Nix) / build-and-deploy (discord-gateway) (push) Successful in 2m33s
Build & Deploy (Nix) / build-and-deploy (proxy) (push) Successful in 2m31s
This commit is contained in:
@@ -8,3 +8,29 @@ Key points:
|
||||
- **WebSocket** at `src/lib/ws/` — auto-reconnecting client with typed event subscriptions
|
||||
- **Static export**: `output: "export"` in next.config.ts, served via nginx
|
||||
- **No authentication**: all endpoints are public
|
||||
|
||||
## Data flow (match these — do not invent endpoints)
|
||||
|
||||
```
|
||||
Discord → discord-gateway → Redis pub/sub → backend (Express :3001) ←→ frontend
|
||||
↑ REST /api/* (same-origin)
|
||||
└ WS /ws (events + PCM binary)
|
||||
```
|
||||
|
||||
- **Base URL**: API + WS default to same-origin. `gmw-proxy` nginx (:8080)
|
||||
proxies `/api` and `/ws` to the backend on :3001. Public host:
|
||||
`imphnen.asepharyana.my.id` (Cloudflare SSL in front of Traefik → :8080).
|
||||
- Local dev overrides: `NEXT_PUBLIC_API_URL` and `NEXT_PUBLIC_WS_URL`
|
||||
(e.g. https://imphnen.asepharyana.my.id).
|
||||
- **Never hardcode a host** in api/ws clients — same-origin or env override only.
|
||||
|
||||
## Backend response shapes that bite
|
||||
|
||||
- `GET /api/chat/history` → `{ history: ChatbotHistoryRow[], total }` where
|
||||
each row is `{ id, user_id, user_message, bot_response, context, created_at }`.
|
||||
Map rows to display messages in `chatbot-context.tsx`.
|
||||
- `message_deleted` WS payload → `{ id, deleted_at }` (an object, not a string).
|
||||
- `voice_recording_uploaded` WS payload has **no** `duration_bytes` (REST rows do).
|
||||
- Dashboard endpoints: `/api/dashboard/stats|users|channels` (+ `/:id` details).
|
||||
- Channel/guild names live inside `message.metadata` JSON (`channel.channelName`),
|
||||
not top-level.
|
||||
|
||||
Reference in New Issue
Block a user