# vallepurohith/complexity-analyzer architecture

> Architecture diagram of the GitHub repository vallepurohith/complexity-analyzer, 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/vallepurohith/complexity-analyzer
- Repository: https://github.com/vallepurohith/complexity-analyzer

## Overview

Complexity Analyzer is a browser-based Python complexity analysis and execution tool. A user edits or selects code in the React interface; the interface requests examples or submits code for analysis, and the FastAPI backend invokes the AST analyzer and returns time/space estimates, metrics, and an explanation for display. The product also offers Python subprocess execution with standard input/output and a timeout. The main internal layer is the analyzer’s AST-based traversal and complexity calculation. The compiler UI’s request wiring is not shown in the excerpts, so that connection is marked unverified.

Main entry points: [`server.py`](https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py) (FastAPI routes), [`frontend/src/App.jsx`](https://github.com/vallepurohith/complexity-analyzer/blob/main/frontend/src/App.jsx) (Editor and reports), [`complexity_analyzer/analyzer.py`](https://github.com/vallepurohith/complexity-analyzer/blob/main/complexity_analyzer/analyzer.py) (AST analysis), [`frontend/src/main.jsx`](https://github.com/vallepurohith/complexity-analyzer/blob/main/frontend/src/main.jsx) (React entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser interface"]
  node_app["Editor and reports<br/>[App.jsx]"]
  node_react_entry["React entry<br/>[main.jsx]"]
end

subgraph group_api["Backend API"]
  node_api_server["FastAPI routes<br/>[server.py]"]
  node_examples["Code examples<br/>[server.py]"]
  node_analyze_handler["Analysis handler<br/>[server.py]"]
  node_run_handler["Run handler<br/>[server.py]"]
end

subgraph group_analysis["Static analysis"]
  node_ast_analysis["AST analysis<br/>[analyzer.py]"]
  node_complexity_result["Analysis result<br/>[result.py]"]
end

subgraph group_execution["Code execution"]
  node_python_subprocess["Python subprocess<br/>[server.py]"]
end

node_user(("User"))

node_user -->|"edits code"| node_app
node_react_entry -->|"renders"| node_app
node_app -->|"requests examples"| node_api_server
node_app -->|"submits analysis"| node_api_server
node_api_server -->|"routes examples"| node_examples
node_api_server -->|"routes analysis"| node_analyze_handler
node_analyze_handler -->|"analyzes code"| node_ast_analysis
node_ast_analysis -->|"returns result"| node_complexity_result
node_api_server -->|"routes execution"| node_run_handler
node_run_handler -->|"executes code"| node_python_subprocess
node_app -.->|"requests execution"| node_api_server

click node_app "https://github.com/vallepurohith/complexity-analyzer/blob/main/frontend/src/App.jsx"
click node_react_entry "https://github.com/vallepurohith/complexity-analyzer/blob/main/frontend/src/main.jsx"
click node_api_server "https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py"
click node_examples "https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py"
click node_analyze_handler "https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py"
click node_run_handler "https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py"
click node_ast_analysis "https://github.com/vallepurohith/complexity-analyzer/blob/main/complexity_analyzer/analyzer.py"
click node_complexity_result "https://github.com/vallepurohith/complexity-analyzer/blob/main/complexity_analyzer/result.py"
click node_python_subprocess "https://github.com/vallepurohith/complexity-analyzer/blob/main/server.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_app,node_react_entry,node_user toneBlue
class node_api_server,node_examples,node_analyze_handler,node_run_handler toneAmber
class node_ast_analysis,node_complexity_result toneMint
class node_python_subprocess toneRose
```

## Components

### Browser interface

- [Editor and reports](https://github.com/vallepurohith/complexity-analyzer/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [React entry](https://github.com/vallepurohith/complexity-analyzer/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### Backend API

- [FastAPI routes](https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py): `server.py`
- [Code examples](https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py): `server.py`
- [Analysis handler](https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py): `server.py`
- [Run handler](https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py): `server.py`

### Static analysis

- [AST analysis](https://github.com/vallepurohith/complexity-analyzer/blob/main/complexity_analyzer/analyzer.py): `complexity_analyzer/analyzer.py`
- [Analysis result](https://github.com/vallepurohith/complexity-analyzer/blob/main/complexity_analyzer/result.py): `complexity_analyzer/result.py`

### Code execution

- [Python subprocess](https://github.com/vallepurohith/complexity-analyzer/blob/main/server.py): `server.py`

### Other components

- **User**

## Connections

- User → Editor and reports: edits code (evidence: `frontend/src/App.jsx`)
- React entry → Editor and reports: renders (evidence: `frontend/src/main.jsx`)
- Editor and reports → FastAPI routes: requests examples (evidence: `frontend/src/App.jsx`)
- Editor and reports → FastAPI routes: submits analysis (evidence: `frontend/src/App.jsx`)
- FastAPI routes → Code examples: routes examples (evidence: `server.py`)
- FastAPI routes → Analysis handler: routes analysis (evidence: `server.py`)
- Analysis handler → AST analysis: analyzes code (evidence: `server.py`)
- AST analysis → Analysis result: returns result (evidence: `complexity_analyzer/analyzer.py`)
- FastAPI routes → Run handler: routes execution (evidence: `server.py`)
- Run handler → Python subprocess: executes code (evidence: `server.py`)
- Editor and reports → FastAPI routes: requests execution
