# openplanhq/openplan architecture

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

- Interactive diagram: https://gitdiagram.com/openplanhq/openplan
- Repository: https://github.com/openplanhq/openplan

## Overview

openplan is a self-hosted Terraform/OpenTofu platform: users register Git-backed templates, compose and configure stack instances, then request plans, applies, or destroys and review durable run status and logs. The browser calls the API; the API owns product operations and coordinates durable work through Temporal, while executor workers run Terraform and return artifacts. The graph preserves documented access control, SSO, credentials, upgrades, and run history. Some subsystem links are documented capabilities rather than inspected call sites; these are dashed where wiring was not shown.

Main entry points: [`web/src/api/client.ts`](https://github.com/openplanhq/openplan/blob/main/web/src/api/client.ts) (API client), [`web/src/app/router.tsx`](https://github.com/openplanhq/openplan/blob/main/web/src/app/router.tsx) (Product screens), [`internal/app/service.go`](https://github.com/openplanhq/openplan/blob/main/internal/app/service.go) (Product service), [`internal/activities/template_run.go`](https://github.com/openplanhq/openplan/blob/main/internal/activities/template_run.go) (Run activities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Web application<br/>[main.tsx]"]
  node_routes["Product screens<br/>[router.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
  node_auth_ui["Sign-in and session UI"]
  node_template_ui["Template management"]
  node_stack_ui["Stack management"]
  node_run_ui["Run history and logs"]
end

subgraph group_identity["Identity and access"]
  node_auth["OIDC sessions<br/>[flow.go]"]
  node_authorization["Stack authorization<br/>[authorization.go]"]
  node_dex(("OIDC provider"))
end

subgraph group_control["API and orchestration"]
  node_api["HTTP API<br/>[server.go]"]
  node_service["Product service<br/>[service.go]"]
  node_queue["Work queue<br/>[controller.go]"]
  node_workflows["Temporal workflows<br/>[template_run.go]"]
  node_sync_workflow["Template sync workflow<br/>[template_sync.go]"]
  node_temporal["Temporal service"]
end

subgraph group_execution["Run execution"]
  node_executor["Temporal executor<br/>[main.go]"]
  node_activities["Run activities<br/>[template_run.go]"]
  node_terraform["Terraform/OpenTofu<br/>[terraform.go]"]
  node_git["Git repository"]
end

subgraph group_state["Persistence and artifacts"]
  node_postgres[("PostgreSQL repositories<br/>[repositories.go]")]
  node_artifacts[("Run artifacts<br/>[store.go]")]
end

node_user(("Platform user"))

node_user -->|"uses"| node_webapp
node_webapp -->|"renders"| node_routes
node_routes -->|"routes to"| node_auth_ui
node_routes -->|"routes to"| node_template_ui
node_routes -->|"routes to"| node_stack_ui
node_routes -->|"routes to"| node_run_ui
node_template_ui -.->|"requests"| node_api_client
node_stack_ui -.->|"requests"| node_api_client
node_run_ui -.->|"requests"| node_api_client
node_api_client -.->|"calls"| node_api
node_api -->|"authenticates"| node_auth
node_auth_ui -.->|"signs in through"| node_api_client
node_auth -.->|"verifies identity"| node_dex
node_api -->|"dispatches requests"| node_service
node_service -.->|"checks access"| node_authorization
node_service -.->|"reads and writes"| node_postgres
node_service -->|"enqueues work"| node_queue
node_queue -->|"dispatches workflows"| node_temporal
node_temporal -.->|"runs"| node_workflows
node_temporal -->|"runs"| node_sync_workflow
node_workflows -.->|"schedules execution"| node_executor
node_executor -->|"registers"| node_activities
node_activities -.->|"runs phases"| node_terraform
node_activities -.->|"fetches source"| node_git
node_activities -->|"stores logs and plans"| node_artifacts
node_run_ui -->|"polls run data"| node_api_client
node_artifacts -.->|"provides run logs"| node_api

click node_webapp "https://github.com/openplanhq/openplan/blob/main/web/src/main.tsx"
click node_routes "https://github.com/openplanhq/openplan/blob/main/web/src/app/router.tsx"
click node_api_client "https://github.com/openplanhq/openplan/blob/main/web/src/api/client.ts"
click node_auth_ui "https://github.com/openplanhq/openplan/blob/main/web/src/auth/SessionProvider.tsx"
click node_template_ui "https://github.com/openplanhq/openplan/blob/main/web/src/features/templates/RegisterTemplatePanel.tsx"
click node_stack_ui "https://github.com/openplanhq/openplan/blob/main/web/src/features/stacks/AddStackTemplateScreen.tsx"
click node_run_ui "https://github.com/openplanhq/openplan/blob/main/web/src/features/runs/RunDetailScreen.tsx"
click node_api "https://github.com/openplanhq/openplan/blob/main/internal/api/server.go"
click node_service "https://github.com/openplanhq/openplan/blob/main/internal/app/service.go"
click node_queue "https://github.com/openplanhq/openplan/blob/main/internal/queue/controller.go"
click node_workflows "https://github.com/openplanhq/openplan/blob/main/internal/workflows/template_run.go"
click node_sync_workflow "https://github.com/openplanhq/openplan/blob/main/internal/workflows/template_sync.go"
click node_auth "https://github.com/openplanhq/openplan/blob/main/internal/authentication/flow.go"
click node_authorization "https://github.com/openplanhq/openplan/blob/main/internal/authorization/authorization.go"
click node_executor "https://github.com/openplanhq/openplan/blob/main/cmd/executor/main.go"
click node_activities "https://github.com/openplanhq/openplan/blob/main/internal/activities/template_run.go"
click node_terraform "https://github.com/openplanhq/openplan/blob/main/internal/runner/terraform.go"
click node_postgres "https://github.com/openplanhq/openplan/blob/main/internal/postgres/repositories.go"
click node_artifacts "https://github.com/openplanhq/openplan/blob/main/internal/artifacts/store.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_webapp,node_routes,node_api_client,node_auth_ui,node_template_ui,node_stack_ui,node_run_ui,node_user toneBlue
class node_auth,node_authorization,node_dex toneAmber
class node_api,node_service,node_queue,node_workflows,node_sync_workflow,node_temporal toneMint
class node_executor,node_activities,node_terraform,node_git toneRose
class node_postgres,node_artifacts toneIndigo
```

## Components

### Web experience

- [Web application](https://github.com/openplanhq/openplan/blob/main/web/src/main.tsx): `web/src/main.tsx`
- [Product screens](https://github.com/openplanhq/openplan/blob/main/web/src/app/router.tsx): `web/src/app/router.tsx`
- [API client](https://github.com/openplanhq/openplan/blob/main/web/src/api/client.ts): `web/src/api/client.ts`
- [Sign-in and session UI](https://github.com/openplanhq/openplan/blob/main/web/src/auth/SessionProvider.tsx): `web/src/auth/SessionProvider.tsx`
- [Template management](https://github.com/openplanhq/openplan/blob/main/web/src/features/templates/RegisterTemplatePanel.tsx): `web/src/features/templates/RegisterTemplatePanel.tsx`
- [Stack management](https://github.com/openplanhq/openplan/blob/main/web/src/features/stacks/AddStackTemplateScreen.tsx): `web/src/features/stacks/AddStackTemplateScreen.tsx`
- [Run history and logs](https://github.com/openplanhq/openplan/blob/main/web/src/features/runs/RunDetailScreen.tsx): `web/src/features/runs/RunDetailScreen.tsx`

### Identity and access

- [OIDC sessions](https://github.com/openplanhq/openplan/blob/main/internal/authentication/flow.go): `internal/authentication/flow.go`
- [Stack authorization](https://github.com/openplanhq/openplan/blob/main/internal/authorization/authorization.go): `internal/authorization/authorization.go`
- **OIDC provider**

### API and orchestration

- [HTTP API](https://github.com/openplanhq/openplan/blob/main/internal/api/server.go): `internal/api/server.go`
- [Product service](https://github.com/openplanhq/openplan/blob/main/internal/app/service.go): `internal/app/service.go`
- [Work queue](https://github.com/openplanhq/openplan/blob/main/internal/queue/controller.go): `internal/queue/controller.go`
- [Temporal workflows](https://github.com/openplanhq/openplan/blob/main/internal/workflows/template_run.go): `internal/workflows/template_run.go`
- [Template sync workflow](https://github.com/openplanhq/openplan/blob/main/internal/workflows/template_sync.go): `internal/workflows/template_sync.go`
- **Temporal service**

### Run execution

- [Temporal executor](https://github.com/openplanhq/openplan/blob/main/cmd/executor/main.go): `cmd/executor/main.go`
- [Run activities](https://github.com/openplanhq/openplan/blob/main/internal/activities/template_run.go): `internal/activities/template_run.go`
- [Terraform/OpenTofu](https://github.com/openplanhq/openplan/blob/main/internal/runner/terraform.go): `internal/runner/terraform.go`
- **Git repository**

### Persistence and artifacts

- [PostgreSQL repositories](https://github.com/openplanhq/openplan/blob/main/internal/postgres/repositories.go): `internal/postgres/repositories.go`
- [Run artifacts](https://github.com/openplanhq/openplan/blob/main/internal/artifacts/store.go): `internal/artifacts/store.go`

### Other components

- **Platform user**

## Connections

- Platform user → Web application: uses (evidence: `README.md`)
- Web application → Product screens: renders (evidence: `web/src/main.tsx`)
- Product screens → Sign-in and session UI: routes to (evidence: `web/src/app/router.tsx`)
- Product screens → Template management: routes to (evidence: `web/src/app/router.tsx`)
- Product screens → Stack management: routes to (evidence: `web/src/app/router.tsx`)
- Product screens → Run history and logs: routes to (evidence: `web/src/app/router.tsx`)
- Template management → API client: requests
- Stack management → API client: requests
- Run history and logs → API client: requests
- API client → HTTP API: calls
- HTTP API → OIDC sessions: authenticates (evidence: `internal/api/server.go`)
- Sign-in and session UI → API client: signs in through
- OIDC sessions → OIDC provider: verifies identity (evidence: `README.md`)
- HTTP API → Product service: dispatches requests (evidence: `internal/api/server.go`)
- Product service → Stack authorization: checks access (evidence: `README.md`)
- Product service → PostgreSQL repositories: reads and writes
- Product service → Work queue: enqueues work (evidence: `internal/app/service.go`)
- Work queue → Temporal service: dispatches workflows
- Temporal service → Temporal workflows: runs
- Temporal service → Template sync workflow: runs
- Temporal workflows → Temporal executor: schedules execution (evidence: `README.md`)
- Temporal executor → Run activities: registers (evidence: `cmd/executor/main.go`)
- Run activities → Terraform/OpenTofu: runs phases (evidence: `README.md`)
- Run activities → Git repository: fetches source (evidence: `README.md`)
- Run activities → Run artifacts: stores logs and plans
- Run history and logs → API client: polls run data
- Run artifacts → HTTP API: provides run logs
