# Codebase

> How the open-source repository is organized.

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

For agents: sypnia-ai repo (Sypnia Git, GitHub mirror): gateway/ Rust workspace (api, router, limits, meter, safety, providers/{openrouter,bedrock,openai_compat}, otel, mcp, store), migrations/, packages/ai (@sypnia/ai server/browser/cli), prices/ (price table format for self-hosting), deploy/ (compose with a fake provider, AWS template), spec/openapi.yaml, spec/routes.schema.json, docs/ARCHITECTURE.md; tests against a recorded fake provider (no keys needed) and contract tests per provider run with real keys in CI.

```text
sypnia-ai/
├─ gateway/             Rust workspace
│  ├─ api/              the HTTP API (axum): OpenAI-compatible endpoints and Sypnia's
│  ├─ router/           routes, versions, fallbacks
│  ├─ limits/           counters and leases
│  ├─ meter/            prices, reservations, charges
│  ├─ safety/           redaction and moderation
│  ├─ providers/        openrouter, bedrock, openai_compat, behind one trait
│  ├─ otel/             spans and their attributes
│  ├─ mcp/              the MCP server
│  └─ store/            Postgres and object storage
├─ migrations/          sypnia_ai schema
├─ packages/ai/         @sypnia/ai (server, browser, cli)
├─ prices/              the price table format, for self-hosting
├─ deploy/              docker compose with a fake provider, AWS template
├─ spec/openapi.yaml
├─ spec/routes.schema.json
└─ docs/ARCHITECTURE.md
```

Tests run against a recorded fake provider, so they need no keys. Contract tests for each real provider run in CI with Sypnia's keys. The repository lives in Sypnia Git, with a mirror on GitHub.
