- Asynchronous Chat System
- Demo
- Running Server and Client
- Configurations
- Running Tests
- Git Hooks Setup
- GitHub Workflow
- Clean And Build
- Summary of the Responsibilities for crate chatty-types and chatty-tcp in Workspace
- Domain Driven Terminology
A high-performance asynchronous chat system consisting of a server and CLI client implementation, designed for maximum throughput and concurrency.
Manages a single chat room with efficient user handling Processes incoming messages through non-blocking operations Broadcasts messages to all connected users except the sender Handles user join/leave operations seamlessly Maintains unique usernames across the system Optimized for high throughput with minimal memory footprint Implements automatic cleanup on user disconnection
Features an async CLI interface Connects automatically to the server on startup Configurable through environment variables or command line arguments for:
- Host address
- Port
- Username
Provides an interactive command prompt supporting:
- send for message broadcasting
- leave for graceful disconnection
To run the server and client, use the following commands:
just run-chatty-tcp-server
And for 3 clients:
just run-chatty-tcp-client-carl-join
This passes the username carl as an argument to the client. And similarly for other clients:
just run-chatty-tcp-client-david-join
just run-chatty-tcp-client-lucio-join
For entering username at the prompt:
just run-chatty-tcp-client-join-no-username
The project uses custom configurations defined in .cargo/config.toml
:
- TCP_SERVER_ADDRESS default "localhost"
- TCP_SERVER_PORT default "8081" These configurations are used to set the server address and port for the TCP server. This allows clients to connect to the server using the same address and port.
just test
This project uses git hooks to ensure code quality. To set up the pre-commit hook:
chmod +x .githooks/pre-commit
git config core.hooksPath .githooks
Once set up, this hook will automatically run before every commit to ensure code quality. You can also run it directly anytime:
./.githooks/pre-commit
The project leverages GitHub Actions to validate chat server client connectivity and executes both unit and integration
tests.
The workflow is defined in .github/workflows/rust.yml
.
just clean
just build
just build-with-tests
- Core types and behaviors (more will be added as needed when more protocols are added, currently only TCP. However, the separation is done from extensibility perspective if more protocols are added)
- Shared infrastructure like tracing config
- TCP-specific transport layer or tightly coupled logic with TCP for now
- Server and client implementations
- Client has:
- Sending
command
module as part of the client - Processing
response
module as part of the client - These are part of the
connect
module used by the client.
- Sending
- Server has:
- Processing
command
module as part of the server - Sending
response
module as part of the server - These are part of the
listen
module used by the server.
- Processing
Bidirectional communication between the client and server is clear based on module names.
Both have command
and response
modules: the client sends the commands and processes responses, while the server
processes commands and sends responses.
The following terms are consistently used throughout the project, forming the core vocabulary of our domain-specific language in both design and development:
- User: A person who interacts with the chat application.
- Command: Command issued by a user to the chat application.
- ChatMessage: Message sent by a user in the chat application as part of Send command.
- ChatResponse: Response sent by the chat application.
- ChatMemo: Memo sent by the chat application as part of ChatResponse.