How vhqtvn/vh-mail-hook works
Main Components
• Mail Service: Located in the “crates/mail-service” directory. It is responsible for receiving, processing, encrypting, and managing emails. This service implements SMTP handling (with dedicated modules for SMTP server, handler, and DNS logic), rate limiting, and mailbox specific encryption.
• Web Application: Found in “crates/web-app”. It offers a RESTful API for mailbox management and authentication functionalities. Note that the web-app has both a frontend (using modern frameworks like Svelte, as seen by the presence of Svelte components, tailwind config, and Vite configuration) and a backend (Rust APIs, authentication logic, and integration with the common utilities).
• Common Library: In “crates/common”. This provides shared utilities such as database connectivity, migration scripts, rate limiting logic, and security functions across other crates.
• Client Library: In the “packages/npm” directory. This officially supports external JavaScript/TypeScript integrations with the VHMailHook system.
Relationships and Data Flows
• The Mail Service receives incoming emails via SMTP. It handles tasks like rate limiting and encryption (using AGE and other encryption modules) and stores processed email data.
• The Web Application offers API endpoints (for authentication, mailbox management, etc.) and interacts with the database (configured via SQLite). It also has front-end aspects that consume these APIs and provide a modern two-column layout.
• Both services share common utilities from the “common” crate, so there’s a dependency/integration aspect where shared modules (like database layers or security services) are reused.
• External OAuth providers (GitHub, Google) and a Telegram login widget are integrated with the web service for authentication. Also consider that the mail service may be exposed externally for incoming SMTP traffic.
• The Client Library acts as a wrapper for external apps/integrations, ensuring that API calls to the web application are properly formatted.
Architectural Patterns and Design Principles
• Modular Cargo Workspace: Each crate (common, mail-service, web-app) is separated by functionality, promoting a layered architecture.
• Separation of Concerns: Clearly divides email processing (mail-service) and API/front-end management (web-app).
• RESTful API: The web application exposes a set of APIs (detailed in README) for user authentication and mailbox operations.
• Automation and CI/CD: The presence of GitHub Workflows and Dockerfile suggest a containerized environment—good to include deployment pipelines, docker containers, and possibly automated publishing or building stages.