How nag763/tchatchers works
Main Components
• Client (Browser): The chat client running in the user’s browser. It loads a static WASM bundle (built with yew.rs) along with assets (HTML, CSS, Tailwind) that display the UI.
• Frontend Service (tchatchers_front): This Rust crate builds the frontend web-app using yew.rs and communicates with the backend via HTTP APIs and Websockets.
• Backend Service (tchatchers_back): This is the API layer built with Axum, handling authentication, chat room management, data persistence, and real-time communication with Websockets.
• Asynchronous Service (tchatchers_async): A dedicated crate that handles asynchronous operations such as queued message processing. It interacts with Redis to manage queues and processes messages asynchronously.
• Core Service (tchatchers_core): This shared library encapsulates common functionality (data models, API-response formats, configuration, authentication tokens, etc.) that is used by both the frontend and backend.
• Command-Line Tools (tchatchers_cli_tools & tct): These tools help in managing or maintaining the application (for example, possibly for environment setup, debugging, or maintenance operations).
• Data Layer: This includes the Postgres database which persists chat data, users, and any other core records, as well as Redis which is used for real-time caching and token storage.
• Proxy/Reverse Proxy: Although not part of the source code, the README describes an architecture layer maintained by nginx that handles HTTPS, security headers, and basic load balancing measures.
Relationships and Interactions
• The Client sends HTTP/Websocket requests to the Frontend Service (served as a static WASM application) which may then interact with the Backend Service.
• The Backend Service (API layer) handles authentication, message handling, and CRUD operations while also interacting with the Postgres database for persistent storage.
• The Asynchronous Service continuously processes messages from Redis queues to handle time-consuming tasks asynchronously.
• The Core library is used by both the frontend and backend layers, ensuring that common logic (such as API responses, configuration, and error management) remains consistent across the application.
• Nginx (reverse proxy) sits at the entry point of the system, routing requests to the appropriate services (frontend, API, and, if applicable, the asynchronous processing endpoints) while enforcing security constraints.
• The CLI Tools provide management operations that might interact with one or several of the above components (for example, updating the environment, migrations, or reporting).
Architectural Patterns and Design Principles
• Service Separation: The project distinguishes frontend, backend, and asynchronous services as separate Rust crates. This modular design encourages separation of concerns.
• Microservices Elements: Although it is a monorepository, the individual services (frontend, backend, async) behave as microservices within the architecture.
• Asynchronous Processing: The dedicated asynchronous layer design shows the use of queues and processors to handle tasks that should not block real-time responses.
• Shared Core: Using a common core crate ensures consistency and reusability across different services.
• Containerization and CI/CD: The existence of multiple Dockerfiles (one per service), docker-compose scripts, GitHub workflows, and Makefiles indicates containerized deployments and an integrated CI/CD process.
• Document interaction points (such as API calls, message queues, Websockets) and include annotations or legends to explain the purpose of each component.