How xcfio/chatio works
Chatio is a real-time chat product: users authenticate in the web app, use chat and account features through the API, and exchange live status and typing events over Socket.IO. The backend also exposes conversation, message, and user operations; shared Drizzle tables and TypeBox types define the data contract. The README documents read receipts and real-time messaging, but the sampled source does not establish which route emits each event, so those specific links are omitted.
Main entry points: src/index.ts Fastify server · database/index.ts Database access · socket/index.ts Socket connection · app Auth and chat UI
Components 19
Web application
- Auth and chat UI
apps/frontend/src/app - HTTP client
apps/frontend/src/lib/fetch.ts - Socket client
apps/frontend/src/lib/socket.ts
Backend API
- Fastify server
apps/backend/src/index.ts - Authentication
apps/backend/src/routes/auth - Conversations
apps/backend/src/routes/conversation - Messages
apps/backend/src/routes/message - User lookup
apps/backend/src/routes/user - Security and API plugins
apps/backend/src/plugin - JWT authentication
apps/backend/src/decorate/auth.ts
Realtime
- Socket connection
apps/backend/src/socket/index.ts - Typing events
apps/backend/src/socket/typing.ts - User presence
apps/backend/src/socket/user-status.ts
Shared data
- Database access
apps/backend/src/database/index.ts - Chat tables
lib/schema/src/table/index.ts - Shared types and events
lib/schema/src/types/index.ts
Other components
- Chat user
- PostgreSQL
- Socket.IO clients
Connections 25
- Chat user → Auth and chat UI: uses
- Auth and chat UI → HTTP client: requests data
- HTTP client → Fastify server: HTTP requests
- Auth and chat UI → Socket client: connects live
- Socket client → Socket.IO clients: Socket.IO events
- Socket.IO clients → Socket connection: connects
- Fastify server → Security and API plugins: registers
- Fastify server → Authentication: registers routes
- Fastify server → Conversations: registers routes
- Fastify server → Messages: registers routes
- Fastify server → User lookup: registers routes
- Fastify server → Socket connection: dispatches connections
- Authentication → JWT authentication: uses authentication
- Authentication → Database access: accesses data
- Conversations → Database access: accesses data
- Messages → Database access: accesses data
- User lookup → Database access: accesses data
- Socket connection → Database access: verifies user
- Socket connection → Typing events: registers events
- Socket connection → User presence: registers events
- Database access → PostgreSQL: queries
- Database access → Chat tables: uses tables
- Fastify server → Shared types and events: uses contracts
- Socket client → Shared types and events: uses event types
- Socket connection → Shared types and events: uses event types