# okeson453/sentra-aura architecture

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

- Interactive diagram: https://gitdiagram.com/okeson453/sentra-aura
- Repository: https://github.com/okeson453/sentra-aura

## Overview

#### Purpose and Entry Points
SentraAura is a multi-tenant autonomous media-production platform for operating faceless channels across strategy, generation, publishing, analytics, and optimization. It is a backend/service monorepo, not a web application. Local entry points are `Makefile`, `local/docker-compose.yml`, and `tools/sentra-cli/src/sentra_cli/main.py`. Deployable HTTP/worker service entry points conventionally live in each service’s `src/.../main.py`, e.g. `services/orchestrator/src/orchestrator/main.py`.

#### Contract-First Service Boundary
OpenAPI specifications define service APIs in `contracts/openapi/`, while versioned event payloads are canonicalized in `contracts/events/v1/` and agent envelopes in `contracts/agent-messages/envelope.json`. Shared Python clients are generated/organized in `packages/api-clients/src/api_clients/`; event publishing, consumption, replay, and schema validation are centralized in `packages/event-bus/src/event_bus/`. This separates synchronous service calls from asynchronous, replayable workflow events.

#### Workflow Orchestration and Agent Runtime
The Orchestrator coordinates durable, recoverable workflows using state machines, sagas, activities, and scheduling: `services/orchestrator/src/orchestrator/workflows.py`, `services/orchestrator/src/orchestrator/saga.py`, and `services/orchestrator/src/orchestrator/state_machine.py`. ADRs identify Temporal as the durability runtime. The Agent Runtime hosts domain agents grouped into clipping, creative, distribution, intelligence, operations, and production; shared enforcement includes approvals, execution policy, tool permissions, durable state, prompt-injection defense, and sandboxing in `services/agent-runtime/src/agent_runtime/`.

#### Content Production Pipeline
A typical flow is intelligence/research → strategy/ideation → scripting and verification → scene/voice/visual production → rendering/clipping → packaging/scheduling/publishing. The clipping engine asynchronously extracts audio, transcribes, detects scenes/shots, segments semantically, diarizes speakers, and scores highlights: `services/clipping-engine/src/clipping_engine/pipeline/`, `services/clipping-engine/src/clipping_engine/tasks.py`. Media assembly, reframing, captions, FFmpeg encoding, and worker execution are isolated in `services/media-renderer/src/media_renderer/assembly/`, `services/media-renderer/src/media_renderer/encoding/ffmpeg_wrapper.py`, and `services/media-renderer/src/media_renderer/worker.py`.

#### Governance, Provenance, and Tenant Control
The control plane manages channels, content, decisions, experiments, policies, publishing, and analytics-facing APIs: `services/control-plane-api/src/control_plane_api/routes/`. The content graph stores content nodes, edges, queries, and lineage; its client exposes traversal and lineage operations: `services/content-graph-service/src/content_graph_service/graph_queries.py`, `packages/content-graph-client/src/content_graph_client/lineage.py`. Policy, rights, approvals, budget/quota, and security form control boundaries before irreversible actions: `services/policy-engine/src/policy_engine/engine.py`, `services/rights-registry-service/src/rights_registry_service/content_id_workflow.py`, `services/agent-runtime/src/agent_runtime/approval_gate.py`.

#### External Providers and Distribution
Provider Gateway normalizes interchangeable LLM, image, search, transcription, TTS, and video vendors and tracks costs: `services/provider-gateway/src/provider_gateway/router.py`, `services/provider-gateway/src/provider_gateway/adapters/`, `services/provider-gateway/src/provider_gateway/cost_tracker.py`. Publishing abstracts platform capabilities and upload state across YouTube, TikTok, and Instagram: `services/publishing-service/src/publishing_service/platforms/`, `services/publishing-service/src/publishing_service/upload_state_machine.py`. Analytics ingests YouTube metrics, normalizes them, and writes ClickHouse/warehouse targets: `services/analytics-ingestion/src/analytics_ingestion/youtube_analytics_client.py`, `services/analytics-ingestion/src/analytics_ingestion/clickhouse_writer.py`.

#### Runtime Infrastructure and Operations
Services are containerized and deployed to Kubernetes via reusable Helm charts and per-service releases: `infra/helm/charts/sentra-service/`, `infra/helm/releases/`, `infra/helm/charts/platform/nats/`. Terraform provisions cluster, networking, databases, object storage, cache, event bus, warehouse, secrets, and observability: `infra/terraform/modules/`. NATS is the event-bus infrastructure; PostgreSQL is implied by migrations and tenant-isolation migrations; ClickHouse supports analytics; object-storage backends support S3, GCS, and Azure. Prometheus/Loki-oriented observability and agent/LLM tracing are defined in `infra/terraform/modules/observability/` and `packages/observability/src/observability/`.

Main entry points: [`services/orchestrator/src/orchestrator/workflows.py`](https://github.com/okeson453/sentra-aura/blob/main/services/orchestrator/src/orchestrator/workflows.py) (Orchestrator), [`services/agent-runtime/src/agent_runtime/approval_gate.py`](https://github.com/okeson453/sentra-aura/blob/main/services/agent-runtime/src/agent_runtime/approval_gate.py) (Approval gate), [`services/media-renderer/src/media_renderer/worker.py`](https://github.com/okeson453/sentra-aura/blob/main/services/media-renderer/src/media_renderer/worker.py) (Media Renderer), [`services/policy-engine/src/policy_engine/engine.py`](https://github.com/okeson453/sentra-aura/blob/main/services/policy-engine/src/policy_engine/engine.py) (Policy Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_contracts["Contracts"]
  node_openapi["OpenAPI contracts<br/>API specifications"]
  node_events["Event contracts<br/>versioned payloads"]
  node_api_clients["API clients<br/>shared clients"]
  node_event_bus["Event bus library<br/>pub/sub and replay"]
end

subgraph group_automation["Workflow &amp; Agents"]
  node_orchestrator{{"Orchestrator<br/>durable workflows<br/>[workflows.py]"}}
  node_agent_runtime{{"Agent Runtime<br/>governed agents"}}
  node_approval_gate["Approval gate<br/>irreversible-action guard<br/>[approval_gate.py]"]
end

subgraph group_production["Production Pipeline"]
  node_clipping["Clipping Engine<br/>async media analysis"]
  node_renderer["Media Renderer<br/>render workers<br/>[worker.py]"]
end

subgraph group_governance["Control &amp; Governance"]
  node_control_plane["Control Plane API<br/>tenant management API"]
  node_content_graph[("Content Graph<br/>lineage service<br/>[graph_queries.py]")]
  node_policy_engine["Policy Engine<br/>policy enforcement<br/>[engine.py]"]
  node_rights_registry["Rights Registry<br/>rights workflow"]
end

subgraph group_platform["Platform Services"]
  node_provider_gateway["Provider Gateway<br/>vendor abstraction<br/>[router.py]"]
  node_publishing["Publishing Service<br/>platform distribution"]
  node_analytics["Analytics Ingestion<br/>metrics pipeline"]
end

subgraph group_infrastructure["Runtime Infrastructure"]
  node_nats["NATS<br/>event infrastructure"]
  node_data_stores[("Data stores<br/>PostgreSQL, ClickHouse, object storage")]
  node_deployment{{"Kubernetes deployment<br/>Helm releases"}}
  node_observability["Observability<br/>metrics, logs, tracing"]
end

node_cli["Sentra CLI<br/>local entrypoint<br/>[main.py]"]

node_cli -->|"operates"| node_control_plane
node_openapi -->|"generates contracts"| node_api_clients
node_api_clients -->|"synchronous calls"| node_control_plane
node_events -->|"validates payloads"| node_event_bus
node_event_bus -->|"publishes and consumes"| node_nats
node_orchestrator -->|"coordinates agents"| node_agent_runtime
node_orchestrator -->|"workflow events"| node_event_bus
node_agent_runtime -->|"invokes providers"| node_provider_gateway
node_agent_runtime -->|"requires approval"| node_approval_gate
node_approval_gate -->|"evaluates policy"| node_policy_engine
node_orchestrator -->|"dispatches analysis"| node_clipping
node_orchestrator -->|"dispatches rendering"| node_renderer
node_clipping -->|"clips and metadata"| node_renderer
node_renderer -->|"stores media assets"| node_data_stores
node_control_plane -->|"records content lineage"| node_content_graph
node_policy_engine -->|"checks rights"| node_rights_registry
node_approval_gate -->|"authorizes publishing"| node_publishing
node_publishing -.->|"published-platform metrics"| node_analytics
node_analytics -->|"writes warehouse"| node_data_stores
node_deployment -.->|"deploys services"| node_orchestrator
node_observability -.->|"traces workflows"| node_orchestrator

click node_cli "https://github.com/okeson453/sentra-aura/blob/main/tools/sentra-cli/src/sentra_cli/main.py"
click node_orchestrator "https://github.com/okeson453/sentra-aura/blob/main/services/orchestrator/src/orchestrator/workflows.py"
click node_approval_gate "https://github.com/okeson453/sentra-aura/blob/main/services/agent-runtime/src/agent_runtime/approval_gate.py"
click node_renderer "https://github.com/okeson453/sentra-aura/blob/main/services/media-renderer/src/media_renderer/worker.py"
click node_content_graph "https://github.com/okeson453/sentra-aura/blob/main/services/content-graph-service/src/content_graph_service/graph_queries.py"
click node_policy_engine "https://github.com/okeson453/sentra-aura/blob/main/services/policy-engine/src/policy_engine/engine.py"
click node_rights_registry "https://github.com/okeson453/sentra-aura/blob/main/services/rights-registry-service/src/rights_registry_service/content_id_workflow.py"
click node_provider_gateway "https://github.com/okeson453/sentra-aura/blob/main/services/provider-gateway/src/provider_gateway/router.py"
click node_publishing "https://github.com/okeson453/sentra-aura/blob/main/services/publishing-service/src/publishing_service/upload_state_machine.py"
click node_analytics "https://github.com/okeson453/sentra-aura/blob/main/services/analytics-ingestion/src/analytics_ingestion/clickhouse_writer.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_openapi,node_events,node_api_clients,node_event_bus toneBlue
class node_orchestrator,node_agent_runtime,node_approval_gate toneAmber
class node_clipping,node_renderer toneMint
class node_control_plane,node_content_graph,node_policy_engine,node_rights_registry toneRose
class node_provider_gateway,node_publishing,node_analytics toneIndigo
class node_nats,node_data_stores,node_deployment,node_observability toneTeal
class node_cli toneNeutral
```

## Components

### Contracts

- **OpenAPI contracts**: API specifications
- **Event contracts**: versioned payloads
- **API clients**: shared clients
- **Event bus library**: pub/sub and replay · Centralizes schema validation, publishing, consumption, and replay.

### Workflow & Agents

- [Orchestrator](https://github.com/okeson453/sentra-aura/blob/main/services/orchestrator/src/orchestrator/workflows.py): durable workflows · Coordinates state machines, sagas, activities, and schedules. · `services/orchestrator/src/orchestrator/workflows.py`
- **Agent Runtime**: governed agents · Runs domain agents with policy, tools, sandboxing, and durable state.
- [Approval gate](https://github.com/okeson453/sentra-aura/blob/main/services/agent-runtime/src/agent_runtime/approval_gate.py): irreversible-action guard · `services/agent-runtime/src/agent_runtime/approval_gate.py`

### Production Pipeline

- **Clipping Engine**: async media analysis · Transcribes, detects scenes, segments, diarizes, and scores highlights.
- [Media Renderer](https://github.com/okeson453/sentra-aura/blob/main/services/media-renderer/src/media_renderer/worker.py): render workers · Assembles media, captions, reframes, and FFmpeg encodes output. · `services/media-renderer/src/media_renderer/worker.py`

### Control & Governance

- **Control Plane API**: tenant management API · Manages channels, content, decisions, experiments, policies, and publishing.
- [Content Graph](https://github.com/okeson453/sentra-aura/blob/main/services/content-graph-service/src/content_graph_service/graph_queries.py): lineage service · Stores content relationships, traversal, and provenance. · `services/content-graph-service/src/content_graph_service/graph_queries.py`
- [Policy Engine](https://github.com/okeson453/sentra-aura/blob/main/services/policy-engine/src/policy_engine/engine.py): policy enforcement · `services/policy-engine/src/policy_engine/engine.py`
- [Rights Registry](https://github.com/okeson453/sentra-aura/blob/main/services/rights-registry-service/src/rights_registry_service/content_id_workflow.py): rights workflow · `services/rights-registry-service/src/rights_registry_service/content_id_workflow.py`

### Platform Services

- [Provider Gateway](https://github.com/okeson453/sentra-aura/blob/main/services/provider-gateway/src/provider_gateway/router.py): vendor abstraction · Routes AI and media providers while tracking cost. · `services/provider-gateway/src/provider_gateway/router.py`
- [Publishing Service](https://github.com/okeson453/sentra-aura/blob/main/services/publishing-service/src/publishing_service/upload_state_machine.py): platform distribution · Manages platform capabilities and upload state. · `services/publishing-service/src/publishing_service/upload_state_machine.py`
- [Analytics Ingestion](https://github.com/okeson453/sentra-aura/blob/main/services/analytics-ingestion/src/analytics_ingestion/clickhouse_writer.py): metrics pipeline · Normalizes YouTube metrics into warehouse targets. · `services/analytics-ingestion/src/analytics_ingestion/clickhouse_writer.py`

### Runtime Infrastructure

- **NATS**: event infrastructure
- **Data stores**: PostgreSQL, ClickHouse, object storage · Supports tenant data, analytics, and media assets.
- **Kubernetes deployment**: Helm releases
- **Observability**: metrics, logs, tracing

### Other components

- [Sentra CLI](https://github.com/okeson453/sentra-aura/blob/main/tools/sentra-cli/src/sentra_cli/main.py): local entrypoint · `tools/sentra-cli/src/sentra_cli/main.py`

## Connections

- Sentra CLI → Control Plane API: operates
- OpenAPI contracts → API clients: generates contracts
- API clients → Control Plane API: synchronous calls
- Event contracts → Event bus library: validates payloads
- Event bus library → NATS: publishes and consumes
- Orchestrator → Agent Runtime: coordinates agents
- Orchestrator → Event bus library: workflow events
- Agent Runtime → Provider Gateway: invokes providers
- Agent Runtime → Approval gate: requires approval
- Approval gate → Policy Engine: evaluates policy
- Orchestrator → Clipping Engine: dispatches analysis
- Orchestrator → Media Renderer: dispatches rendering
- Clipping Engine → Media Renderer: clips and metadata
- Media Renderer → Data stores: stores media assets
- Control Plane API → Content Graph: records content lineage
- Policy Engine → Rights Registry: checks rights
- Approval gate → Publishing Service: authorizes publishing
- Publishing Service → Analytics Ingestion: published-platform metrics
- Analytics Ingestion → Data stores: writes warehouse
- Kubernetes deployment → Orchestrator: deploys services
- Observability → Orchestrator: traces workflows
