Skip to content

Cortex Server, Execution Engine

Cortex Server is the Node.js runtime that executes habits. It exposes a REST API and can be self-hosted anywhere Node.js runs: a VPS, Docker container, serverless function, or CI runner.

What it is

CapabilityDescription
REST APIEvery habit becomes an HTTP endpoint automatically
CLI executionRun any habit from the command line
Multi-habit stacksLoad multiple habits from a single stack.yaml
Dynamic modulesLoad bits on demand; no rebuild required
StreamingServer-sent events for long-running workflows
Swagger UIAuto-generated API docs at /misc/api-docs

Cortex Engine

How to run

bash
# Latest from npm
npx habits cortex --config ./stack.yaml

# Or pin a version
npx habits@1.2.3 cortex --config ./stack.yaml

Server starts at http://localhost:3000 by default.

Key API endpoints

MethodPathDescription
GET/POST/api/{workflow-id}Execute a workflow
GET/misc/workflowsList all loaded workflows
GET/misc/workflow/{id}Workflow details
GET/misc/api-docsSwagger UI

TIP

Never use /misc/execute/, it does not exist. Execute via /api/{workflow-id}.

Self-hosting with Docker

bash
docker run -v $(pwd)/stack.yaml:/app/stack.yaml \
  -p 3000:3000 \
  habits cortex --config /app/stack.yaml

See the Docker Compose examples in the repository.

Deep dive

Relation to other tools

ToolRelation
BaseBase designs habits; Cortex runs them
AdminAdmin orchestrates multiple Cortex instances
Desktop AppThe app bundles Cortex for offline execution
Mobile AppThe mobile app bundles Cortex for on-device execution

Released under the AGPL-3.0 License.