Forge was rebuilt from scratch after a catastrophic failure taught us critical lessons. This document captures the architectural decisions and their rationale.
What happened: Excessive API calls and workflow automation triggered account suspension. Solution: Local-first development. GitHub Actions only for final deployment triggers.
What happened: Cloudflare Workers 3MiB limit caused deployment failures. Solution: Use Cloudflare Pages (no bundle limit) for primary hosting.
What happened: D1 database tied us to Cloudflare's ecosystem. Solution: Turso/libSQL - SQLite-compatible, works everywhere.
What happened: Errors swallowed, debugging impossible. Solution: Comprehensive logging, health checks, error boundaries.
- Interface Layer - Cloudflare Pages (SSR + Static)
- Compute Layer - Cloudflare Workers (Background Jobs)
- Database Layer - Turso/libSQL (Platform-agnostic)
- CI/CD Layer - Local-first with minimal GitHub deps
- Monitoring Layer - Health checks + Structured logging
| Component | Choice | Rationale |
|---|---|---|
| Framework | Next.js 15 | SSR + API routes + static export |
| Database | Turso | Platform-agnostic SQLite |
| ORM | Prisma | Type-safe, multi-backend |
| Hosting | Cloudflare Pages | No bundle limits, edge network |
| Language | TypeScript | Type safety catches errors early |
- Zero administration
- ACID compliant
- Works embedded or over HTTP
- No vendor lock-in
- All IDs use cuid() (collision-resistant, sortable)
- Cascade deletes for owned resources
- Indexes on all foreign keys and query patterns
- Audit log for all mutations
- No bundle size limit
- Global edge network
- Built-in analytics
- Background jobs only
- Scheduled tasks (cron)
- Webhook processing
- GitHub Actions for compute
- Long-running processes in serverless
- Storing secrets in code
- Encryption at rest: All secrets encrypted with FORGE_ENCRYPTION_KEY
- Environment isolation: Dev/staging/prod separation
- Least privilege: API tokens scoped to specific operations
- Audit trail: All actions logged with actor and timestamp
- /api/health - System health check
- Structured logging with correlation IDs
- Error tracking (TODO: Sentry integration)
- Performance metrics (TODO)
- Multi-region database replication
- Queue system for build jobs
- Plugin architecture for workflows
- Self-hosted runner support