How aman6012/realtime-chat works
Realtime Chat is a browser chat client backed by an Express/Socket.IO server and MongoDB. Users register or log in, then join a room, load recent messages and online users, and exchange live messages; the server also supports private messages and message-history APIs. The graph follows calls and data transfers shown in the client, server entry point, routes, and socket handlers. Room model and user-directory route are included based on the source index; their internal behavior is not excerpted.
Main entry points: App.tsx Chat interface · src/index.ts HTTP and socket server · auth.ts Authentication routes · socketHandlers/index.ts Live chat handlers
Components 16
Chat client
- Chat interface
client/src/App.tsx
Server API and realtime
- HTTP and socket server
server/src/index.ts - Authentication routes
server/src/routes/auth.ts - JWT authentication
server/src/middleware/auth.ts - Input validation
server/src/middleware/validation.ts - Message history API
server/src/routes/messages.ts - Online user API
server/src/routes/users.ts - Live chat handlers
server/src/socketHandlers/index.ts - Standalone chat server
realtime-chat/index.js
Domain and persistence
- User records
server/src/models/User.ts - Message records
server/src/models/Message.ts - Room model
server/src/models/Room.ts - Domain types
server/src/types/index.ts - Legacy user model
realtime-chat/models/User.js - Legacy message model
realtime-chat/models/Message.js
Other components
- Chat user
Connections 23
- Chat user → Chat interface: uses
client/src/App.tsx - Chat interface → Authentication routes: registers or logs in
client/src/App.tsx - HTTP and socket server → Authentication routes: mounts routes
server/src/index.ts - Authentication routes → Input validation: validates input
server/src/routes/auth.ts - Authentication routes → User records: reads and updates
server/src/routes/auth.ts - Authentication routes → JWT authentication: protects endpoints
server/src/routes/auth.ts - Chat interface → HTTP and socket server: opens socket
client/src/App.tsx - Chat interface → Message history API: requests history
client/src/App.tsx - Chat interface → Online user API: requests online users
client/src/App.tsx - HTTP and socket server → Message history API: mounts routes
server/src/index.ts - HTTP and socket server → Online user API: mounts routes
server/src/index.ts - HTTP and socket server → Live chat handlers: registers handlers
server/src/index.ts - Message history API → JWT authentication: authenticates requests
server/src/routes/messages.ts - Message history API → Message records: queries history
server/src/routes/messages.ts - Live chat handlers → Message records: stores and loads
server/src/socketHandlers/index.ts - Live chat handlers → User records: updates presence
server/src/socketHandlers/index.ts - Live chat handlers → Input validation: validates messages
server/src/socketHandlers/index.ts - Chat interface → Live chat handlers: joins and exchanges events
client/src/App.tsx - Standalone chat server → Legacy user model: uses
realtime-chat/index.js - Standalone chat server → Legacy message model: uses
realtime-chat/index.js - User records → Domain types: implements
server/src/models/User.ts - Message records → Domain types: implements
server/src/models/Message.ts - Room model → Domain types: implements
server/src/models/Room.ts