Phase 3 scaffold: chat engine (WebSocket, FCM, pricing, timer, extension, history)

- Backend: WebSocket plugin, chat/pricing/timer/extension/closure/notification services
- Client app: ChatBloc, pricing dialog, chat screen with message status, extension/goodbye flow, history
- Mitra app: MitraChatBloc, ExtensionBloc, chat screen, extension accept/reject, history
- Control center: free trial, extension timeout, early end config toggles
- DB migration: chat_messages, session_closures, session_extensions, customer_transactions tables

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 23:58:11 +08:00
parent 844d7234e6
commit b4efcf14c2
47 changed files with 4361 additions and 44 deletions

View File

@@ -30,7 +30,7 @@ Mental health chat platform connecting clients (users seeking support) with trai
- **Control center is internal-only** — never expose its API routes to the public internet; protected via Nginx allow/deny + VPN
- **Firebase Auth** tokens are verified on Fastify via JWT — user data lives in PostgreSQL, linked by Firebase UID
- **Horizontal scaling** (Cloud Run) handles load — do not split into microservices prematurely
- **Real-time features** use Valkey pub/sub for in-app events; FCM push notifications planned for next phase
- **Real-time features** use WebSocket for chat + Valkey pub/sub as backend bus; FCM push for background notifications
- **Pairing** uses blast-to-all-available-mitras with first-come-first-served acceptance
## Current Progress
@@ -47,6 +47,12 @@ Mental health chat platform connecting clients (users seeking support) with trai
- mitra_app: online/offline toggle, heartbeat + lifecycle handling, incoming request notification, active sessions screen
- control_center: dashboard (auto-refresh), max customers per mitra config, session management + reroute, mitra online logs
- Docs: `requirement/phase2.md`, `requirement/phase2-plan.md`
- **Phase 3 (Chat Engine)** — fully scaffolded
- Backend: WebSocket plugin, chat message service, session timer (backend-authoritative), extension/closure services, FCM push notifications, pricing service (mock tiers + free trial)
- client_app: ChatBloc (WebSocket), ChatOpeningBloc (pricing), SessionClosureBloc, chat screen with message status (sent/delivered/read), typing indicator, extension/goodbye flow, chat history + transcript screens, FCM setup
- mitra_app: MitraChatBloc (WebSocket), ExtensionBloc, chat screen, extension accept/reject, goodbye flow, chat history + transcript screens, FCM setup
- control_center: free trial config, extension timeout config, early end toggles (mitra/customer)
- Docs: `requirement/phase3.md`, `requirement/phase3-plan.md`
## Domain Concepts