How riskymh/emailthing works
Project type and purpose
• This is a full‑stack monorepo centered on email management (“EmailThing”).
• It contains two front‑ends:
– A PWA built with Bun + React/JSX (apps/pwa)
– A Next.js web app (apps/web)
• It also includes back‑end/serverless code:
– Next.js API routes under apps/web/app/api
– Cloudflare Email Workers for inbound (receive‑email) and outbound (send‑email)
• A shared database layer (packages/db) using Drizzle ORM + SQLite/Turso
• A CLI/SDK package (packages/emailthing) and helper scripts for setup
File structure
• Top‑level “apps” folder holds two separate front‑ends (pwa, web).
• “apps/web/app/api” contains REST/cron/debug/internal/v0 endpoints.
• “cloudflare-workers” houses standalone worker scripts for email ingest/send.
• “packages/db” exports schema, queries, and Drizzle config – consumed by both front‑ends and API.
• “packages/emailthing” provides a CLI and SDK for interacting with your email API.
• “scripts” includes administrative setup (create‑admin).
• CI/CD manifests: .github/workflows, bun.lock, package.json at root.
README for additional insights
• The Web UI and PWA call Cloudflare Email Workers to receive incoming mail and MailChannels (or custom workers) to send.
• Data persistence is in SQLite or Turso, via Drizzle.
• Service‑worker based notifications, S3 for attachments, DKIM, JWT tokens, and S3 environment variables.
• Local dev uses “bun db:push” and “bun dev --turbo” to spin up both front‑ends and API.
– UI → API → DB
– UI → API v0/send → Worker → MailChannels/S3
– Worker → API v0/receive-email → DB → UI (via Web Push)
– Blue for Clients
– Green for API/Serverless
– Orange for Data/Storage
– Purple for External Services
Detail
• Every logical component (PWA, web, API submodules, workers, packages, scripts).
• Don’t just show “Back‑end” – break it out into API routes, Workers, Cron jobs.
• Your shared modules (packages/db, packages/emailthing) and how they plug into each consumer.
• Configuration sources (env vars, bun scripts) as annotations if helpful.