Axum-based backend for a personal website, with a real-time chat system and SQLite persistence.
Real-time visitor/admin chat over WebSockets, with message history persisted in SQLite and broadcast updates to all connected admins.
- Connect to
GET /ws(WebSocket). - Send
Hellowithclient_idand optionalchat_id. - Receive
Welcomewith the resolvedchat_id, thenHistory(last 200 messages). - Send
SendMessageto persist and broadcast to the chat and all admins.
- Connect to
GET /admin/ws(WebSocket). - Send
AdminHellowithtoken(fromADMIN_TOKEN). - Receive
ChatListordered by last activity. - Send
AdminJoinChatto loadHistory. - Send
AdminSendMessageto persist and broadcast to the chat and all admins.
- SQLite database at
./data/chat.dbby default. chatsandmessagestables are auto-created on boot.- New messages are broadcast to all subscribers in the chat, plus all admins.
GET /healthGET /ws(visitor WebSocket)GET /admin/ws(admin WebSocket)
HOST(default127.0.0.1)PORT(default3000)FRONTEND_ORIGIN(defaulthttp://localhost:5173)ADMIN_TOKEN(optional; required for admin WebSocket auth)DATABASE_URL(defaultsqlite://./data/chat.db)
export ADMIN_TOKEN="your-token"
cargo run