Chatify is a terminal-first, self-hosted chat system with a Rust server and client.
Core components:
- Server binary: src/main.rs
- Client binary: src/client.rs
- Shared crypto library: src/crypto.rs
- Optional Discord bridge: src/discord_bot.rs (feature-gated)
The server maintains in-memory runtime state plus a persistent event store:
- Channels and broadcast buses are kept in DashMap.
- Channel history is retained in bounded in-memory queues.
- Durable events are written to SQLite for history/search/rewind.
Event flow:
- WebSocket payload received.
- Payload validated and dispatched by event type.
- In-memory channel state updated.
- Durable event persisted when relevant.
- Broadcast forwarded to subscribed clients.
SQLite stores chat events and schema metadata:
- schema_meta table tracks schema_version.
- events table stores normalized event payloads.
- Migration path upgrades old schema versions.
- Newer unsupported schema versions are not downgraded.
Client responsibilities:
- Authentication and connection lifecycle.
- Command parsing and outbound payload generation.
- Inbound event dispatch and local timeline rendering.
- Local key derivation and message encryption/decryption.
Client code is organized around small event handlers and shared queue helpers to keep the main loop readable.
Shared crypto helpers provide:
- Channel key derivation from password + channel salt.
- DM key derivation through X25519 Diffie-Hellman.
- ChaCha20-Poly1305 encryption and decryption.
- Password hashing and keypair/public key helpers.
The Discord bridge is feature-gated behind discord-bridge.
Build behavior:
- Default build excludes bridge dependencies and binary.
- Enabling discord-bridge compiles and exposes discord_bot binary.
Current integration coverage focuses on protocol contracts:
- Auth and user payload shape.
- Message roundtrip behavior.
- Voice payload forwarding.
- Durable history/search/rewind behavior.
- Schema migration and version handling.
Recommended CI checks:
- cargo fmt --check
- cargo clippy --all-targets --all-features -- -D warnings
- cargo test --all
- cargo check --features discord-bridge --bin discord_bot