How stormhaha/green-api-chat works
GREEN-API Chat is a browser messenger for Telegram: users authenticate an instance, create or select a chat, send text, and receive polled notifications. The app layer coordinates login and the messenger; chat actions resolve recipients, dispatch messages and notifications into reducer state, and persist per-instance history locally. The README also documents exclusive-tab handling, retry/status, unread counts, and incoming chats. Links follow explicit README or indexed source references; unsampled reducer and UI behavior is not expanded beyond those references.
Main entry points: useChats.ts Chat actions · Messenger.tsx Messenger shell · App.tsx App coordinator · Sidebar.tsx Chat list
Components 21
App and access
- App coordinator
src/App.tsx - Instance login
src/components/LoginScreen/LoginScreen.tsx - Exclusive tab guard
src/components/TabGuard/TabGuard.tsx
Chat interface
- Messenger shell
src/components/Messenger/Messenger.tsx - Chat list
src/components/Sidebar/Sidebar.tsx - New chat dialog
src/components/NewChatDialog/NewChatDialog.tsx - Conversation view
src/components/ChatView/ChatView.tsx - Message composer
src/components/ChatView/Composer.tsx - Message timeline
src/components/ChatView/MessageList.tsx - Message rendering
src/components/ChatView/MessageBubble.tsx
Messaging workflow
- Chat actions
src/hooks/useChats.ts - Notification polling
src/hooks/useNotificationPolling.ts - Phone normalization
src/domain/phone.ts - Notification parsing
src/domain/notifications.ts - Chat domain helpers
src/domain/chat.ts
Chat state
- Chat reducer
src/state/chatReducer.ts - Chat selectors
src/state/selectors.ts - Local persistence
src/state/storage.ts
GREEN-API integration
- GREEN-API client
src/api/greenApi.ts
Other components
- Messenger user
- GREEN-API service
Connections 32
- Messenger user → App coordinator: opens app
src/App.tsx - App coordinator → Instance login: shows when logged out
src/App.tsx - App coordinator → Local persistence: loads and saves credentials
src/App.tsx - Instance login → GREEN-API client: checks instance
src/components/LoginScreen/LoginScreen.tsx - Instance login → App coordinator: submits credentials
src/components/LoginScreen/LoginScreen.tsx - App coordinator → Exclusive tab guard: wraps authenticated view
src/App.tsx - Exclusive tab guard → Messenger shell: hosts when active
src/App.tsx - Exclusive tab guard → Messenger user: offers tab takeover
README.md - Messenger shell → Chat actions: uses chat actions
src/components/Messenger/Messenger.tsx - Messenger shell → Notification polling: starts polling
src/components/Messenger/Messenger.tsx - Messenger shell → Chat list: renders chat list
src/components/Messenger/Messenger.tsx - Messenger shell → Conversation view: renders conversation
src/components/Messenger/Messenger.tsx - Chat list → New chat dialog: opens dialog
src/components/Sidebar/Sidebar.tsx - Chat list → Chat selectors: sorts chats
src/components/Sidebar/Sidebar.tsx - New chat dialog → Phone normalization: normalizes recipient
src/components/NewChatDialog/NewChatDialog.tsx - Conversation view → Message composer: renders composer
src/components/ChatView/ChatView.tsx - Conversation view → Message timeline: renders timeline
src/components/ChatView/ChatView.tsx - Message timeline → Message rendering: renders messages
src/components/ChatView/MessageList.tsx - Conversation view → Chat domain helpers: uses chat helpers
src/components/ChatView/ChatView.tsx - Message composer → Chat actions: submits message
- New chat dialog → Chat actions: requests chat creation
- Chat actions → Phone normalization: formats fallback chat ID
src/hooks/useChats.ts - Chat actions → GREEN-API client: checks and sends
src/hooks/useChats.ts - Notification polling → GREEN-API client: receives and deletes
src/hooks/useNotificationPolling.ts - Notification polling → Chat actions: delivers notifications
src/components/Messenger/Messenger.tsx - Chat actions → Notification parsing: parses notification
src/hooks/useChats.ts - Chat actions → Chat reducer: dispatches chat events
src/hooks/useChats.ts - Chat actions → Local persistence: loads and persists state
src/hooks/useChats.ts - Chat list → Chat selectors: reads chat ordering
src/components/Sidebar/Sidebar.tsx - GREEN-API client → GREEN-API service: calls HTTP API
README.md - Local persistence → Messenger user: retains local history
README.md - Chat reducer → Chat selectors: provides chat state