Context
We need a Universal Delivery Adaptor. It must:
- Execute delivery commands (Email/SMS) from anywhere (Manager, Newsletter, Billing).
- Be secure (handle sensitive API keys).
- Be fast (OTPs must be instant).
- Be dumb (No business logic).
Decision
We will build the Communication Service as a Cloudflare Worker.
Rationale
-
Global Edge Execution:
- OTPs are generated and sent from the nearest data center to the user.
- Reduces latency for the "Critical Path" (Login).
-
Security (The Vault):
- Workers Environment + D1 allows us to store encrypted Tenant Keys securely.
- No "Server Management" means smaller attack surface.
-
Service Bindings (Internal Only):
- We can lock this service down completely.
- Only trusted Apps (
manager,blog-service) can call it viac.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.