# asaad-suliman/ai-code-analyst architecture

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

- Interactive diagram: https://gitdiagram.com/asaad-suliman/ai-code-analyst
- Repository: https://github.com/asaad-suliman/ai-code-analyst

## Overview

This repository is an AI code-analysis product: a user submits Python, the backend analyzes and rewrites it, then executes both versions in a sandbox to verify correctness and performance. The web app also provides authentication, live progress, analysis reports, and session history. The backend pipeline and API relationships are supported by the excerpts and index; the README documents the broader six-stage flow and UI streaming. Some frontend and agent implementations were not sampled, so uncertain internal calls are omitted.

Main entry points: [`orchestrator.py`](https://github.com/asaad-suliman/ai-code-analyst/blob/main/orchestrator.py) (Pipeline orchestrator), [`core/schemas.py`](https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/schemas.py) (Typed data contracts), [`api/app.py`](https://github.com/asaad-suliman/ai-code-analyst/blob/main/api/app.py) (FastAPI endpoints), [`frontend/src/main.jsx`](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/main.jsx) (Page routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_api_app["FastAPI endpoints<br/>[app.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_supabase[("Supabase auth and sessions")]
end

subgraph group_analysis["Analysis pipeline"]
  node_orchestrator["Pipeline orchestrator<br/>[orchestrator.py]"]
  node_schemas["Typed data contracts<br/>[schemas.py]"]
  node_architect["AST architect<br/>[architect_agent.py]"]
  node_security["Security scanner<br/>[security_agent.py]"]
  node_bugs["Bug detector<br/>[bug_detector.py]"]
  node_optimizer["Code optimizer<br/>[optimizer.py]"]
  node_prompts["LLM prompts<br/>[prompts.py]"]
end

subgraph group_verification["Execution and verification"]
  node_performance["Performance analyzer"]
  node_validator["Optimization validator<br/>[validator.py]"]
  node_executor["Sandbox executor<br/>[code_executor.py]"]
  node_metrics["Resource sampler<br/>[metrics.py]"]
end

subgraph group_memory["Learning and metrics"]
  node_retriever[("RAG retrieval and storage<br/>[retriever.py]")]
  node_learning["Learning gate<br/>[learning_engine.py]"]
end

subgraph group_web["Web experience"]
  node_frontend["React dashboard<br/>[Dashboard.jsx]"]
  node_api_client["Frontend API client<br/>[api.js]"]
  node_auth["Frontend authentication<br/>[auth.js]"]
  node_router["Page routing<br/>[main.jsx]"]
  node_insights["Analysis insights<br/>[Insights.jsx]"]
  node_history["Session history<br/>[History.jsx]"]
  node_home["Product landing page<br/>[Home.jsx]"]
end

node_user(("Code submitter"))

node_user -->|"submits code"| node_api_app
node_api_app -->|"runs pipeline"| node_orchestrator
node_orchestrator -->|"runs stage"| node_architect
node_orchestrator -->|"runs stage"| node_security
node_orchestrator -->|"retrieves context"| node_retriever
node_orchestrator -->|"runs stage"| node_bugs
node_orchestrator -->|"runs stage"| node_performance
node_orchestrator -->|"runs stage"| node_optimizer
node_orchestrator -->|"runs stage"| node_validator
node_orchestrator -->|"triggers learning"| node_learning
node_orchestrator -->|"uses contracts"| node_schemas
node_validator -->|"executes code"| node_executor
node_performance -->|"measures execution"| node_executor
node_metrics -->|"samples process"| node_executor
node_learning -->|"saves approved fixes"| node_retriever
node_retriever -->|"reads store path"| node_config
node_api_app -->|"authenticates and stores sessions"| node_supabase
node_api_app -->|"loads settings"| node_config
node_architect -->|"returns report"| node_schemas
node_security -->|"returns report"| node_schemas
node_bugs -->|"returns report"| node_schemas
node_performance -->|"returns report"| node_schemas
node_optimizer -->|"returns result"| node_schemas
node_validator -->|"returns verdict"| node_schemas
node_user -->|"uses dashboard"| node_frontend
node_frontend -->|"requests analysis"| node_api_client
node_api_client -->|"calls API"| node_api_app
node_api_app -->|"streams stages"| node_frontend
node_router -->|"routes dashboard"| node_frontend
node_router -->|"routes reports"| node_insights
node_router -->|"routes sessions"| node_history
node_router -->|"routes home"| node_home
node_insights -->|"loads reports"| node_api_client
node_history -->|"loads history"| node_api_client
node_auth -.->|"stores login state"| node_supabase

click node_api_app "https://github.com/asaad-suliman/ai-code-analyst/blob/main/api/app.py"
click node_orchestrator "https://github.com/asaad-suliman/ai-code-analyst/blob/main/orchestrator.py"
click node_schemas "https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/schemas.py"
click node_architect "https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/architect_agent.py"
click node_security "https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/security_agent.py"
click node_bugs "https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/bug_detector.py"
click node_performance "https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/performance_analyzer.py"
click node_optimizer "https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/optimizer.py"
click node_validator "https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/validator.py"
click node_executor "https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/code_executor.py"
click node_metrics "https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/metrics.py"
click node_retriever "https://github.com/asaad-suliman/ai-code-analyst/blob/main/rag/retriever.py"
click node_learning "https://github.com/asaad-suliman/ai-code-analyst/blob/main/rag/learning_engine.py"
click node_config "https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/config.py"
click node_prompts "https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/prompts.py"
click node_frontend "https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/Dashboard.jsx"
click node_api_client "https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/lib/api.js"
click node_auth "https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/lib/auth.js"
click node_router "https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/main.jsx"
click node_insights "https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/Insights.jsx"
click node_history "https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/History.jsx"
click node_home "https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/Home.jsx"

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_api_app,node_config,node_supabase toneBlue
class node_orchestrator,node_schemas,node_architect,node_security,node_bugs,node_optimizer,node_prompts toneAmber
class node_performance,node_validator,node_executor,node_metrics toneMint
class node_retriever,node_learning toneRose
class node_frontend,node_api_client,node_auth,node_router,node_insights,node_history,node_home,node_user toneIndigo
```

## Components

### API and access

- [FastAPI endpoints](https://github.com/asaad-suliman/ai-code-analyst/blob/main/api/app.py): `api/app.py`
- [Runtime configuration](https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/config.py): `core/config.py`
- **Supabase auth and sessions**

### Analysis pipeline

- [Pipeline orchestrator](https://github.com/asaad-suliman/ai-code-analyst/blob/main/orchestrator.py): `orchestrator.py`
- [Typed data contracts](https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/schemas.py): `core/schemas.py`
- [AST architect](https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/architect_agent.py): `agents/architect_agent.py`
- [Security scanner](https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/security_agent.py): `agents/security_agent.py`
- [Bug detector](https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/bug_detector.py): `agents/bug_detector.py`
- [Code optimizer](https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/optimizer.py): `agents/optimizer.py`
- [LLM prompts](https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/prompts.py): `core/prompts.py`

### Execution and verification

- [Performance analyzer](https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/performance_analyzer.py): `agents/performance_analyzer.py`
- [Optimization validator](https://github.com/asaad-suliman/ai-code-analyst/blob/main/agents/validator.py): `agents/validator.py`
- [Sandbox executor](https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/code_executor.py): `core/code_executor.py`
- [Resource sampler](https://github.com/asaad-suliman/ai-code-analyst/blob/main/core/metrics.py): `core/metrics.py`

### Learning and metrics

- [RAG retrieval and storage](https://github.com/asaad-suliman/ai-code-analyst/blob/main/rag/retriever.py): `rag/retriever.py`
- [Learning gate](https://github.com/asaad-suliman/ai-code-analyst/blob/main/rag/learning_engine.py): `rag/learning_engine.py`

### Web experience

- [React dashboard](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Frontend API client](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`
- [Frontend authentication](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/lib/auth.js): `frontend/src/lib/auth.js`
- [Page routing](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Analysis insights](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/Insights.jsx): `frontend/src/pages/Insights.jsx`
- [Session history](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/History.jsx): `frontend/src/pages/History.jsx`
- [Product landing page](https://github.com/asaad-suliman/ai-code-analyst/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`

### Other components

- **Code submitter**

## Connections

- Code submitter → FastAPI endpoints: submits code (evidence: `api/app.py`)
- FastAPI endpoints → Pipeline orchestrator: runs pipeline (evidence: `api/app.py`)
- Pipeline orchestrator → AST architect: runs stage (evidence: `orchestrator.py`)
- Pipeline orchestrator → Security scanner: runs stage (evidence: `orchestrator.py`)
- Pipeline orchestrator → RAG retrieval and storage: retrieves context (evidence: `orchestrator.py`)
- Pipeline orchestrator → Bug detector: runs stage (evidence: `orchestrator.py`)
- Pipeline orchestrator → Performance analyzer: runs stage (evidence: `orchestrator.py`)
- Pipeline orchestrator → Code optimizer: runs stage (evidence: `orchestrator.py`)
- Pipeline orchestrator → Optimization validator: runs stage (evidence: `orchestrator.py`)
- Pipeline orchestrator → Learning gate: triggers learning (evidence: `orchestrator.py`)
- Pipeline orchestrator → Typed data contracts: uses contracts (evidence: `orchestrator.py`)
- Optimization validator → Sandbox executor: executes code (evidence: `agents/validator.py`)
- Performance analyzer → Sandbox executor: measures execution
- Resource sampler → Sandbox executor: samples process (evidence: `core/metrics.py`)
- Learning gate → RAG retrieval and storage: saves approved fixes (evidence: `rag/learning_engine.py`)
- RAG retrieval and storage → Runtime configuration: reads store path (evidence: `rag/retriever.py`)
- FastAPI endpoints → Supabase auth and sessions: authenticates and stores sessions (evidence: `api/app.py`)
- FastAPI endpoints → Runtime configuration: loads settings (evidence: `core/config.py`)
- AST architect → Typed data contracts: returns report (evidence: `agents/architect_agent.py`)
- Security scanner → Typed data contracts: returns report (evidence: `agents/security_agent.py`)
- Bug detector → Typed data contracts: returns report (evidence: `agents/bug_detector.py`)
- Performance analyzer → Typed data contracts: returns report (evidence: `agents/performance_analyzer.py`)
- Code optimizer → Typed data contracts: returns result (evidence: `agents/optimizer.py`)
- Optimization validator → Typed data contracts: returns verdict (evidence: `agents/validator.py`)
- Code submitter → React dashboard: uses dashboard (evidence: `README.md`)
- React dashboard → Frontend API client: requests analysis (evidence: `frontend/src/pages/Dashboard.jsx`)
- Frontend API client → FastAPI endpoints: calls API (evidence: `README.md`)
- FastAPI endpoints → React dashboard: streams stages (evidence: `README.md`)
- Page routing → React dashboard: routes dashboard (evidence: `frontend/src/main.jsx`)
- Page routing → Analysis insights: routes reports (evidence: `frontend/src/main.jsx`)
- Page routing → Session history: routes sessions (evidence: `frontend/src/main.jsx`)
- Page routing → Product landing page: routes home (evidence: `frontend/src/main.jsx`)
- Analysis insights → Frontend API client: loads reports (evidence: `frontend/src/pages/Insights.jsx`)
- Session history → Frontend API client: loads history (evidence: `frontend/src/pages/History.jsx`)
- Frontend authentication → Supabase auth and sessions: stores login state
