How sadhguru-slayer/fieldchat works
FieldChat is an asynchronous chat backend. Users authenticate, connect through REST or WebSockets, manage conversations, and exchange persistent messages plus transient typing/presence events. Persistent message changes are recorded with outbox events, streamed through Redis, and delivered to WebSocket clients; ephemeral events use Pub/Sub. The graph also preserves documented profile, administration, storage, and push-notification capabilities. Several routes and workers are represented by their exact tree paths but were not sampled, so their internal call wiring is intentionally limited to documented relationships.
Main entry points: redis_client.py Redis state and streams · main.py FastAPI application · auth.py Authentication routes · manager.py Connection manager
Components 25
API and identity
- FastAPI application
app/main.py - Authentication routes
app/router/auth.py - User and token services
app/services/user.py - JWT security
app/core/security/auth.py - User model
app/models/auth/user.py - Admin operations
app/admin/message.py
Chat domain
- Conversation routes
app/router/chat.py - Message routes
app/router/messages.py - Message processing
app/services/messages.py - Messages and chat models
app/models/chat/messages.py - Attachment storage
app/services/storage_service.py
Realtime delivery
- WebSocket event handling
app/ws/sockets.py - Connection manager
app/ws/manager.py - Redis event handlers
app/redis/handlers.py - Stream consumer groups
app/redis/stream_listner.py - Pub/Sub subscribers
app/redis/subscribers.py - Transactional outbox
app/services/outbox_service.py
Persistence and state
- Redis state and streams
app/redis_client.py - Presence cache
app/services/cache_management/presence.py - Conversation cache
app/services/cache_management/conversation.py - PostgreSQL application state
app/database.py
Profiles and notifications
- Profile and settings routes
app/router/profile.py - Notification service
app/services/notification_service.py
Other components
- Chat user
- Web Push provider
Connections 30
- Chat user → FastAPI application: uses API
- FastAPI application → Authentication routes: registers routes
app/main.py - Authentication routes → User and token services: looks up users
app/router/auth.py - Authentication routes → JWT security: issues tokens
app/router/auth.py - Authentication routes → User model: creates user
app/router/auth.py - Chat user → Conversation routes: manages conversations
- Conversation routes → Conversation cache: uses membership cache
app/router/chat.py - Chat user → Message routes: sends messages
- Message routes → Message processing: processes messages
app/router/messages.py - Message routes → Messages and chat models: reads and writes
app/router/messages.py - Chat user → WebSocket event handling: connects by WebSocket
- WebSocket event handling → Connection manager: manages connections
app/ws/sockets.py - Connection manager → Redis state and streams: tracks connections
app/ws/manager.py - Connection manager → Presence cache: updates presence
app/ws/manager.py - Message processing → Transactional outbox: records persistent events
- Transactional outbox → PostgreSQL application state: reads pending events
app/services/outbox_service.py - Transactional outbox → Redis state and streams: publishes stream events
app/services/outbox_service.py - Redis state and streams → Stream consumer groups: delivers stream events
app/redis/stream_listner.py - Stream consumer groups → Redis event handlers: dispatches events
app/redis/stream_listner.py - Redis event handlers → Connection manager: fans out events
app/redis/handlers.py - Chat user → Pub/Sub subscribers: sends transient events
- Pub/Sub subscribers → Redis state and streams: subscribes to Pub/Sub
- FastAPI application → Profile and settings routes: registers routes
app/main.py - Chat user → Notification service: receives notifications
- Notification service → Web Push provider: dispatches Web Push
app/services/notification_service.py - Notification service → Redis state and streams: publishes notification events
app/services/notification_service.py - Chat user → Attachment storage: uploads attachments
- FastAPI application → Admin operations: mounts admin
app/main.py - Conversation routes → PostgreSQL application state: persists conversations
- WebSocket event handling → Message processing: handles message events
app/ws/sockets.py