How aayush746/wiget_chat works
ChatFlow is an embeddable, multi-tenant support-chat product: visitors start and resume widget conversations, while staff manage the inbox and respond from a real-time dashboard. The API also handles identity, website/FAQ configuration, assignments, reporting, and an optional FAQ-grounded AI agent with human handoff. The README documents client/API and database links; sampled controllers show key service calls. Several subsystem internals were not sampled, so their detailed links are omitted rather than inferred.
Main entry points: app.module.ts API application · WidgetApp.tsx Chat widget · ai.worker.ts AI agent · conversations.service.ts Conversation workflow
Components 22
Chat clients
- Chat widget
apps/widget/src/WidgetApp.tsx - Widget panel
apps/widget/src/components/Panel.tsx - Message state
apps/widget/src/lib/messages.ts - Visitor storage
apps/widget/src/lib/storage.ts - Staff dashboard
apps/dashboard/src/app/DashboardShell.tsx - Dashboard session
apps/dashboard/src/App.tsx
API services
- API application
apps/api/src/app.module.ts - Authentication
apps/api/src/auth/auth.service.ts - Visitor identity
apps/api/src/visitors/visitors.service.ts - Conversation workflow
apps/api/src/conversations/conversations.service.ts - Message handling
apps/api/src/conversations/messages.service.ts - Realtime chat
apps/api/src/realtime/chat.gateway.ts
Tenant administration
- Website settings
apps/api/src/websites/websites.service.ts - FAQ knowledge base
apps/api/src/websites/faqs.service.ts - Staff memberships
apps/api/src/websites/memberships.service.ts - Staff accounts
apps/api/src/users/users.service.ts - Conversation assignments
apps/api/src/conversations/assignments.service.ts
AI and reporting
- AI agent
apps/api/src/ai/ai.worker.ts - Tenant reports
apps/api/src/reports/reports.service.ts
Persistence
- Postgres database
Other components
- Website visitor
- Model backend
Connections 27
- Website visitor → Chat widget: opens chat
- Chat widget → API application: HTTP and sockets
- Staff dashboard → API application: HTTP and sockets
- Chat widget → Widget panel: renders
apps/widget/src/WidgetApp.tsx - Chat widget → Message state: sends messages
apps/widget/src/WidgetApp.tsx - Chat widget → Visitor storage: loads and saves
apps/widget/src/WidgetApp.tsx - Dashboard session → Staff dashboard: shows after login
apps/dashboard/src/App.tsx - API application → Authentication: registers module
apps/api/src/app.module.ts - API application → Conversation workflow: registers module
apps/api/src/app.module.ts - API application → Visitor identity: registers module
apps/api/src/app.module.ts - API application → Realtime chat: registers module
apps/api/src/app.module.ts - API application → Tenant reports: registers module
apps/api/src/app.module.ts - API application → Website settings: registers module
apps/api/src/app.module.ts - API application → Staff accounts: registers module
apps/api/src/app.module.ts - API application → AI agent: registers module
apps/api/src/app.module.ts - API application → Postgres database: persists data
- Authentication → Staff accounts: looks up accounts
apps/api/src/auth/auth.service.ts - Visitor identity → Postgres database: reads and writes
- Conversation workflow → Postgres database: reads and writes
- Message handling → Postgres database: reads and writes
- Realtime chat → Message handling: dispatches messages
- AI agent → FAQ knowledge base: grounds answers
- AI agent → Model backend: requests completions
- AI agent → Conversation workflow: hands off threads
- Tenant reports → Postgres database: aggregates data
- Staff memberships → Postgres database: reads and writes
- Conversation assignments → Postgres database: reads and writes