# pi-pod/pipod architecture

> Architecture diagram of the GitHub repository pi-pod/pipod, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pi-pod/pipod
- Repository: https://github.com/pi-pod/pipod

## Overview

Pi Pod runs pi coding-agent sessions in remote sandbox pods. A CLI or mobile app signs in, requests pod lifecycle operations from the server, and drives a session through the server gateway; the server provisions pods in the sandbox service. The server also exposes jobs, templates, and settings capabilities. The README establishes the main cross-service relationships; detailed wiring for unsampled subsystems is therefore not inferred.

Main entry points: [`server/src/server/app.ts`](https://github.com/pi-pod/pipod/blob/main/server/src/server/app.ts) (Server API), [`cli/src/cli.ts`](https://github.com/pi-pod/pipod/blob/main/cli/src/cli.ts) (CLI), [`ios/PiPod/Features/Common/RootView.swift`](https://github.com/pi-pod/pipod/blob/main/ios/PiPod/Features/Common/RootView.swift) (iOS app), [`android/app/src/main/kotlin/com/pipod/app/MainActivity.kt`](https://github.com/pi-pod/pipod/blob/main/android/app/src/main/kotlin/com/pipod/app/MainActivity.kt) (Android app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_cli["CLI<br/>[cli.ts]"]
  node_ios["iOS app<br/>[RootView.swift]"]
  node_android["Android app<br/>[MainActivity.kt]"]
end

subgraph group_control["Control plane"]
  node_api["Server API<br/>[app.ts]"]
  node_podroutes["Pod lifecycle<br/>[routes.ts]"]
  node_gateway["Session gateway<br/>[routes.ts]"]
  node_jobs["Scheduled jobs<br/>[routes.ts]"]
  node_templates["Pod templates<br/>[routes.ts]"]
  node_settings["Settings<br/>[routes.ts]"]
  node_database[("Postgres<br/>[index.ts]")]
end

subgraph group_runtime["Pod runtime"]
  node_sandboxapi["Sandbox API<br/>[server.ts]"]
  node_manager["Pod manager<br/>[manager.ts]"]
  node_container["Container runtime<br/>[crun.ts]"]
  node_shim["Pi shim<br/>[pi-pod-ext.ts]"]
end

subgraph group_identity["Identity"]
  node_zitadel{{"Zitadel OIDC"}}
end

node_user(("User"))

node_user -->|"uses"| node_cli
node_user -->|"uses"| node_ios
node_user -->|"uses"| node_android
node_cli -->|"requests"| node_api
node_ios -->|"requests"| node_api
node_android -->|"requests"| node_api
node_api -->|"registers routes"| node_podroutes
node_api -->|"registers routes"| node_gateway
node_api -->|"registers routes"| node_jobs
node_api -->|"registers routes"| node_templates
node_api -->|"registers routes"| node_settings
node_api -->|"uses"| node_database
node_podroutes -->|"provisions pods"| node_sandboxapi
node_sandboxapi -->|"dispatches requests"| node_manager
node_manager -->|"starts containers"| node_container
node_gateway -->|"relays sessions"| node_shim
node_shim -->|"runs inside pod"| node_container
node_cli -->|"signs in via"| node_zitadel
node_ios -->|"signs in via"| node_zitadel
node_android -->|"signs in via"| node_zitadel

click node_cli "https://github.com/pi-pod/pipod/blob/main/cli/src/cli.ts"
click node_ios "https://github.com/pi-pod/pipod/blob/main/ios/PiPod/Features/Common/RootView.swift"
click node_android "https://github.com/pi-pod/pipod/blob/main/android/app/src/main/kotlin/com/pipod/app/MainActivity.kt"
click node_api "https://github.com/pi-pod/pipod/blob/main/server/src/server/app.ts"
click node_podroutes "https://github.com/pi-pod/pipod/blob/main/server/src/server/pods/routes.ts"
click node_gateway "https://github.com/pi-pod/pipod/blob/main/server/src/server/gateway/routes.ts"
click node_jobs "https://github.com/pi-pod/pipod/blob/main/server/src/server/jobs/routes.ts"
click node_templates "https://github.com/pi-pod/pipod/blob/main/server/src/server/templates/routes.ts"
click node_settings "https://github.com/pi-pod/pipod/blob/main/server/src/server/settings/routes.ts"
click node_database "https://github.com/pi-pod/pipod/blob/main/server/src/server/db/index.ts"
click node_sandboxapi "https://github.com/pi-pod/pipod/blob/main/sandbox/src/api/server.ts"
click node_manager "https://github.com/pi-pod/pipod/blob/main/sandbox/src/core/manager.ts"
click node_container "https://github.com/pi-pod/pipod/blob/main/sandbox/src/runtime/crun.ts"
click node_shim "https://github.com/pi-pod/pipod/blob/main/server/src/core/shim/pi-pod-ext.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_ios,node_android,node_user toneBlue
class node_api,node_podroutes,node_gateway,node_jobs,node_templates,node_settings,node_database toneAmber
class node_sandboxapi,node_manager,node_container,node_shim toneMint
class node_zitadel toneRose
```

## Components

### User clients

- [CLI](https://github.com/pi-pod/pipod/blob/main/cli/src/cli.ts): `cli/src/cli.ts`
- [iOS app](https://github.com/pi-pod/pipod/blob/main/ios/PiPod/Features/Common/RootView.swift): `ios/PiPod/Features/Common/RootView.swift`
- [Android app](https://github.com/pi-pod/pipod/blob/main/android/app/src/main/kotlin/com/pipod/app/MainActivity.kt): `android/app/src/main/kotlin/com/pipod/app/MainActivity.kt`

### Control plane

- [Server API](https://github.com/pi-pod/pipod/blob/main/server/src/server/app.ts): `server/src/server/app.ts`
- [Pod lifecycle](https://github.com/pi-pod/pipod/blob/main/server/src/server/pods/routes.ts): `server/src/server/pods/routes.ts`
- [Session gateway](https://github.com/pi-pod/pipod/blob/main/server/src/server/gateway/routes.ts): `server/src/server/gateway/routes.ts`
- [Scheduled jobs](https://github.com/pi-pod/pipod/blob/main/server/src/server/jobs/routes.ts): `server/src/server/jobs/routes.ts`
- [Pod templates](https://github.com/pi-pod/pipod/blob/main/server/src/server/templates/routes.ts): `server/src/server/templates/routes.ts`
- [Settings](https://github.com/pi-pod/pipod/blob/main/server/src/server/settings/routes.ts): `server/src/server/settings/routes.ts`
- [Postgres](https://github.com/pi-pod/pipod/blob/main/server/src/server/db/index.ts): `server/src/server/db/index.ts`

### Pod runtime

- [Sandbox API](https://github.com/pi-pod/pipod/blob/main/sandbox/src/api/server.ts): `sandbox/src/api/server.ts`
- [Pod manager](https://github.com/pi-pod/pipod/blob/main/sandbox/src/core/manager.ts): `sandbox/src/core/manager.ts`
- [Container runtime](https://github.com/pi-pod/pipod/blob/main/sandbox/src/runtime/crun.ts): `sandbox/src/runtime/crun.ts`
- [Pi shim](https://github.com/pi-pod/pipod/blob/main/server/src/core/shim/pi-pod-ext.ts): `server/src/core/shim/pi-pod-ext.ts`

### Identity

- **Zitadel OIDC**

### Other components

- **User**

## Connections

- User → CLI: uses (evidence: `README.md`)
- User → iOS app: uses (evidence: `README.md`)
- User → Android app: uses (evidence: `README.md`)
- CLI → Server API: requests (evidence: `README.md`)
- iOS app → Server API: requests (evidence: `README.md`)
- Android app → Server API: requests (evidence: `README.md`)
- Server API → Pod lifecycle: registers routes (evidence: `server/src/server/app.ts`)
- Server API → Session gateway: registers routes (evidence: `server/src/server/app.ts`)
- Server API → Scheduled jobs: registers routes (evidence: `server/src/server/app.ts`)
- Server API → Pod templates: registers routes (evidence: `server/src/server/app.ts`)
- Server API → Settings: registers routes (evidence: `server/src/server/app.ts`)
- Server API → Postgres: uses (evidence: `server/src/server/app.ts`)
- Pod lifecycle → Sandbox API: provisions pods (evidence: `README.md`)
- Sandbox API → Pod manager: dispatches requests (evidence: `sandbox/src/api/server.ts`)
- Pod manager → Container runtime: starts containers (evidence: `sandbox/src/core/manager.ts`)
- Session gateway → Pi shim: relays sessions (evidence: `README.md`)
- Pi shim → Container runtime: runs inside pod (evidence: `README.md`)
- CLI → Zitadel OIDC: signs in via (evidence: `README.md`)
- iOS app → Zitadel OIDC: signs in via (evidence: `README.md`)
- Android app → Zitadel OIDC: signs in via (evidence: `README.md`)
