# evanxdsouza/mangrove architecture

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

- Interactive diagram: https://gitdiagram.com/evanxdsouza/mangrove
- Repository: https://github.com/evanxdsouza/mangrove

## Overview

Mangrove is a self-hosted PaaS control plane. A user creates or links a project, configures a deployment from Git, a Dockerfile, Compose, an image, or a template, then Mangrove builds/runs it, health-checks it, and routes traffic through Caddy; GitHub pushes and pull requests can trigger redeploys and previews. The graph also preserves major product branches: auth/workspaces, deployment management, templates, terminal, and optional NAS storage. Some subsystem links are documented capabilities rather than sampled call sites; those are dashed where implementation wiring was not shown.

Main entry points: [`internal/api/router.go`](https://github.com/evanxdsouza/mangrove/blob/main/internal/api/router.go) (HTTP API), [`internal/orchestrator/deploy.go`](https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/deploy.go) (Deploy orchestration), [`internal/executor/docker.go`](https://github.com/evanxdsouza/mangrove/blob/main/internal/executor/docker.go) (Container executor), [`internal/orchestrator/storage.go`](https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/storage.go) (NAS orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients"]
  node_dashboard["Dashboard"]
  node_webapi["Web API client<br/>[api.ts]"]
  node_cli["CLI<br/>[main.go]"]
  node_tui["Terminal UI<br/>[main.go]"]
  node_mcp["MCP server<br/>[main.go]"]
end

subgraph group_control["Control plane"]
  node_daemon["Control daemon<br/>[main.go]"]
  node_api["HTTP API<br/>[router.go]"]
  node_auth["Session and access<br/>[session.go]"]
end

subgraph group_deploy["Deployment runtime"]
  node_orchestrator["Deploy orchestration<br/>[deploy.go]"]
  node_executor["Container executor<br/>[docker.go]"]
  node_proxy["Traffic proxy<br/>[caddy.go]"]
  node_scheduler["Health and lifecycle jobs<br/>[health.go]"]
  node_templates["App templates<br/>[templates.go]"]
  node_terminal["Interactive terminal<br/>[terminal.go]"]
end

subgraph group_integrations["Integrations"]
  node_githubwebhook["GitHub webhooks<br/>[webhook.go]"]
  node_github["GitHub integration<br/>[oauth.go]"]
  node_notify["Email notifications<br/>[resend.go]"]
  node_mountapi["Storage API<br/>[storage.go]"]
  node_nas["NAS orchestration<br/>[storage.go]"]
  node_mountclient["Mount helper client<br/>[client.go]"]
  node_mountd["Privileged mount helper<br/>[main.go]"]
end

subgraph group_state["State and storage"]
  node_store[("SQLite store<br/>[store.go]")]
  node_models["Domain models<br/>[models.go]"]
end

node_user(("Operator"))
node_drive[("Host drive")]
node_smb(("LAN SMB clients"))
node_caddy["Caddy"]
node_docker["Docker"]
node_githubservice["GitHub"]

node_user -->|"operates"| node_dashboard
node_dashboard -->|"requests"| node_webapi
node_webapi -.->|"calls HTTP"| node_api
node_cli -.->|"calls HTTP"| node_api
node_tui -.->|"calls HTTP"| node_api
node_mcp -->|"calls HTTP"| node_api
node_daemon -->|"configures"| node_api
node_api -->|"requires sessions"| node_auth
node_api -.->|"reads and writes"| node_store
node_api -->|"dispatches deploys"| node_orchestrator
node_githubwebhook -->|"triggers deploys"| node_orchestrator
node_githubwebhook -->|"records deliveries"| node_store
node_githubservice -.->|"sends events"| node_githubwebhook
node_orchestrator -.->|"runs containers"| node_executor
node_executor -->|"controls"| node_docker
node_orchestrator -.->|"configures routes"| node_proxy
node_proxy -->|"uses admin API"| node_caddy
node_scheduler -->|"reaps previews"| node_orchestrator
node_daemon -->|"starts jobs"| node_scheduler
node_orchestrator -.->|"persists state"| node_store
node_store -->|"stores records"| node_models
node_templates -.->|"deploys templates"| node_executor
node_api -.->|"supports OAuth"| node_github
node_terminal -.->|"opens container shell"| node_executor
node_orchestrator -.->|"sends results"| node_notify
node_dashboard -->|"manages drives"| node_mountapi
node_mountapi -->|"creates shares"| node_nas
node_nas -->|"requests mounts"| node_mountclient
node_mountclient -.->|"uses Unix socket"| node_mountd
node_mountd -->|"mounts drive"| node_drive
node_nas -->|"runs SMB service"| node_executor
node_smb -.->|"connects over LAN"| node_nas

click node_dashboard "https://github.com/evanxdsouza/mangrove/blob/main/web/src/lib/pages/ProjectsPage.svelte"
click node_webapi "https://github.com/evanxdsouza/mangrove/blob/main/web/src/lib/api.ts"
click node_cli "https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrovectl/main.go"
click node_tui "https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove-tui/main.go"
click node_mcp "https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove-mcp/main.go"
click node_daemon "https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove/main.go"
click node_api "https://github.com/evanxdsouza/mangrove/blob/main/internal/api/router.go"
click node_auth "https://github.com/evanxdsouza/mangrove/blob/main/internal/auth/session.go"
click node_githubwebhook "https://github.com/evanxdsouza/mangrove/blob/main/internal/api/webhook.go"
click node_orchestrator "https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/deploy.go"
click node_executor "https://github.com/evanxdsouza/mangrove/blob/main/internal/executor/docker.go"
click node_proxy "https://github.com/evanxdsouza/mangrove/blob/main/internal/proxy/caddy.go"
click node_scheduler "https://github.com/evanxdsouza/mangrove/blob/main/internal/scheduler/health.go"
click node_templates "https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/templates.go"
click node_terminal "https://github.com/evanxdsouza/mangrove/blob/main/internal/api/terminal.go"
click node_github "https://github.com/evanxdsouza/mangrove/blob/main/internal/github/oauth.go"
click node_notify "https://github.com/evanxdsouza/mangrove/blob/main/internal/notify/resend.go"
click node_store "https://github.com/evanxdsouza/mangrove/blob/main/internal/store/store.go"
click node_models "https://github.com/evanxdsouza/mangrove/blob/main/internal/models/models.go"
click node_mountapi "https://github.com/evanxdsouza/mangrove/blob/main/internal/api/storage.go"
click node_nas "https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/storage.go"
click node_mountclient "https://github.com/evanxdsouza/mangrove/blob/main/internal/mountd/client.go"
click node_mountd "https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove-mountd/main.go"

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_dashboard,node_webapi,node_cli,node_tui,node_mcp,node_smb toneBlue
class node_daemon,node_api,node_auth,node_drive toneAmber
class node_orchestrator,node_executor,node_proxy,node_scheduler,node_templates,node_terminal toneMint
class node_githubwebhook,node_github,node_notify,node_mountapi,node_nas,node_mountclient,node_mountd toneRose
class node_store,node_models,node_user,node_caddy,node_docker,node_githubservice toneIndigo
```

## Components

### Clients

- [Dashboard](https://github.com/evanxdsouza/mangrove/blob/main/web/src/lib/pages/ProjectsPage.svelte): `web/src/lib/pages/ProjectsPage.svelte`
- [Web API client](https://github.com/evanxdsouza/mangrove/blob/main/web/src/lib/api.ts): `web/src/lib/api.ts`
- [CLI](https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrovectl/main.go): `cmd/mangrovectl/main.go`
- [Terminal UI](https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove-tui/main.go): `cmd/mangrove-tui/main.go`
- [MCP server](https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove-mcp/main.go): `cmd/mangrove-mcp/main.go`

### Control plane

- [Control daemon](https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove/main.go): `cmd/mangrove/main.go`
- [HTTP API](https://github.com/evanxdsouza/mangrove/blob/main/internal/api/router.go): `internal/api/router.go`
- [Session and access](https://github.com/evanxdsouza/mangrove/blob/main/internal/auth/session.go): `internal/auth/session.go`

### Deployment runtime

- [Deploy orchestration](https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/deploy.go): `internal/orchestrator/deploy.go`
- [Container executor](https://github.com/evanxdsouza/mangrove/blob/main/internal/executor/docker.go): `internal/executor/docker.go`
- [Traffic proxy](https://github.com/evanxdsouza/mangrove/blob/main/internal/proxy/caddy.go): `internal/proxy/caddy.go`
- [Health and lifecycle jobs](https://github.com/evanxdsouza/mangrove/blob/main/internal/scheduler/health.go): `internal/scheduler/health.go`
- [App templates](https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/templates.go): `internal/orchestrator/templates.go`
- [Interactive terminal](https://github.com/evanxdsouza/mangrove/blob/main/internal/api/terminal.go): `internal/api/terminal.go`

### Integrations

- [GitHub webhooks](https://github.com/evanxdsouza/mangrove/blob/main/internal/api/webhook.go): `internal/api/webhook.go`
- [GitHub integration](https://github.com/evanxdsouza/mangrove/blob/main/internal/github/oauth.go): `internal/github/oauth.go`
- [Email notifications](https://github.com/evanxdsouza/mangrove/blob/main/internal/notify/resend.go): `internal/notify/resend.go`
- [Storage API](https://github.com/evanxdsouza/mangrove/blob/main/internal/api/storage.go): `internal/api/storage.go`
- [NAS orchestration](https://github.com/evanxdsouza/mangrove/blob/main/internal/orchestrator/storage.go): `internal/orchestrator/storage.go`
- [Mount helper client](https://github.com/evanxdsouza/mangrove/blob/main/internal/mountd/client.go): `internal/mountd/client.go`
- [Privileged mount helper](https://github.com/evanxdsouza/mangrove/blob/main/cmd/mangrove-mountd/main.go): `cmd/mangrove-mountd/main.go`

### State and storage

- [SQLite store](https://github.com/evanxdsouza/mangrove/blob/main/internal/store/store.go): `internal/store/store.go`
- [Domain models](https://github.com/evanxdsouza/mangrove/blob/main/internal/models/models.go): `internal/models/models.go`

### Other components

- **Operator**
- **Host drive**
- **LAN SMB clients**
- **Caddy**
- **Docker**
- **GitHub**

## Connections

- Operator → Dashboard: operates
- Dashboard → Web API client: requests (evidence: `web/src/lib/api.ts`)
- Web API client → HTTP API: calls HTTP
- CLI → HTTP API: calls HTTP
- Terminal UI → HTTP API: calls HTTP (evidence: `cmd/mangrove-tui/main.go`)
- MCP server → HTTP API: calls HTTP (evidence: `cmd/mangrove-mcp/main.go`)
- Control daemon → HTTP API: configures (evidence: `cmd/mangrove/main.go`)
- HTTP API → Session and access: requires sessions (evidence: `internal/api/router.go`)
- HTTP API → SQLite store: reads and writes
- HTTP API → Deploy orchestration: dispatches deploys
- GitHub webhooks → Deploy orchestration: triggers deploys (evidence: `internal/api/webhook.go`)
- GitHub webhooks → SQLite store: records deliveries (evidence: `internal/api/webhook.go`)
- GitHub → GitHub webhooks: sends events
- Deploy orchestration → Container executor: runs containers
- Container executor → Docker: controls
- Deploy orchestration → Traffic proxy: configures routes
- Traffic proxy → Caddy: uses admin API
- Health and lifecycle jobs → Deploy orchestration: reaps previews
- Control daemon → Health and lifecycle jobs: starts jobs (evidence: `cmd/mangrove/main.go`)
- Deploy orchestration → SQLite store: persists state
- SQLite store → Domain models: stores records (evidence: `internal/store/store.go`)
- App templates → Container executor: deploys templates
- HTTP API → GitHub integration: supports OAuth (evidence: `internal/api/router.go`)
- Interactive terminal → Container executor: opens container shell
- Deploy orchestration → Email notifications: sends results
- Dashboard → Storage API: manages drives
- Storage API → NAS orchestration: creates shares (evidence: `internal/api/storage.go`)
- NAS orchestration → Mount helper client: requests mounts (evidence: `internal/orchestrator/storage.go`)
- Mount helper client → Privileged mount helper: uses Unix socket (evidence: `cmd/mangrove-mountd/main.go`)
- Privileged mount helper → Host drive: mounts drive (evidence: `cmd/mangrove-mountd/main.go`)
- NAS orchestration → Container executor: runs SMB service (evidence: `internal/orchestrator/storage.go`)
- LAN SMB clients → NAS orchestration: connects over LAN
