How footprintai/containarium works
1. Repository shape
- This is a Go-first monorepo with a small TypeScript agent runtime and a Next.js web UI. The core platform is in internal/, substrate adapters are in pkg/core/, public API contracts are in proto/ and generated pkg/pb/, and all runnable entrypoints live under cmd/.
2. Primary control-plane entrypoints
- cmd/containarium is the main operator CLI.
- cmd/mcp-server is the platform MCP server for host-level operations.
- cmd/agent-box is the in-container MCP server exposed to the agent itself.
- cmd/containarium, cmd/mcp-server, and the daemon-facing packages share the same underlying service logic rather than duplicating workflows.
3. Top-level runtime topology
- The architecture has a public sentinel edge and one or more backend hosts behind it.
- The sentinel handles inbound SSH and HTTPS routing; backend hosts run the daemon and the tenant boxes.
- The same control plane can target either Incus/LXC or Kubernetes backends at runtime.
4. Agent execution boundary
- Each tenant gets a persistent “box” that is SSH-reachable and also exposes MCP tools from inside the box.
- The data path is: agent client → SSH to box → agent-box MCP over stdio.
- internal/agentbox implements the in-box file, shell, and directory tools, plus a constrained root via AGENTBOX_ROOT when enabled.
5. Host-side orchestration and reconciliation
- internal/server contains the daemon’s business logic: container lifecycle, networking, routes, secrets, security, alerts, traffic, autosleep, and higher-level orchestration.
- pkg/core/box/incus and pkg/core/box/k8s are the substrate adapters for the two runtimes.
- internal/app and related packages model apps, routes, buildpacks, proxies, and route synchronization across the backend.
6. Public ingress and routing
- The sentinel uses SSH proxying for user login into boxes and Caddy for hostname-based HTTPS exposure.
- internal/sentinel, internal/wake, internal/egressproxy, and internal/network/internal/traffic coordinate SSH routing, wake/recovery, passthrough, egress control, and traffic accounting.
- Public app exposure is split between low-level route management and higher-level expose-port workflows.
7. Security and tenancy boundaries
- Authentication is JWT-based for the API, with scopes, revocation, and role checks enforced in internal/auth and internal/server.
- Tenant ownership and admin-only boundaries are explicit in the server handlers.
- Secrets are stored encrypted through pkg/core/secrets and internal/secrets, backed by Postgres plus optional external KMS.
- Audit data is append-only with a hash chain in internal/audit.
8. Networking and policy enforcement
- The repo treats network policy as a first-class subsystem, not just a deployment concern.
- internal/netpolicy, internal/netbpf, and internal/server/network_policy_* implement egress policy, signature-based rules, and kernel-level enforcement hooks.
- The design spans both backend substrates so the policy model stays consistent across LXC and Kubernetes.
9. API contract and transport layers
- proto/containarium/** defines the canonical API surface.
- Generated gRPC services plus gRPC-Gateway handlers live in pkg/pb/**, giving the daemon both gRPC and REST entrypoints.
- Swagger is checked in under api/swagger/, which supports the UI and external clients.
10. Web UI and human-facing management
- web-ui/ is a separate Next.js frontend that talks to the platform APIs and event stream.
- It focuses on container lists, lifecycle controls, metrics, audit, security, network, traffic, and browser-based terminal access.
- The UI is a consumer of the control plane, not a parallel source of truth.
11. Agent/model-side tooling
- agent-runtime/ is a TypeScript package for driving model backends such as Claude, Codex, and Gemini.
- It contains polling, artifact handling, and A2A/engine abstractions, so agent orchestration can sit outside the Go daemon.
- This is adjacent to the platform rather than part of the host runtime itself.
12. Operational and deployment boundary
- terraform/ and deploy/ define production infrastructure, especially GCE and Kubernetes packaging.
- scripts/, hacks/, and images/ hold bootstrap, install, and container image assembly logic.
- The repo is designed to be deployed either as a self-hosted VM stack or inside an existing Kubernetes environment, with the same control surface in both cases.
Main entry points: server Daemon · sentinel Sentinel · agentbox Agent Box · containarium API Surface
Components 21
Runtimes
User-facing and agent-side runtimes outside the Go control plane.
- Agent Runtime · TypeScript agent/model runtime for polling, artifacts, and model engines.
agent-runtime - Web UI · Human-facing management UI for control-plane data and events.
web-ui
Control plane
Go services, daemon logic, and API handlers.
- Sentinel · Public ingress edge for SSH, HTTPS, and host routing.
internal/sentinel - Daemon · Main host-side control service and orchestration entrypoint.
internal/server - Apps · App lifecycle, routes, proxies, buildpacks, and route sync.
internal/app - Agent Box · MCP tool server running inside each tenant box.
internal/agentbox - MCP API · Shared MCP client/server plumbing and tool wiring.
internal/mcp - Auth · JWT auth, scopes, revocation, roles, and tenant boundaries.
internal/auth - Secrets · Secret encryption, KMS integration, and secret reconciliation.
internal/secrets - Audit · Append-only audit trail with hash chaining.
internal/audit - Net Policy · Network policy model, signatures, and enforcement coordination.
internal/netpolicy - Traffic · Connection tracking, flow collection, and traffic storage.
internal/traffic - Wake · SSH wake, recovery, trusted proxy handling, and routing state.
internal/wake - API Surface · Canonical protobuf contracts plus generated gRPC and REST handlers.
proto/containarium - CLI · Operator entrypoints for the main CLI, MCP server, and agent box server.
cmd
Substrates
Runtime adapters and lower-level platform integrations.
- Core Adapters · Shared substrate abstractions for boxes, secrets, networking, and core services.
pkg/core - Incus · Incus/LXC box backend adapter.
pkg/core/incus - K8s · Kubernetes box backend adapter and gateway support.
pkg/core/box/k8s - Hosting · Hostname exposure, Caddy integration, and provider setup.
internal/hosting - Generated PB · Generated protobuf services and gRPC-Gateway shims.
pkg/pb/containarium
Ops
Deployment and release machinery.
- Deploy · Terraform, scripts, images, and deploy manifests for production and lab setups.
terraform
Connections 20
- Sentinel → Wake: SSH routing · Sentinel forwards login and recovery flows through wake/router logic.
- Sentinel → Hosting: HTTPS exposure · Sentinel uses hostname-based HTTPS and Caddy-backed exposure.
- Sentinel → Daemon: backend host · Sentinel fronts backend hosts where the daemon and tenant boxes run.
- Daemon → Core Adapters: uses adapters · Daemon business logic is built on shared core substrate abstractions.
- Daemon → Incus: runtime backend · Daemon can manage boxes on Incus/LXC.
- Daemon → K8s: runtime backend · Daemon can manage boxes on Kubernetes.
- Daemon → Apps: app control · Daemon coordinates apps, routes, buildpacks, and proxies.
- Daemon → Secrets: secret ops · Daemon reconciles and serves encrypted secrets.
- Daemon → Audit: audit trail · Daemon emits append-only audit events.
- Daemon → Net Policy: enforces policy · Daemon applies network policy and enforcement hooks.
- Daemon → Traffic: measures flows · Daemon records traffic and connection accounting.
- Daemon → API Surface: serves API · Daemon exposes protobuf-defined API surfaces.
- API Surface → Generated PB: generated handlers · Generated gRPC and REST handlers implement the canonical contract.
- CLI → Daemon: operator control · Operator CLI and server entrypoints share the same service logic.
- CLI → MCP API: mcp tools · CLI-related MCP workflows reuse the same MCP tool plumbing.
- Agent Box → MCP API: stdio tools · The in-box MCP server exposes file, shell, and directory tools over stdio.
- Agent Box → Auth: root boundary · Constrained root and tenant scoping are enforced around agent-box operations.
- Agent Runtime → MCP API: drives agents · Agent runtime sits beside the platform and orchestrates model-backed execution.
- Web UI → API Surface: consumes api · Web UI reads platform APIs and event streams.
- Daemon → Agent Box: tenant boxes · Daemon provisions and manages the persistent boxes used by tenants.