logicspike/docs

Communication

ADR 001: Communication Service as a Stateless Delivery Edge

Context

We need a Universal Delivery Adaptor. It must:

  1. Execute delivery commands (Email/SMS) from anywhere (Manager, Newsletter, Billing).
  2. Be secure (handle sensitive API keys).
  3. Be fast (OTPs must be instant).
  4. Be dumb (No business logic).

Decision

We will build the Communication Service as a Cloudflare Worker.

Rationale

  1. Global Edge Execution:

    • OTPs are generated and sent from the nearest data center to the user.
    • Reduces latency for the "Critical Path" (Login).
  2. Security (The Vault):

    • Workers Environment + D1 allows us to store encrypted Tenant Keys securely.
    • No "Server Management" means smaller attack surface.
  3. Service Bindings (Internal Only):

    • We can lock this service down completely.
    • Only trusted Apps (manager, blog-service) can call it via c.env.COMMUNICATION.
    • Zero public internet exposure for the internal API.

Trade-offs

  • No Background Heavy Lifting:
    • It cannot "generate" a PDF invoice (CPU limit). It must receive the PDF or a URL.
    • Mitigation: The Caller generates content, this service just delivers it.

Status

Accepted.

Communication