Architecture Overview
| Layer | Technology | Rationale |
|---|---|---|
| Compute | Cloudflare Workers | Edge-first, zero cold starts, scales to zero |
| Database | Cloudflare D1 (SQLite) | SQL at the edge, point-in-time recovery, 100GB storage |
| Validation | Zod (shared schema package) | Same validation on CLI and API, TypeScript-first |
| Docs | Astro Starlight on Cloudflare Pages | Static, fast, built-in search (Pagefind) |
Request lifecycle
Section titled “Request lifecycle”┌──────────────────────────────────────────────────────┐│ Client (CLI / SDK) │└────────────┬───────────────────────────────┬─────────┘ │ │ ┌───────▼────────┐ ┌──────▼──────────┐ │ POST /form │ │ POST /submit │ │ (validate) │ │ (webhook) │ └───────┬────────┘ └──────┬──────────┘ │ │ ┌───────▼───────────────────────────────▼─────────┐ │ Cloudflare Worker │ │ ┌─────────────────────────────────────────┐ │ │ │ Hono Router │ │ │ │ ├─ Auth middleware (API key) │ │ │ │ ├─ Zod validation │ │ │ │ ├─ Business logic │ │ │ │ └─ D1 query │ │ │ └─────────────────────────────────────────┘ │ └──────────────────────┬──────────────────────────┘ │ ┌───────▼────────┐ │ Cloudflare D1 │ │ (SQLite) │ └────────────────┘Why edge?
Section titled “Why edge?”- Latency. Workers run in 300+ data centers. A form validation round-trip is <50ms for most users.
- Scaling. Zero servers to manage. Workers scale to zero when idle.
- D1. SQLite at the edge with full SQL support, point-in-time restore, and up to 100GB per database.
- Cost. Pay per request, not per server-hour.
Monorepo layout
Section titled “Monorepo layout”agentsforms/├── apps/│ ├── api/ Cloudflare Workers API (Hono)│ ├── web/ Landing page + dashboard (Astro)│ └── docs/ This documentation (Astro Starlight)├── packages/│ ├── schemas/ Zod schemas + validation (shared)│ └── sdk-js/ JavaScript SDK (TypeScript)├── forms/ Demo form definitions└── examples/ Agent integration examplesDeployment
Section titled “Deployment”| Service | Platform | URL |
|---|---|---|
| API | Cloudflare Workers | api.agentsforms.com |
| Docs | Cloudflare Pages | docs.agentsforms.com |
| Landing | Cloudflare Pages | agentsforms.com |
| Hosted Forms | Cloudflare Workers | agentsforms.com/f/* |