$ show RiskyMH/EmailThing
EmailThing is a self-hosted email service providing web (PWA), CLI, and API interfaces for sending and receiving emails with custom domains. The system consists of a Bun-based backend API using PostgreSQL with Drizzle ORM, a React/Next.js PWA with Dexie IndexedDB for offline capabilities, and a CLI tool for management. It handles email storage via S3, authentication with JWT/sessions and passkeys, rate limiting with Redis, and integrates with external email services for sending while using Cloudflare Workers for reception. The architecture follows a monorepo pattern with clear separation: apps/api (backend server), apps/pwa (frontend interface), apps/cli (terminal tool), and shared packages for database, constants, and SDK. Key features include multi-user mailbox management, aliases, custom domain support, team collaboration, end-to-end encryption for sensitive data, and real-time synchronization between client and server. The system emphasizes user control over email infrastructure while providing modern web application experiences.
The LLM identified 5 files worth highlighting for reuse:
Implements CRC-based checksum validation for tokens to prevent timing attacks. Provides secure token generation and verification utilities that are self-contained and could be extracted for use in any application requiring secure token handling. Demonstrates security-aware implementation beyond basic JWT libraries.
Namespaced Redis wrapper with automatic key prefixing, TTL management, and connection handling. Encapsulates Redis concerns into a reusable utility that prevents key collisions and simplifies cache operations. Could be adapted for other projects needing Redis integration with proper scoping.
Abstracts S3-compatible storage operations (upload, delete, get signed URL) with consistent error handling. Provides a vendor-agnostic interface that works with AWS S3, Cloudflare R2, or other S3-compatible services. Demonstrates proper cloud storage abstraction that could be reused in any application needing blob storage.
Type-safe API client providing end-to-end type safety for API consumption. Automatically maps API endpoints to typed functions with proper request/response validation. Shows excellent DX-focused design that could be adapted for other REST APIs while maintaining strict type safety.
Dexie IndexedDB wrapper providing a typed interface for client-side database operations. Encapsulates database schema, versioning, and query logic into a reusable module. Demonstrates proper client-side storage abstraction that could be adapted for other PWA applications needing offline-first capabilities.