# Codebase

> Where everything of Sypnia Cases lives.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://cases.docs.sypnia.com/architecture/codebase/

For agents: Repository sypnia-cases (open source): spec/ (JSON Schemas for map, navigation, case and event envelope; OpenAPI), packages/cases (@sypnia/cases: src/sypnorm, src/runtime, src/map, src/spec, src/client, src/cli), migrations/ (the schema sypnia_cases, shared by both runtimes), crates/ (sypnia-cases-core, sypnia-cases: the Rust runtime, sypnia-cases-testkit), server/ (TypeScript: api/, mcp/, auth/, directory/, maps/, jobs/, links/, appdb/, export/, db/ with Sypnorm use cases and migrations), examples/la-espiga, deploy/ (Dockerfile, docker-compose.yml), docs/ARCHITECTURE.md. Licenses: server/ AGPL-3.0-only; packages/cases and crates/ MIT (they run inside apps); spec/ open for anyone to implement. The editor lives in the private sypnia-cloud repository.

```text
sypnia-cases/                 open source
├── spec/                     the format, open for anyone to implement
│   ├── map.schema.json       the format (JSON Schema 2020-12)
│   ├── navigation.schema.json
│   ├── case.schema.json
│   ├── event.schema.json     the event envelope
│   └── openapi.yaml          the API
├── migrations/               the schema sypnia_cases (subscriptions, outbox, deliveries, processed_events): one SQL contract for both runtimes
├── packages/cases/           @sypnia/cases (MIT)
│   └── src/{sypnorm,runtime,map,spec,client,cli}   Sypnorm, the runtime, deriving the map, the format, the API client, the CLI
├── crates/                   MIT
│   ├── sypnia-cases-core/    the Rust side of the format: names, case files, schedules, the event graph
│   ├── sypnia-cases/         the runtime for Rust services (outbox, tokio delivery task, idempotency)
│   └── sypnia-cases-testkit/ a throwaway Postgres for tests
├── server/src/               the Cases server (AGPL-3.0)
│   ├── api/                  routes
│   ├── mcp/                  the MCP tools
│   ├── auth/, directory/     tokens, sessions, members and roles
│   ├── maps/                 changes, levels, uploads
│   ├── jobs/                 review e-mails
│   ├── links/                readers for Data and Telemetry
│   ├── appdb/                deliveries and dead letters in the app's database
│   ├── export/               the map as files
│   └── db/                   Sypnorm use cases and migrations
├── examples/la-espiga/       the docs' bakery, end to end
├── deploy/                   Dockerfile, docker-compose.yml
└── docs/ARCHITECTURE.md

sypnia-cloud/                 private
└── cases-editor/             the visual editor
```
