# rajkp10/orchestration architecture

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

- Interactive diagram: https://gitdiagram.com/rajkp10/orchestration
- Repository: https://github.com/rajkp10/orchestration

## Overview

This is an event-driven infrastructure orchestrator for PostgreSQL lifecycle changes. A caller submits a lifecycle event through the trigger, which parses it and starts a Temporal workflow; the workflow validates the request, applies Terraform changes, verifies the live resource, and reports a result. Activities resolve a platform adapter and use per-resource Terraform workspaces. The README documents provision, patch, decommission, duplicate handling, status queries, and failure outcomes. Some implementation details are unsampled; edges below are limited to shown calls or documented behavior.

Main entry points: [`orchestrator/workflow.py`](https://github.com/rajkp10/orchestration/blob/main/orchestrator/workflow.py) (Lifecycle workflow), [`orchestrator/platforms/postgres.py`](https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/postgres.py) (Live verification), [`orchestrator/trigger.py`](https://github.com/rajkp10/orchestration/blob/main/orchestrator/trigger.py) (Trigger CLI), [`orchestrator/activities.py`](https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py) (Terraform activity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Event entry"]
  node_trigger["Trigger CLI<br/>[trigger.py]"]
  node_event_parser["Event parser<br/>[events.py]"]
  node_event_model["Lifecycle models<br/>[models.py]"]
  node_result_record["Result JSON record<br/>[config.py]"]
end

subgraph group_temporal["Temporal orchestration"]
  node_temporal_service(("Temporal service"))
  node_workflow["Lifecycle workflow<br/>[workflow.py]"]
  node_worker["Temporal worker<br/>[worker.py]"]
  node_activities["Activity dispatch<br/>[activities.py]"]
  node_result_report["Result reporting<br/>[activities.py]"]
end

subgraph group_platform["Platform lifecycle"]
  node_validation["Request validation<br/>[activities.py]"]
  node_platform_registry["Adapter registry<br/>[registry.py]"]
  node_adapter_contract["Adapter contract<br/>[base.py]"]
  node_postgres_adapter["Postgres lifecycle<br/>[postgres.py]"]
  node_verification["Live verification<br/>[postgres.py]"]
end

subgraph group_infra["Infrastructure execution"]
  node_terraform_activity["Terraform activity<br/>[activities.py]"]
  node_terraform_runner["Terraform runner<br/>[runner.py]"]
  node_error_classifier["Error classifier<br/>[classifier.py]"]
  node_postgres_module["Postgres module<br/>[main.tf]"]
end

node_caller(("Event caller"))
node_docker(("Docker engine"))
node_postgres_container[("Postgres container")]

node_caller -->|"submits event"| node_trigger
node_trigger -->|"parses event"| node_event_parser
node_trigger -->|"starts workflow"| node_temporal_service
node_trigger -->|"starts"| node_workflow
node_trigger -->|"queries status"| node_workflow
node_worker -->|"connects to"| node_temporal_service
node_worker -->|"registers"| node_workflow
node_worker -->|"registers"| node_activities
node_workflow -->|"executes"| node_validation
node_workflow -->|"executes"| node_terraform_activity
node_workflow -->|"executes"| node_verification
node_workflow -->|"reports outcome"| node_result_report
node_validation -->|"resolves adapter"| node_platform_registry
node_terraform_activity -->|"resolves adapter"| node_platform_registry
node_verification -->|"resolves adapter"| node_platform_registry
node_platform_registry -->|"registers"| node_postgres_adapter
node_platform_registry -->|"uses contract"| node_adapter_contract
node_validation -->|"validates request"| node_postgres_adapter
node_terraform_activity -->|"builds variables"| node_postgres_adapter
node_verification -->|"checks resource"| node_postgres_adapter
node_validation -->|"reads state"| node_terraform_runner
node_terraform_activity -->|"applies or destroys"| node_terraform_runner
node_verification -->|"reads outputs"| node_terraform_runner
node_terraform_runner -->|"classifies errors"| node_error_classifier
node_terraform_activity -->|"selects module"| node_postgres_module
node_postgres_module -->|"manages containers"| node_docker
node_docker -->|"hosts"| node_postgres_container
node_verification -->|"checks live database"| node_postgres_container
node_verification -->|"checks removal"| node_docker
node_result_report -->|"writes result"| node_result_record

click node_trigger "https://github.com/rajkp10/orchestration/blob/main/orchestrator/trigger.py"
click node_event_parser "https://github.com/rajkp10/orchestration/blob/main/orchestrator/events.py"
click node_event_model "https://github.com/rajkp10/orchestration/blob/main/orchestrator/models.py"
click node_workflow "https://github.com/rajkp10/orchestration/blob/main/orchestrator/workflow.py"
click node_worker "https://github.com/rajkp10/orchestration/blob/main/orchestrator/worker.py"
click node_activities "https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py"
click node_validation "https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py"
click node_platform_registry "https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/registry.py"
click node_adapter_contract "https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/base.py"
click node_postgres_adapter "https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/postgres.py"
click node_verification "https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/postgres.py"
click node_terraform_activity "https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py"
click node_terraform_runner "https://github.com/rajkp10/orchestration/blob/main/orchestrator/terraform/runner.py"
click node_error_classifier "https://github.com/rajkp10/orchestration/blob/main/orchestrator/terraform/classifier.py"
click node_postgres_module "https://github.com/rajkp10/orchestration/blob/main/terraform/modules/postgres/main.tf"
click node_result_report "https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py"
click node_result_record "https://github.com/rajkp10/orchestration/blob/main/orchestrator/config.py"

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_trigger,node_event_parser,node_event_model,node_result_record toneBlue
class node_temporal_service,node_workflow,node_worker,node_activities,node_result_report,node_postgres_container toneAmber
class node_validation,node_platform_registry,node_adapter_contract,node_postgres_adapter,node_verification toneMint
class node_terraform_activity,node_terraform_runner,node_error_classifier,node_postgres_module toneRose
class node_caller,node_docker toneIndigo
```

## Components

### Event entry

- [Trigger CLI](https://github.com/rajkp10/orchestration/blob/main/orchestrator/trigger.py): `orchestrator/trigger.py`
- [Event parser](https://github.com/rajkp10/orchestration/blob/main/orchestrator/events.py): `orchestrator/events.py`
- [Lifecycle models](https://github.com/rajkp10/orchestration/blob/main/orchestrator/models.py): `orchestrator/models.py`
- [Result JSON record](https://github.com/rajkp10/orchestration/blob/main/orchestrator/config.py): `orchestrator/config.py`

### Temporal orchestration

- **Temporal service**
- [Lifecycle workflow](https://github.com/rajkp10/orchestration/blob/main/orchestrator/workflow.py): `orchestrator/workflow.py`
- [Temporal worker](https://github.com/rajkp10/orchestration/blob/main/orchestrator/worker.py): `orchestrator/worker.py`
- [Activity dispatch](https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py): `orchestrator/activities.py`
- [Result reporting](https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py): `orchestrator/activities.py`

### Platform lifecycle

- [Request validation](https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py): `orchestrator/activities.py`
- [Adapter registry](https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/registry.py): `orchestrator/platforms/registry.py`
- [Adapter contract](https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/base.py): `orchestrator/platforms/base.py`
- [Postgres lifecycle](https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/postgres.py): `orchestrator/platforms/postgres.py`
- [Live verification](https://github.com/rajkp10/orchestration/blob/main/orchestrator/platforms/postgres.py): `orchestrator/platforms/postgres.py`

### Infrastructure execution

- [Terraform activity](https://github.com/rajkp10/orchestration/blob/main/orchestrator/activities.py): `orchestrator/activities.py`
- [Terraform runner](https://github.com/rajkp10/orchestration/blob/main/orchestrator/terraform/runner.py): `orchestrator/terraform/runner.py`
- [Error classifier](https://github.com/rajkp10/orchestration/blob/main/orchestrator/terraform/classifier.py): `orchestrator/terraform/classifier.py`
- [Postgres module](https://github.com/rajkp10/orchestration/blob/main/terraform/modules/postgres/main.tf): `terraform/modules/postgres/main.tf`

### Other components

- **Event caller**
- **Docker engine**
- **Postgres container**

## Connections

- Event caller → Trigger CLI: submits event (evidence: `README.md`)
- Trigger CLI → Event parser: parses event (evidence: `orchestrator/trigger.py`)
- Trigger CLI → Temporal service: starts workflow (evidence: `orchestrator/trigger.py`)
- Trigger CLI → Lifecycle workflow: starts (evidence: `orchestrator/trigger.py`)
- Trigger CLI → Lifecycle workflow: queries status (evidence: `orchestrator/trigger.py`)
- Temporal worker → Temporal service: connects to (evidence: `orchestrator/worker.py`)
- Temporal worker → Lifecycle workflow: registers (evidence: `orchestrator/worker.py`)
- Temporal worker → Activity dispatch: registers (evidence: `orchestrator/worker.py`)
- Lifecycle workflow → Request validation: executes (evidence: `orchestrator/workflow.py`)
- Lifecycle workflow → Terraform activity: executes (evidence: `orchestrator/workflow.py`)
- Lifecycle workflow → Live verification: executes (evidence: `orchestrator/workflow.py`)
- Lifecycle workflow → Result reporting: reports outcome (evidence: `orchestrator/workflow.py`)
- Request validation → Adapter registry: resolves adapter (evidence: `orchestrator/activities.py`)
- Terraform activity → Adapter registry: resolves adapter (evidence: `orchestrator/activities.py`)
- Live verification → Adapter registry: resolves adapter (evidence: `orchestrator/platforms/registry.py`)
- Adapter registry → Postgres lifecycle: registers (evidence: `orchestrator/platforms/registry.py`)
- Adapter registry → Adapter contract: uses contract (evidence: `orchestrator/platforms/registry.py`)
- Request validation → Postgres lifecycle: validates request (evidence: `orchestrator/activities.py`)
- Terraform activity → Postgres lifecycle: builds variables (evidence: `orchestrator/activities.py`)
- Live verification → Postgres lifecycle: checks resource (evidence: `orchestrator/platforms/postgres.py`)
- Request validation → Terraform runner: reads state (evidence: `orchestrator/activities.py`)
- Terraform activity → Terraform runner: applies or destroys (evidence: `orchestrator/activities.py`)
- Live verification → Terraform runner: reads outputs
- Terraform runner → Error classifier: classifies errors (evidence: `orchestrator/terraform/runner.py`)
- Terraform activity → Postgres module: selects module
- Postgres module → Docker engine: manages containers (evidence: `README.md`)
- Docker engine → Postgres container: hosts (evidence: `README.md`)
- Live verification → Postgres container: checks live database (evidence: `orchestrator/platforms/postgres.py`)
- Live verification → Docker engine: checks removal (evidence: `orchestrator/platforms/postgres.py`)
- Result reporting → Result JSON record: writes result (evidence: `orchestrator/activities.py`)
