How yengas/rust-chat-server works
This workspace is an educational, room-based chat application: a terminal user connects to the server, joins a room, and exchanges messages. The TUI routes input into a Redux-inspired state store, which manages the TCP client connection and commands; server sessions dispatch room operations and relay room events back to clients. The graph also captures the shared communications protocol and the server’s room/session layers. Some page, room, and event implementations were not sampled, so their wiring is shown only where the README or sampled callers support it.
Main entry points: state_store.rs State store · chat_session.rs Chat session · client.rs TCP client transport · mod.rs Page router
Components 19
Terminal client
- TUI runtime
tui/src/main.rs - UI manager
tui/src/ui_management/ui_manager.rs - Page router
tui/src/ui_management/pages/mod.rs - Connect page
tui/src/ui_management/pages/connect_page - Chat page
tui/src/ui_management/pages/chat_page - UI actions
tui/src/state_store/action.rs - State store
tui/src/state_store/state_store.rs - Client state
tui/src/state_store/state.rs
Chat server
- Server runtime
server/src/main.rs - Chat session
server/src/session/chat_session.rs - Room manager
server/src/room_manager/room_manager.rs - Chat rooms
server/src/room_manager/room - Room session handle
server/src/room_manager/room/user_session_handle.rs
Shared communications
- TCP client transport
comms/src/transport/client.rs - User commands
comms/src/command.rs - Chat events
comms/src/event.rs - TCP server transport
comms/src/transport/server.rs
Other components
- Chat user
- TCP connection
Connections 25
- Chat user → Connect page: enters address
- Chat user → Chat page: uses chat
- TUI runtime → State store: starts loop
- TUI runtime → UI manager: starts loop
- UI manager → Page router: renders and routes
- Page router → Connect page: selects page
- Page router → Chat page: selects page
- Connect page → UI actions: dispatches
- Chat page → UI actions: dispatches
- UI actions → State store: consumed by
- State store → Client state: updates
- State store → UI manager: publishes state
- State store → TCP client transport: connects and exchanges
- TCP client transport → User commands: serializes and reads
- TCP client transport → Chat events: reads and deserializes
- TCP client transport → TCP connection: uses TCP
- TCP connection → Server runtime: connects to listener
- Server runtime → Chat session: spawns per connection
- Chat session → TCP server transport: handles TCP stream
- TCP server transport → User commands: reads commands
- TCP server transport → Chat events: writes events
- Chat session → Room manager: joins and leaves
- Room manager → Chat rooms: manages membership
- Chat session → Room session handle: sends room messages
- Room session handle → Chat events: broadcasts message