Thanks for your interest in contributing. This document covers the conventions and workflow for the project.
-
Clone and install:
git clone https://github.com/Stackbilt-dev/mindspring.git cd mindspring npm install -
Configure: Copy
.env.exampleto.envand add yourCLOUDFLARE_API_TOKEN. -
Run locally:
wrangler dev
-
Run checks:
npm run type-check # TypeScript compilation npm test # Vitest test suite
Every source file must stay under 400 lines. If a module is approaching this limit, decompose it into focused sub-modules. This is a hard constraint inherited from the broader Stackbilt architecture.
The only runtime dependency is Hono. Everything else — JSON parsing, rate limiting, auth, telemetry — is implemented directly against Cloudflare Workers APIs. Do not add runtime dependencies without discussion.
Dev dependencies (TypeScript, Vitest, Wrangler, @cloudflare/workers-types) are fine.
src/
├── index.ts — App entry point, middleware wiring, route registration
├── queue.ts — Queue consumer (ingestion pipeline)
├── lib/ — Shared libraries (auth, telemetry, parsing, clients)
│ └── __tests__/ — Unit tests co-located with their modules
└── routes/ — Hono route handlers, one file per resource
frontend/
├── index.html — App shell
├── styles.css — Design system (CSS custom properties, no preprocessor)
└── app.js — Vanilla JS SPA (no build step, no framework)
lib/contains pure logic and middleware that doesn't depend on route structure.routes/contains Hono route handlers grouped by resource. Each file exports aHonoinstance that gets mounted inindex.ts.frontend/is served as static assets via Cloudflare Workers Static Assets. No build step — edit and deploy.- Tests go in
lib/__tests__/orroutes/__tests__/, mirroring the source structure.
- No frameworks, no build tools. The frontend is vanilla HTML/CSS/JS.
- CSS custom properties defined in
:rootfor theming. Follow the Cloud Architecture palette. - Fonts: Syne (display), DM Sans (body), JetBrains Mono (data). Do not add additional font imports.
- No npm dependencies in the frontend. Everything is self-contained.
- Strict mode is enabled. Do not use
// @ts-ignoreoranywithout a comment explaining why. - All Cloudflare bindings are typed via the
Envinterface inlib/types.ts. If you add a new binding inwrangler.toml, add the corresponding type. - Hono context variables (set by middleware, read by handlers) are typed via
AppVariablesinlib/types.ts.
- Routes: Return structured JSON errors with appropriate HTTP status codes. Never leak stack traces to the client in production.
- Queue consumer: Errors are caught per-message and logged to telemetry. Failed messages are retried by the Queue. Progress is checkpointed to KV so retries resume from the last successful batch.
- Middleware: Auth and validation middleware return early with 4xx responses. Rate limit middleware includes
Retry-Afterheaders.
All observable events should write a TelemetryEnvelope to KV via logEvent() or logIngestionEvent(). This is the standard observability format for the Stackbilt ecosystem. Include:
requestIdfor correlationcategoryfor filtering (request,ingestion,error,auth)durationMsfor performance tracking- Structured
dataorerrorpayloads
- Branch: Create a feature branch from
main. - Checks: Ensure
npm run type-checkandnpm testpass before opening a PR. - Module discipline: Verify no file exceeds 400 lines (
wc -l src/**/*.ts). - Description: Include a summary of changes and any architectural decisions.
- Review: PRs require at least one approval before merging.
- Create a new file in
src/routes/(e.g.,src/routes/topics.ts). - Export a
Honoinstance with your route handlers. - Mount it in
src/index.tswith the appropriate auth and rate limit middleware. - Add the endpoint to the root
/endpoint listing. - Document it in
openapi.yamlandREADME.md.
- Create a new file in
src/lib/. - Export typed functions or classes — no side effects at module level.
- Add tests in
src/lib/__tests__/. - Update
src/lib/types.tsif new bindings or context variables are needed.
Open an issue on GitHub with:
- Steps to reproduce
- Expected vs actual behavior
- Relevant error messages or telemetry output