System Architecture
High-Level Diagram
graph TB
cli["Safekeys CLI"]
control_plane_db["Control Plane Database"]
control_plane["Control Plane API"]
mcp_server["Safekeys MCP Server"]
python_sdk["Python SDK"]
site["Safekeys.ai Site"]
sidecar["Sidecar / Resolver"]
typescript_sdk["TypeScript SDK"]
cli --> sidecar
cli --> control_plane
control_plane --> key_store
control_plane --> control_plane_db
mcp_server --> cli
python_sdk --> cli
sidecar --> control_plane
sidecar --> key_store
typescript_sdk --> cliTechnology Stack
| Service | Type | Runtime | Tech Stack |
|---|---|---|---|
| Safekeys CLI | api | go | language: Go, framework: spf13/cobra for command routing, distribution: single static binary per platform (Linux, macOS) |
| Control Plane Database | database | postgres | engine: Postgres 16, migrations: SQL migrations applied at boot, access: pgx (Go) with prepared statements, backups: managed snapshots plus PITR |
| Control Plane API | api | go | language: Go, framework: net/http (standard library) or chi, database: Postgres, key_store: OpenBao or Vault (Transit / KV), migrations: SQL migrations applied at boot, observability: Prometheus metrics and structured logs |
| Safekeys MCP Server | api | node | language: TypeScript / Node, protocol: Model Context Protocol (stdio transport), transport: local sidecar Unix socket for resolution |
| Python SDK | api | python | language: Python 3.11+, packaging: pyproject.toml, published to PyPI, agent_frameworks: LangChain and LangGraph tools first, transport: local sidecar Unix socket |
| Safekeys.ai Site | web-app | nextjs | framework: Next.js, styling: Tailwind CSS, hosting: static or edge deploy, docs: open protocol specification and getting-started guides |
| Sidecar / Resolver | worker | go | language: Go, crypto: AES-256-GCM and ChaCha20-Poly1305 for object encryption; signed capability tokens, transport: Unix domain socket for local agent/CLI requests, isolation: separate OS user, seccomp/AppArmor profile, no shared memory with agents, observability: Prometheus metrics (resolution latency, deny rate) |
| TypeScript SDK | api | node | language: TypeScript / Node, packaging: npm workspace package, agent_frameworks: Mastra, Vercel AI SDK, OpenAI Agents SDK |
System Components
Safekeys CLI
Type: api
Runtime: go
Summary: Safekeys CLI — the operator and agent-facing command line (safekeys create, exec, revoke, list). It talks to the local sidecar over the Unix socket and to the control plane for token lifecycle, never handling plaintext except on the create path where it writes directly to the sidecar.
Depends on: sidecar, control-plane
Control Plane Database
- Type: database
- Runtime: postgres
- Port: 5432
- Summary: Postgres data model for the control plane — objects, wrapping keys, token issuance, the jti revocation denylist, policy rules, and the append-only audit log. Stores identifiers, policy, and outcomes only: no plaintext, no unwrapped keys. Wrapped DEKs live with the folder; the KEK lives in the key store.
Control Plane API
Type: api
Runtime: go
Port: 8080
Summary: Control Plane API — issues and revokes capability tokens, manages policy, and exposes the audit log. It never receives plaintext secrets. Built in Go on Postgres, authenticating sidecars and CLIs via API key in the MVP and mTLS later.
Depends on: key-store, control-plane-db
Safekeys MCP Server
Type: api
Runtime: node
Summary: Safekeys MCP Server — the highest-leverage MVP integration. One MCP server exposes Safekeys tools to every MCP-capable agent runtime (Claude, Cursor, Codex, Gemini), so agents can create and use secrets without per-vendor SDK work. Agents receive only tokens, paths, and status.
Depends on: cli
Python SDK
Type: api
Runtime: python
Summary: Python Agent SDK — a token-only client for agents building secret workflows (LangChain and LangGraph tools first). It exposes create_secret and resolve_for_tool, and by construction cannot return plaintext to the caller: it only ever returns capability tokens and folder paths.
Depends on: cli
Safekeys.ai Site
- Type: web-app
- Runtime: nextjs
- Port: 3000
- Summary: Safekeys.ai Site — the public marketing and documentation presence at safekeys.ai, explaining the encrypted transport model, the open protocol, and the "Secrets move. Models don't see." positioning. It is the adoption front door for the open core.
TODO (post-0.1.0, vanity Go module path): serve a go-import meta tag at safekeys.ai/go so Go installs can read go install safekeys.ai/go/cmd/safekeys. Do NOT switch the module path until the site is live and serving that path; the module remains github.com/Smith-Gray-Pty-Ltd/safekeys for 0.1.0.
Sidecar / Resolver
Type: worker
Runtime: go
Summary: Sidecar / Resolver — the only component permitted to resolve a capability token. It validates tokens, requests data-key unwrap from the key store, injects plaintext into a non-LLM consumer, and zeroises. Written in Go, it runs as a separate user from agents with seccomp/AppArmor confinement and no shared memory.
Depends on: control-plane, key-store
TypeScript SDK
Type: api
Runtime: node
Summary: TypeScript SDK — the Node-side counterpart to the Python SDK, targeting Mastra, Vercel AI SDK, and OpenAI Agents SDK customers. Identical token-only API surface: accept and return capability tokens and folder paths, never plaintext.
Depends on: cli
Third-Party Services
| ID | Name | Reference |
|---|---|---|
| control-plane-api | Safekeys Control Plane API | apps/control-plane |