Architecture Deep Dive

Bloomx is designed to be headless first. It separates the email "engine" from the "interface", allowing entirely new clients to be built on top of the same diverse infrastructure.

The Engine (Next.js App Router)

Bloomx runs entirely on Next.js 14+ Server Actions and Route Handlers. It uses a mix of Edge Runtime (for speed) and Node.js Runtime (for complex parsing/AI).

The Memory (PostgreSQL)

We use Prisma ORM to interact with Postgres. This ensures type safety from the DB all the way to the React Component. No more `any` types.

The Store (S3/R2)

Attachments are streamed directly to S3-compatible storage (AWS or Cloudflare R2). We generate pre-signed URLs, so your server never bottlenecks on file uploads.

The Vault (Encryption)

User credentials for expansions are encrypted at rest using AES-256-CBC. Keys are derived from a master server secret, ensuring even database dumps are useless to attackers.

The Expansion Lifecycle

When an event occurs (e.g. an email is received via Webhook), the flow is as follows:

  1. Ingestion: Resend POSTs to /api/webhooks/resend.
  2. Parsing: We use simple-mail-parser to extract body, headers, and attachments.
  3. Storage: Raw email is stored in Postgres; attachments streamed to R2.
  4. Expansion Trigger: The ExpansionRegistry checks for any expansions compliant with EMAIL_RECEIVED.
  5. Execution:
    • Organizer: Classifies the email using Vercel AI SDK.
    • Summarizer: Generates a summary if the thread is long.
    • Webhooks: Forwards the payload to user-defined URLs if configured.
BloomX Mail