How shakib-zeydi/raayanchat-widget works
Rayan Chat Widget is an embeddable React chat interface. A host page mounts the widget; visitors register or resume a session, choose AI or human support, then send messages and view history or live operator updates. The graph separates the widget’s user-facing flows, conversation state, network adapters, and browser persistence. Several connections are supported by the source index or README rather than full excerpts; those limits are reflected by omitting uncertain links.
Main entry points: widget.tsx Widget shell · human-chat.tsx Human chat · ai-chat.tsx AI chat · http.ts HTTP client
Components 23
Embed and widget
- Widget mount
src/main.tsx - Widget shell
src/components/widget.tsx - Mode selector
src/components/conversation-mode-selector.tsx - Chat header
src/components/chat-header.tsx
Conversation experiences
- AI chat
src/components/ai-chat.tsx - AI conversation
src/hooks/use-ai-conversation.ts - Human chat
src/components/human-chat.tsx - Human conversation
src/hooks/use-human-conversation.ts - Human read tracking
src/hooks/use-human-conversation-read.ts - Human notifications
src/hooks/use-human-notifications.ts - Message list
src/components/message-list.tsx - Message input
src/components/message-input.tsx
Session and state
- Visitor form
src/components/visitor-form.tsx - Visitor session
src/hooks/use-visitor-session.ts - Widget storage
src/storage/widget-storage.ts
Service connectivity
- AI API adapter
src/services/ai-conversation-api.ts - Visitor API adapter
src/services/visitor-api.ts - Notification API
src/services/human-notifications.ts - HTTP client
src/services/http.ts - Realtime client
src/lib/echo.ts
Other components
- Host website
- Chat backend
- WebSocket service
Connections 29
- Host website → Widget mount: mounts
src/main.tsx - Widget mount → Widget shell: renders
src/main.tsx - Widget shell → Visitor session: creates session
src/components/widget.tsx - Widget shell → Human notifications: checks unread
src/components/widget.tsx - Widget shell → Visitor form: renders
src/components/widget.tsx - Widget shell → Mode selector: offers modes
src/components/widget.tsx - Widget shell → Chat header: renders
src/components/widget.tsx - Widget shell → AI chat: renders
src/components/widget.tsx - Widget shell → Human chat: renders
src/components/widget.tsx - AI chat → AI conversation: uses
src/components/ai-chat.tsx - AI chat → Message list: renders
src/components/ai-chat.tsx - AI chat → Message input: renders
src/components/ai-chat.tsx - Human chat → Human conversation: uses
src/components/human-chat.tsx - Human chat → Human read tracking: uses
src/components/human-chat.tsx - Human chat → Message list: renders
src/components/human-chat.tsx - Human chat → Message input: renders
src/components/human-chat.tsx - Visitor session → Visitor API adapter: registers visitor
src/hooks/use-visitor-session.ts - Visitor session → Widget storage: reads and saves
src/hooks/use-visitor-session.ts - AI conversation → AI API adapter: loads and sends
src/hooks/use-ai-conversation.ts - AI conversation → Widget storage: persists conversation
src/hooks/use-ai-conversation.ts - Human conversation → Widget storage: persists conversation
src/hooks/use-human-conversation.ts - Human conversation → Realtime client: subscribes
src/hooks/use-human-conversation.ts - Human notifications → Notification API: loads status
src/hooks/use-human-notifications.ts - Human notifications → Realtime client: subscribes
src/hooks/use-human-notifications.ts - AI API adapter → HTTP client: requests
src/services/ai-conversation-api.ts - Visitor API adapter → HTTP client: requests
src/services/visitor-api.ts - Notification API → HTTP client: requests
src/services/human-notifications.ts - HTTP client → Chat backend: sends HTTP
src/services/http.ts - Realtime client → WebSocket service: connects
src/lib/echo.ts