# buvan45/time-complexity-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/buvan45/time-complexity-analyzer
- Repository: https://github.com/buvan45/time-complexity-analyzer

## Overview

Complexity Lab is a web tool that estimates a code snippet’s Big-O category. The user edits code in the React workspace, submits it through the API client to FastAPI, and sees the prediction and caveats in the results panel. The backend combines TF-IDF text features with heuristic structural features, scales the latter, and invokes the trained classifier. README documents health/API documentation and containerized deployment; the sampled tree supports the health route, but contains no deployment configuration. Backend processing and result formatting share one source file.

Main entry points: [`backend/main.py`](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py) (Prediction orchestration), [`frontend/src/api.js`](https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/api.js) (API client), [`frontend/src/App.jsx`](https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/App.jsx) (Editor and results), [`frontend/src/main.jsx`](https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/main.jsx) (React app mount)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web workspace"]
  node_workspace["Editor and results<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_app_mount["React app mount<br/>[main.jsx]"]
end

subgraph group_backend["Analysis API"]
  node_api["Analysis API<br/>[main.py]"]
  node_prediction_result["Prediction response<br/>[main.py]"]
end

subgraph group_ml["Prediction pipeline"]
  node_predict["Prediction orchestration<br/>[main.py]"]
  node_text_features["TF-IDF features<br/>[main.py]"]
  node_structural_features["Structural features<br/>[main.py]"]
  node_scaler["Feature scaler<br/>[main.py]"]
  node_classifier["Complexity classifier<br/>[main.py]"]
  node_model_bundle[("Trained model bundle")]
end

node_user(("Code author"))

node_user -->|"enters code"| node_workspace
node_app_mount -->|"renders"| node_workspace
node_workspace -->|"submits code"| node_api_client
node_api_client -->|"POST analyze"| node_api
node_api -->|"calls prediction"| node_predict
node_predict -->|"transforms text"| node_text_features
node_predict -->|"extracts features"| node_structural_features
node_predict -->|"scales features"| node_scaler
node_predict -->|"predicts class"| node_classifier
node_api -->|"formats response"| node_prediction_result
node_prediction_result -->|"returns JSON"| node_api_client
node_api_client -->|"returns result"| node_workspace
node_predict -->|"loads components"| node_model_bundle

click node_workspace "https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/api.js"
click node_app_mount "https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/main.jsx"
click node_api "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py"
click node_predict "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py"
click node_text_features "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py"
click node_structural_features "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py"
click node_scaler "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py"
click node_classifier "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py"
click node_model_bundle "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/models/codecomplex_structural.pkl"
click node_prediction_result "https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.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_workspace,node_api_client,node_app_mount toneBlue
class node_api,node_prediction_result toneAmber
class node_predict,node_text_features,node_structural_features,node_scaler,node_classifier,node_model_bundle toneMint
class node_user toneIndigo
```

## Components

### Web workspace

- [Editor and results](https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [React app mount](https://github.com/buvan45/time-complexity-analyzer/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### Analysis API

- [Analysis API](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py): `backend/main.py`
- [Prediction response](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py): `backend/main.py`

### Prediction pipeline

- [Prediction orchestration](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py): `backend/main.py`
- [TF-IDF features](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py): `backend/main.py`
- [Structural features](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py): `backend/main.py`
- [Feature scaler](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py): `backend/main.py`
- [Complexity classifier](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/main.py): `backend/main.py`
- [Trained model bundle](https://github.com/buvan45/time-complexity-analyzer/blob/main/backend/models/codecomplex_structural.pkl): `backend/models/codecomplex_structural.pkl`

### Other components

- **Code author**

## Connections

- Code author → Editor and results: enters code (evidence: `README.md`)
- React app mount → Editor and results: renders (evidence: `frontend/src/main.jsx`)
- Editor and results → API client: submits code (evidence: `frontend/src/App.jsx`)
- API client → Analysis API: POST analyze (evidence: `frontend/src/api.js`)
- Analysis API → Prediction orchestration: calls prediction (evidence: `backend/main.py`)
- Prediction orchestration → TF-IDF features: transforms text (evidence: `backend/main.py`)
- Prediction orchestration → Structural features: extracts features (evidence: `backend/main.py`)
- Prediction orchestration → Feature scaler: scales features (evidence: `backend/main.py`)
- Prediction orchestration → Complexity classifier: predicts class (evidence: `backend/main.py`)
- Analysis API → Prediction response: formats response (evidence: `backend/main.py`)
- Prediction response → API client: returns JSON (evidence: `README.md`)
- API client → Editor and results: returns result (evidence: `frontend/src/App.jsx`)
- Prediction orchestration → Trained model bundle: loads components (evidence: `backend/main.py`)
