# rasidi3112/pondok-ai architecture

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

- Interactive diagram: https://gitdiagram.com/rasidi3112/pondok-ai
- Repository: https://github.com/rasidi3112/pondok-ai

## Overview

pondok-ai is a CLI for configuring and operating a private, local AI stack, plus an OpenAI-compatible API gateway included in the standard/full presets. The main workflow is initialize a preset using hardware checks, generate configuration and Compose files, start and monitor Docker services, then manage models or share Open WebUI on a LAN. README capabilities also include diagnostics, lifecycle operations, updates, and integrity-checked backup/restore. Gateway route internals and several command implementations were not excerpted; those branches are documented at subsystem level, with links omitted where call ownership was not visible.

Main entry points: [`src/cli/program.ts`](https://github.com/rasidi3112/pondok-ai/blob/main/src/cli/program.ts) (CLI commands), [`src/commands/init.ts`](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/init.ts) (Initialize stack), [`api/src/app.ts`](https://github.com/rasidi3112/pondok-ai/blob/main/api/src/app.ts) (Gateway server), [`src/docker/client.ts`](https://github.com/rasidi3112/pondok-ai/blob/main/src/docker/client.ts) (Docker control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and operations"]
  node_program["CLI commands<br/>[program.ts]"]
  node_initialize["Initialize stack<br/>[init.ts]"]
  node_operations["Lifecycle and status<br/>[up.ts]"]
  node_diagnostics["Diagnostics<br/>[doctor.ts]"]
  node_models["Model management<br/>[model.ts]"]
  node_sharing["LAN sharing<br/>[share.ts]"]
  node_backup["Backup and restore<br/>[backup.ts]"]
  node_update["Stack updates<br/>[update.ts]"]
end

subgraph group_config["Configuration and hardware"]
  node_hardware["Hardware detection<br/>[detect.ts]"]
  node_recommend["Model recommendations<br/>[recommendations.ts]"]
  node_configmanager["Config and credentials<br/>[manager.ts]"]
  node_presets["Preset definitions<br/>[defaults.ts]"]
end

subgraph group_runtime["Stack runtime"]
  node_compose["Compose generation<br/>[compose.ts]"]
  node_docker["Docker control<br/>[client.ts]"]
  node_health["Service health<br/>[health.ts]"]
  node_ollama["Native Ollama support<br/>[ollama-native.ts]"]
  node_stack["Local AI services"]
  node_openwebui["Open WebUI"]
  node_exec["Process execution<br/>[exec.ts]"]
end

subgraph group_gateway["API gateway"]
  node_gatewayapp["Gateway server<br/>[app.ts]"]
  node_chatroute["Chat endpoint<br/>[chat.ts]"]
  node_embeddingroute["Embeddings endpoint<br/>[embeddings.ts]"]
  node_modelroute["Models endpoint<br/>[models.ts]"]
  node_upstream["Ollama upstream<br/>[upstream.ts]"]
end

node_user(("Operator"))
node_sdk(("OpenAI-compatible clients"))

node_user -->|"runs"| node_program
node_program -->|"registers"| node_initialize
node_program -->|"registers"| node_operations
node_program -->|"registers"| node_diagnostics
node_program -->|"registers"| node_models
node_program -->|"registers"| node_sharing
node_program -->|"registers"| node_backup
node_program -->|"registers"| node_update
node_initialize -->|"detects"| node_hardware
node_initialize -->|"configures"| node_configmanager
node_initialize -->|"uses"| node_presets
node_initialize -->|"generates"| node_compose
node_initialize -.->|"prepares"| node_stack
node_operations -.->|"controls"| node_docker
node_operations -.->|"checks health"| node_health
node_diagnostics -.->|"checks system"| node_hardware
node_models -->|"requests advice"| node_recommend
node_models -->|"manages models"| node_docker
node_recommend -->|"uses detection"| node_hardware
node_sharing -->|"loads config"| node_configmanager
node_sharing -->|"checks stack"| node_docker
node_sharing -.->|"enables access"| node_openwebui
node_backup -->|"backs up config"| node_configmanager
node_backup -->|"archives volumes"| node_exec
node_update -->|"updates services"| node_docker
node_compose -->|"uses defaults"| node_presets
node_compose -->|"resolves runtime"| node_ollama
node_docker -->|"runs commands"| node_exec
node_stack -.->|"includes UI"| node_openwebui
node_stack -.->|"includes gateway"| node_gatewayapp
node_sdk -->|"calls API"| node_gatewayapp
node_gatewayapp -->|"routes requests"| node_chatroute
node_gatewayapp -->|"routes requests"| node_embeddingroute
node_gatewayapp -->|"routes requests"| node_modelroute
node_chatroute -->|"forwards inference"| node_upstream
node_embeddingroute -->|"forwards embeddings"| node_upstream
node_modelroute -->|"queries models"| node_upstream

click node_program "https://github.com/rasidi3112/pondok-ai/blob/main/src/cli/program.ts"
click node_initialize "https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/init.ts"
click node_operations "https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/up.ts"
click node_diagnostics "https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/doctor.ts"
click node_models "https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/model.ts"
click node_sharing "https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/share.ts"
click node_backup "https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/backup.ts"
click node_update "https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/update.ts"
click node_hardware "https://github.com/rasidi3112/pondok-ai/blob/main/src/system/detect.ts"
click node_recommend "https://github.com/rasidi3112/pondok-ai/blob/main/src/system/recommendations.ts"
click node_configmanager "https://github.com/rasidi3112/pondok-ai/blob/main/src/config/manager.ts"
click node_presets "https://github.com/rasidi3112/pondok-ai/blob/main/src/config/defaults.ts"
click node_compose "https://github.com/rasidi3112/pondok-ai/blob/main/src/docker/compose.ts"
click node_docker "https://github.com/rasidi3112/pondok-ai/blob/main/src/docker/client.ts"
click node_health "https://github.com/rasidi3112/pondok-ai/blob/main/src/docker/health.ts"
click node_ollama "https://github.com/rasidi3112/pondok-ai/blob/main/src/system/ollama-native.ts"
click node_gatewayapp "https://github.com/rasidi3112/pondok-ai/blob/main/api/src/app.ts"
click node_chatroute "https://github.com/rasidi3112/pondok-ai/blob/main/api/src/routes/chat.ts"
click node_embeddingroute "https://github.com/rasidi3112/pondok-ai/blob/main/api/src/routes/embeddings.ts"
click node_modelroute "https://github.com/rasidi3112/pondok-ai/blob/main/api/src/routes/models.ts"
click node_upstream "https://github.com/rasidi3112/pondok-ai/blob/main/api/src/upstream.ts"
click node_exec "https://github.com/rasidi3112/pondok-ai/blob/main/src/utils/exec.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_program,node_initialize,node_operations,node_diagnostics,node_models,node_sharing,node_backup,node_update,node_sdk toneBlue
class node_hardware,node_recommend,node_configmanager,node_presets toneAmber
class node_compose,node_docker,node_health,node_ollama,node_stack,node_openwebui,node_exec toneMint
class node_gatewayapp,node_chatroute,node_embeddingroute,node_modelroute,node_upstream toneRose
class node_user toneIndigo
```

## Components

### CLI and operations

- [CLI commands](https://github.com/rasidi3112/pondok-ai/blob/main/src/cli/program.ts): `src/cli/program.ts`
- [Initialize stack](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/init.ts): `src/commands/init.ts`
- [Lifecycle and status](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/up.ts): `src/commands/up.ts`
- [Diagnostics](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/doctor.ts): `src/commands/doctor.ts`
- [Model management](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/model.ts): `src/commands/model.ts`
- [LAN sharing](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/share.ts): `src/commands/share.ts`
- [Backup and restore](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/backup.ts): `src/commands/backup.ts`
- [Stack updates](https://github.com/rasidi3112/pondok-ai/blob/main/src/commands/update.ts): `src/commands/update.ts`

### Configuration and hardware

- [Hardware detection](https://github.com/rasidi3112/pondok-ai/blob/main/src/system/detect.ts): `src/system/detect.ts`
- [Model recommendations](https://github.com/rasidi3112/pondok-ai/blob/main/src/system/recommendations.ts): `src/system/recommendations.ts`
- [Config and credentials](https://github.com/rasidi3112/pondok-ai/blob/main/src/config/manager.ts): `src/config/manager.ts`
- [Preset definitions](https://github.com/rasidi3112/pondok-ai/blob/main/src/config/defaults.ts): `src/config/defaults.ts`

### Stack runtime

- [Compose generation](https://github.com/rasidi3112/pondok-ai/blob/main/src/docker/compose.ts): `src/docker/compose.ts`
- [Docker control](https://github.com/rasidi3112/pondok-ai/blob/main/src/docker/client.ts): `src/docker/client.ts`
- [Service health](https://github.com/rasidi3112/pondok-ai/blob/main/src/docker/health.ts): `src/docker/health.ts`
- [Native Ollama support](https://github.com/rasidi3112/pondok-ai/blob/main/src/system/ollama-native.ts): `src/system/ollama-native.ts`
- **Local AI services**
- **Open WebUI**
- [Process execution](https://github.com/rasidi3112/pondok-ai/blob/main/src/utils/exec.ts): `src/utils/exec.ts`

### API gateway

- [Gateway server](https://github.com/rasidi3112/pondok-ai/blob/main/api/src/app.ts): `api/src/app.ts`
- [Chat endpoint](https://github.com/rasidi3112/pondok-ai/blob/main/api/src/routes/chat.ts): `api/src/routes/chat.ts`
- [Embeddings endpoint](https://github.com/rasidi3112/pondok-ai/blob/main/api/src/routes/embeddings.ts): `api/src/routes/embeddings.ts`
- [Models endpoint](https://github.com/rasidi3112/pondok-ai/blob/main/api/src/routes/models.ts): `api/src/routes/models.ts`
- [Ollama upstream](https://github.com/rasidi3112/pondok-ai/blob/main/api/src/upstream.ts): `api/src/upstream.ts`

### Other components

- **Operator**
- **OpenAI-compatible clients**

## Connections

- Operator → CLI commands: runs (evidence: `src/cli/program.ts`)
- CLI commands → Initialize stack: registers (evidence: `src/cli/program.ts`)
- CLI commands → Lifecycle and status: registers (evidence: `src/cli/program.ts`)
- CLI commands → Diagnostics: registers (evidence: `src/cli/program.ts`)
- CLI commands → Model management: registers (evidence: `src/cli/program.ts`)
- CLI commands → LAN sharing: registers (evidence: `src/cli/program.ts`)
- CLI commands → Backup and restore: registers (evidence: `src/cli/program.ts`)
- CLI commands → Stack updates: registers (evidence: `src/cli/program.ts`)
- Initialize stack → Hardware detection: detects (evidence: `src/commands/init.ts`)
- Initialize stack → Config and credentials: configures (evidence: `src/commands/init.ts`)
- Initialize stack → Preset definitions: uses (evidence: `src/commands/init.ts`)
- Initialize stack → Compose generation: generates (evidence: `src/commands/init.ts`)
- Initialize stack → Local AI services: prepares (evidence: `README.md`)
- Lifecycle and status → Docker control: controls (evidence: `README.md`)
- Lifecycle and status → Service health: checks health (evidence: `README.md`)
- Diagnostics → Hardware detection: checks system (evidence: `README.md`)
- Model management → Model recommendations: requests advice (evidence: `src/commands/model.ts`)
- Model management → Docker control: manages models (evidence: `src/commands/model.ts`)
- Model recommendations → Hardware detection: uses detection (evidence: `src/system/recommendations.ts`)
- LAN sharing → Config and credentials: loads config (evidence: `src/commands/share.ts`)
- LAN sharing → Docker control: checks stack (evidence: `src/commands/share.ts`)
- LAN sharing → Open WebUI: enables access (evidence: `README.md`)
- Backup and restore → Config and credentials: backs up config (evidence: `src/commands/backup.ts`)
- Backup and restore → Process execution: archives volumes (evidence: `src/commands/backup.ts`)
- Stack updates → Docker control: updates services (evidence: `src/commands/update.ts`)
- Compose generation → Preset definitions: uses defaults (evidence: `src/docker/compose.ts`)
- Compose generation → Native Ollama support: resolves runtime (evidence: `src/docker/compose.ts`)
- Docker control → Process execution: runs commands (evidence: `src/docker/client.ts`)
- Local AI services → Open WebUI: includes UI (evidence: `README.md`)
- Local AI services → Gateway server: includes gateway (evidence: `README.md`)
- OpenAI-compatible clients → Gateway server: calls API (evidence: `README.md`)
- Gateway server → Chat endpoint: routes requests (evidence: `api/src/app.ts`)
- Gateway server → Embeddings endpoint: routes requests (evidence: `api/src/app.ts`)
- Gateway server → Models endpoint: routes requests (evidence: `api/src/app.ts`)
- Chat endpoint → Ollama upstream: forwards inference (evidence: `api/src/routes/chat.ts`)
- Embeddings endpoint → Ollama upstream: forwards embeddings (evidence: `api/src/routes/embeddings.ts`)
- Models endpoint → Ollama upstream: queries models (evidence: `api/src/routes/models.ts`)
