# sai-kanagat/cortex-studio architecture

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

- Interactive diagram: https://gitdiagram.com/sai-kanagat/cortex-studio
- Repository: https://github.com/sai-kanagat/cortex-studio

## Overview

Cortex Studio turns a marketing brief into a reviewed, localized campaign package through a resumable multi-agent workflow. The API starts and streams runs; specialist stages research, plan, create and critique campaign content before a human approval gate and packaging. Supporting layers provide LLM access, retrieval and tools, media storage, security, tracing and evaluation. The README documents the full campaign sequence and capabilities; some component links are therefore documented rather than verified from sampled implementation excerpts.

Main entry points: [`apps/api/app/api/routes.py`](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/api/routes.py) (Campaign API), [`apps/api/app/graph/agents.py`](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py) (Market research), [`apps/api/app/graph/build.py`](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/build.py) (Workflow graph), [`apps/api/app/tools/registry.py`](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/tools/registry.py) (Agent tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product_flow["Campaign workflow"]
  node_ingest["Brief intake<br/>[agents.py]"]
  node_brand_intake["Brand intake<br/>[agents.py]"]
  node_planner["Campaign planner<br/>[agents.py]"]
  node_research["Market research<br/>[agents.py]"]
  node_strategy["Campaign strategy<br/>[agents.py]"]
  node_copywriter["Copywriting<br/>[agents.py]"]
  node_creative["Creative direction<br/>[agents.py]"]
  node_art["Art direction<br/>[agents.py]"]
  node_storyboard["Storyboard<br/>[agents.py]"]
  node_localize["Localization<br/>[agents.py]"]
  node_critic["Brand critic<br/>[agents.py]"]
  node_human_gate["Human approval<br/>[agents.py]"]
  node_packager["Campaign packager<br/>[agents.py]"]
end

subgraph group_runtime["API and controls"]
  node_api["Campaign API<br/>[routes.py]"]
  node_web["Campaign UI"]
  node_graph["Workflow graph<br/>[build.py]"]
  node_state["Campaign state<br/>[state.py]"]
  node_guardrails["Input guardrails<br/>[guardrails.py]"]
  node_moderation["Output moderation<br/>[moderation.py]"]
  node_rate_limit["Rate limiting<br/>[ratelimit.py]"]
  node_config["Runtime config<br/>[config.py]"]
end

subgraph group_capabilities["Campaign capabilities"]
  node_tools["Agent tools<br/>[registry.py]"]
  node_media[("Media and campaign kit<br/>[store.py]")]
  node_evaluation["Campaign evaluation<br/>[harness.py]"]
end

subgraph group_platform["Runtime services"]
  node_llm["Model router<br/>[client.py]"]
  node_vector_store[("Brand vector store<br/>[vector_store.py]")]
  node_embeddings["Text embeddings<br/>[embeddings.py]"]
  node_episodic["Episodic recall<br/>[episodic.py]"]
  node_tracing[("Run tracing<br/>[tracing.py]")]
end

node_marketer(("Marketer"))
node_reviewer(("Human reviewer"))
node_model_provider{{"LLM provider"}}
node_search_provider{{"Tavily search"}}

node_marketer -->|"submits brief"| node_api
node_web -->|"uses API"| node_api
node_api -->|"invokes run"| node_graph
node_graph -->|"dispatches"| node_ingest
node_ingest -->|"passes state"| node_brand_intake
node_brand_intake -->|"passes state"| node_planner
node_planner -->|"passes state"| node_research
node_research -->|"passes findings"| node_strategy
node_strategy -->|"passes strategy"| node_copywriter
node_copywriter -->|"passes copy"| node_creative
node_creative -->|"passes concept"| node_art
node_art -->|"passes direction"| node_storyboard
node_storyboard -->|"passes frames"| node_localize
node_localize -->|"submits draft"| node_critic
node_critic -->|"requests revision"| node_copywriter
node_critic -->|"routes approved"| node_human_gate
node_human_gate -->|"routes rejection"| node_copywriter
node_human_gate -->|"routes approval"| node_packager
node_reviewer -->|"reviews draft"| node_web
node_web -->|"submits decision"| node_api
node_packager -->|"returns package"| node_marketer
node_graph -->|"uses typed state"| node_state
node_ingest -->|"sanitizes brief"| node_guardrails
node_api -->|"applies limits"| node_rate_limit
node_api -->|"reads settings"| node_config
node_research -->|"uses research tools"| node_tools
node_strategy -.->|"uses agent tools"| node_tools
node_tools -->|"retrieves brand data"| node_vector_store
node_vector_store -->|"embeds and ranks"| node_embeddings
node_planner -->|"recalls episodes"| node_episodic
node_episodic -->|"searches memory"| node_vector_store
node_creative -->|"requests completion"| node_llm
node_research -.->|"requests completion"| node_llm
node_art -.->|"saves generated assets"| node_media
node_storyboard -.->|"stores frames"| node_media
node_api -->|"loads run trace"| node_tracing
node_critic -.->|"checks brand safety"| node_moderation
node_llm -.->|"calls provider"| node_model_provider
node_tools -.->|"searches web"| node_search_provider
node_evaluation -->|"runs campaign"| node_graph
node_evaluation -->|"judges quality"| node_llm

click node_api "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/api/routes.py"
click node_web "https://github.com/sai-kanagat/cortex-studio/tree/main/apps/web"
click node_ingest "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_brand_intake "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_planner "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_research "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_strategy "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_copywriter "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_creative "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_art "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_storyboard "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_localize "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_critic "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_human_gate "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_packager "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py"
click node_graph "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/build.py"
click node_state "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/state.py"
click node_guardrails "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/guardrails.py"
click node_moderation "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/moderation.py"
click node_rate_limit "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/ratelimit.py"
click node_config "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/config.py"
click node_llm "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/llm/client.py"
click node_tools "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/tools/registry.py"
click node_vector_store "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/memory/vector_store.py"
click node_embeddings "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/memory/embeddings.py"
click node_episodic "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/memory/episodic.py"
click node_media "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/media/store.py"
click node_tracing "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/obs/tracing.py"
click node_evaluation "https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/eval/harness.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_ingest,node_brand_intake,node_planner,node_research,node_strategy,node_copywriter,node_creative,node_art,node_storyboard,node_localize,node_critic,node_human_gate,node_packager,node_reviewer toneBlue
class node_api,node_web,node_graph,node_state,node_guardrails,node_moderation,node_rate_limit,node_config toneAmber
class node_tools,node_media,node_evaluation toneMint
class node_llm,node_vector_store,node_embeddings,node_episodic,node_tracing toneRose
class node_marketer,node_model_provider,node_search_provider toneIndigo
```

## Components

### Campaign workflow

- [Brief intake](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Brand intake](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Campaign planner](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Market research](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Campaign strategy](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Copywriting](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Creative direction](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Art direction](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Storyboard](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Localization](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Brand critic](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Human approval](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`
- [Campaign packager](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/agents.py): `apps/api/app/graph/agents.py`

### API and controls

- [Campaign API](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/api/routes.py): `apps/api/app/api/routes.py`
- [Campaign UI](https://github.com/sai-kanagat/cortex-studio/tree/main/apps/web): `apps/web`
- [Workflow graph](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/build.py): `apps/api/app/graph/build.py`
- [Campaign state](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/graph/state.py): `apps/api/app/graph/state.py`
- [Input guardrails](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/guardrails.py): `apps/api/app/core/guardrails.py`
- [Output moderation](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/moderation.py): `apps/api/app/core/moderation.py`
- [Rate limiting](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/ratelimit.py): `apps/api/app/core/ratelimit.py`
- [Runtime config](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/core/config.py): `apps/api/app/core/config.py`

### Campaign capabilities

- [Agent tools](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/tools/registry.py): `apps/api/app/tools/registry.py`
- [Media and campaign kit](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/media/store.py): `apps/api/app/media/store.py`
- [Campaign evaluation](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/eval/harness.py): `apps/api/app/eval/harness.py`

### Runtime services

- [Model router](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/llm/client.py): `apps/api/app/llm/client.py`
- [Brand vector store](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/memory/vector_store.py): `apps/api/app/memory/vector_store.py`
- [Text embeddings](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/memory/embeddings.py): `apps/api/app/memory/embeddings.py`
- [Episodic recall](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/memory/episodic.py): `apps/api/app/memory/episodic.py`
- [Run tracing](https://github.com/sai-kanagat/cortex-studio/blob/main/apps/api/app/obs/tracing.py): `apps/api/app/obs/tracing.py`

### Other components

- **Marketer**
- **Human reviewer**
- **LLM provider**
- **Tavily search**

## Connections

- Marketer → Campaign API: submits brief (evidence: `README.md`)
- Campaign UI → Campaign API: uses API (evidence: `README.md`)
- Campaign API → Workflow graph: invokes run (evidence: `apps/api/app/api/routes.py`)
- Workflow graph → Brief intake: dispatches (evidence: `apps/api/app/graph/build.py`)
- Brief intake → Brand intake: passes state (evidence: `apps/api/app/graph/build.py`)
- Brand intake → Campaign planner: passes state (evidence: `apps/api/app/graph/build.py`)
- Campaign planner → Market research: passes state (evidence: `apps/api/app/graph/build.py`)
- Market research → Campaign strategy: passes findings (evidence: `apps/api/app/graph/build.py`)
- Campaign strategy → Copywriting: passes strategy (evidence: `apps/api/app/graph/build.py`)
- Copywriting → Creative direction: passes copy (evidence: `apps/api/app/graph/build.py`)
- Creative direction → Art direction: passes concept (evidence: `apps/api/app/graph/build.py`)
- Art direction → Storyboard: passes direction (evidence: `apps/api/app/graph/build.py`)
- Storyboard → Localization: passes frames (evidence: `apps/api/app/graph/build.py`)
- Localization → Brand critic: submits draft (evidence: `apps/api/app/graph/build.py`)
- Brand critic → Copywriting: requests revision (evidence: `apps/api/app/graph/build.py`)
- Brand critic → Human approval: routes approved (evidence: `apps/api/app/graph/build.py`)
- Human approval → Copywriting: routes rejection (evidence: `apps/api/app/graph/build.py`)
- Human approval → Campaign packager: routes approval (evidence: `apps/api/app/graph/build.py`)
- Human reviewer → Campaign UI: reviews draft (evidence: `README.md`)
- Campaign UI → Campaign API: submits decision (evidence: `README.md`)
- Campaign packager → Marketer: returns package (evidence: `README.md`)
- Workflow graph → Campaign state: uses typed state (evidence: `apps/api/app/graph/build.py`)
- Brief intake → Input guardrails: sanitizes brief (evidence: `apps/api/app/graph/agents.py`)
- Campaign API → Rate limiting: applies limits (evidence: `apps/api/app/api/routes.py`)
- Campaign API → Runtime config: reads settings (evidence: `apps/api/app/api/routes.py`)
- Market research → Agent tools: uses research tools (evidence: `README.md`)
- Campaign strategy → Agent tools: uses agent tools (evidence: `apps/api/app/graph/agents.py`)
- Agent tools → Brand vector store: retrieves brand data (evidence: `apps/api/app/tools/registry.py`)
- Brand vector store → Text embeddings: embeds and ranks (evidence: `apps/api/app/memory/vector_store.py`)
- Campaign planner → Episodic recall: recalls episodes (evidence: `apps/api/app/graph/agents.py`)
- Episodic recall → Brand vector store: searches memory (evidence: `apps/api/app/memory/episodic.py`)
- Creative direction → Model router: requests completion (evidence: `README.md`)
- Market research → Model router: requests completion (evidence: `apps/api/app/graph/agents.py`)
- Art direction → Media and campaign kit: saves generated assets (evidence: `apps/api/app/graph/agents.py`)
- Storyboard → Media and campaign kit: stores frames (evidence: `apps/api/app/graph/agents.py`)
- Campaign API → Run tracing: loads run trace (evidence: `apps/api/app/api/routes.py`)
- Brand critic → Output moderation: checks brand safety (evidence: `apps/api/app/graph/agents.py`)
- Model router → LLM provider: calls provider
- Agent tools → Tavily search: searches web (evidence: `apps/api/app/tools/registry.py`)
- Campaign evaluation → Workflow graph: runs campaign (evidence: `apps/api/app/eval/harness.py`)
- Campaign evaluation → Model router: judges quality (evidence: `apps/api/app/eval/harness.py`)
