$ show 123nhh/tempmail
TempMail is a self-hosted temporary email service platform that provides disposable email addresses with automatic expiration. The system uses a microservices architecture with separate containers for API (Go/Gin), frontend (Nginx), email reception (Postfix), and email processing (custom LMTP daemon). Key features include domain pool management with automatic MX validation, API Key authentication with rate limiting, OAuth login options, and web-based email management. The platform is optimized for high throughput with innovations like a delivery batcher that groups multiple email writes into single database transactions and a stats flusher that efficiently aggregates in-memory counters.
The LLM identified 3 files worth highlighting for reuse:
Implements micro-batching of email deliveries to optimize database write performance. Groups multiple delivery requests into a single PostgreSQL statement while preserving API contract semantics. Demonstrates sophisticated understanding of high-throughput systems with proper failure handling and atomicity guarantees. The component is isolated with clear interfaces and could be extracted for any high-write database scenario.
Redis-based sliding window rate limiting middleware for Gin framework. Uses Redis pipeline for efficiency and implements fail-open behavior (allows requests if Redis is unavailable). Clean, isolated implementation that follows security best practices for API protection. Could be easily extracted for use in any web service requiring rate limiting.
Implements efficient counter flushing from memory to database using JSONB for batch updates. The RunStatsFlusher and flushCounters functions provide high-performance statistics updates by aggregating counters in memory and periodically flushing to PostgreSQL. Demonstrates advanced understanding of database performance optimization with proper crash recovery handling. Could be extracted for any high-write counter scenario.