Generic technical documentation for Stockflow.
This document is intentionally scoped to:
stockflow/- root config used by Stockflow (
docker-compose.yml,.env,config/)
Excluded by default:
temporal/bpm_engine/
Stockflow is a YAML execution engine for backend workflows.
Project direction:
- Inspired by Kestra and Supabase.
- Built so users can define workflow logic in YAML and execute it safely in a controlled runtime.
- Create PostgreSQL tables.
- Run
db:generatefromstockflow/package.json. - Stockflow updates generated DB artifacts used by the project.
- Write YAML functions in
stockflow/data/functions. - Execute them through
/api/rpc.
docker compose upcd stockflow
npm install
npm run devStockflow server entrypoint: stockflow/src/index.ts
GET /api: service check endpointPOST /api/rpc: execute YAML functionPOST /api/query: execute structured query modelPOST /mcp: MCP endpoint exposing YAML tools withskill: true
Location: stockflow/data/functions/**/*.yml
Common structure:
nameversiontemporal(optional)paramsstepsreturn
Temporal routing rules:
- Top-level
temporal: trueapplies to all steps by default. step.temporaloverrides the default for an individual step.- Flagged steps are sent to
TEMPORAL_STEP_EXECUTOR_URLwhen configured. - Without
TEMPORAL_STEP_EXECUTOR_URL, flagged steps run locally for backward compatibility.
Supported step.type values:
callmapeditFieldreferencequerypersistconditionloop
- Runtime executor:
stockflow/src/runtime/index.ts - Built-in functions:
stockflow/src/runtime/system-functions.ts - YAML loader + templating:
stockflow/src/helper/yaml.loader.ts - Query compiler:
stockflow/src/helper/query.model.ts - DB schema:
stockflow/src/db/schema.ts
Request context is converted into PostgreSQL claim settings in middleware:
stockflow/src/middleware/rls.tsstockflow/src/middleware/withDb.ts
Typical headers:
x-claimsx-auth-request-userx-user-roleauthorization: Bearer <jwt>
cd stockflow
npm run db:generate
npm run db:migrateMinimum expected variables:
DATABASE_URLJWT_SECRET
Optional platform variables may include OAUTH2_PROXY_*, N8N_*, and pgAdmin settings depending on compose usage.
- Keep changes scoped and minimal.
- Preserve existing YAML runtime behavior unless change is intentional.
- Avoid committing secrets.
- Update docs when endpoint/runtime behavior changes.