ADR 0001: Stack for the open-source core
- Status: Accepted
- Date: 2026-11-24
- Deciders: AP Dev Solutions, LLC
- Related: the project overview §6, §7, §14, §15
Context
Section titled “Context”Commitment Desk Inbox is a new open-source repository. It needs a small, credible first release that can receive and review field records while keeping a path to self-hosting later. The stack must:
- Run cheaply on Cloudflare Workers first, without making the domain logic depend on Cloudflare.
- Share one typed API contract between the API and the web app.
- Be approachable for contributors and AI coding agents.
- Keep the operational surface small enough for a solo maintainer.
- Avoid committing to a database, storage, or hosting vendor in the core.
The first milestone (M0) delivers only foundations: workspace tooling, a health endpoint, a web shell, CI, and local development. This ADR fixes the stack decisions that later milestones depend on.
Decision
Section titled “Decision”Use the following stack.
| Concern | Decision |
|---|---|
| Language | TypeScript 6.x, strict compiler settings |
| Package manager | pnpm workspaces (pnpm-workspace.yaml), no Turborepo at the start |
| API runtime | Hono on Cloudflare Workers, with Node/self-host adapter in M3 |
| Contracts | Zod schemas in packages/capture-schema, OpenAPI 3.1 generation in M1 |
| Database | Drizzle ORM with D1/SQLite first, Postgres adapter later |
| Object storage | R2 first behind an AttachmentStore interface, S3-compatible later |
| Queue | Cloudflare Queues first behind a JobQueue interface |
| Web | React 19, Vite, TypeScript, TanStack Query |
| Styling | Plain CSS with design tokens; Radix only where accessibility requires it |
| Tests | Vitest; Miniflare/Workers pool for integration tests; Playwright in M2 |
| Lint and format | ESLint flat config + typescript-eslint, Prettier |
| CI | GitHub Actions: install, typecheck, lint, format check, test, build |
The Worker configuration lives at apps/api/wrangler.jsonc, next to the Worker source. Shared
Cloudflare provisioning notes and future D1 migrations live under infra/cloudflare/.
Portability rule
Section titled “Portability rule”The domain layer in packages/core must not import Cloudflare modules. It depends on interfaces
(CaptureRepository, ParcelRepository, TownRepository, AttachmentStore, JobQueue, Clock,
IdGenerator) that M1 defines. Cloudflare implementations live in the API adapters. The Node/Docker
target in M3 implements the same interfaces.
Contract rule
Section titled “Contract rule”Request and response schemas live in packages/capture-schema and are consumed by both apps. M0
starts this pattern with the health response schema. Apps must not redeclare API types.
Why these choices
Section titled “Why these choices”- Hono + Workers gives a small runtime, fast local development through Wrangler, and a direct upgrade path to Workers, D1, R2, and Queues without adopting a framework with server-rendering opinions the office inbox does not need.
- pnpm workspaces are sufficient for two apps and a few packages. Turborepo adds configuration and cache complexity before there is a build-time problem to solve.
- Zod provides runtime validation and inferred TypeScript types from one definition. That keeps capture-client validation and web types aligned, and supports OpenAPI generation.
- Drizzle + D1 matches the first runtime while keeping SQL explicit. Repository interfaces keep a future Postgres adapter from becoming a rewrite.
- React + Vite is a conventional, well-supported SPA stack. The inbox is office-first and does not need SSR, while TanStack Query covers list/detail caching and request states.
- Plain CSS with tokens avoids a styling dependency and keeps the interface accessible and themeable. Radix primitives can be added where a specific widget needs them.
- Vitest and Playwright match the Vite ecosystem and can run Worker code and browser flows without a second test framework.
Consequences
Section titled “Consequences”- The API must be tested through Hono’s request interface in M0 and through Miniflare once bindings exist in M1. This keeps unit tests fast while leaving integration coverage for real bindings.
- Cloudflare service bindings cannot leak into
packages/core; adapters and dependency injection are required from the first use case. - Internal packages export TypeScript source and are bundled by Vite/Wrangler. They do not produce a
separate
distuntil an external consumer needs one. - Prettier and ESLint run at the repository root, so configs and Markdown are checked consistently.
PLAN.mdand legal texts are excluded from Prettier to preserve their authored line breaks.- Deploying requires Wrangler and Cloudflare credentials. CI only performs a dry-run bundle; it does not deploy. A preview deployment workflow can be added after M1.
- OpenAPI is not generated in M0. The health schema establishes the contract seam; generation lands with the first capture endpoints.
Alternatives considered
Section titled “Alternatives considered”| Alternative | Why not now |
|---|---|
| Next.js full-stack | SSR and framework conventions are unnecessary for an authenticated SPA; it would couple the API and web deploy paths. |
| Node-first API | Workers is the cheapest first deployment. The portability interfaces keep a Node adapter viable without building it in M0. |
| Turborepo or Nx | No build-time problem yet; pnpm recursive scripts are enough. |
| Jest | Vitest shares Vite’s transform pipeline and is faster to configure for React and ESM. |
| Tailwind or a component library | Adds dependencies and styling lock-in for a small office UI; tokens cover M0. |
| Prisma | Drizzle’s SQL-first model fits D1 and keeps the Postgres path explicit. |
| A single-package repo | The API, web app, and contract need separate dependency and deploy boundaries. |
Follow-up decisions
Section titled “Follow-up decisions”- M1: D1 schema, migrations, and repository interfaces.
- M1: OpenAPI generation and the error envelope.
- M2: magic-link authentication and session storage.
- M3: Node/Docker adapter, S3-compatible storage, and database-backed queue.
- Add an ADR before changing the license, the open-core boundary, or the runtime model.