# mehulmathodia/ai-code-genius architecture

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

- Interactive diagram: https://gitdiagram.com/mehulmathodia/ai-code-genius
- Repository: https://github.com/mehulmathodia/ai-code-genius

## Overview

AI Code Genius Pro is a code-analysis dashboard for developers. A user edits C++ code and starts analysis; the React app sends the code to a FastAPI endpoint, which asks Gemini for a structured analysis and returns the result for display. The main result stages are explanation and Big O complexity, optimized code with rationale, and cross-language translation. The README documents these capabilities, while the sampled backend prompt and frontend show the request and display flow; separate implementation modules for those stages are not evident in the tree.

Main entry points: [`backend/main.py`](https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py) (Code analysis), [`frontend/src/App.js`](https://github.com/mehulmathodia/ai-code-genius/blob/main/frontend/src/App.js) (Analyze workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Analysis dashboard"]
  node_editor["Code editor<br/>[App.js]"]
  node_app["Analyze workflow<br/>[App.js]"]
  node_dashboard["Results dashboard<br/>[App.js]"]
end

subgraph group_backend["Analysis service"]
  node_endpoint["Analyze endpoint<br/>[main.py]"]
  node_validation["Request validation<br/>[main.py]"]
  node_analysis["Code analysis<br/>[main.py]"]
  node_complexity["Complexity analysis<br/>[main.py]"]
  node_refactoring["Logic refactoring<br/>[main.py]"]
  node_translation["Language translation<br/>[main.py]"]
end

subgraph group_ai["AI provider"]
  node_gemini["Gemini 2.5 Flash"]
end

node_developer(("Developer"))

node_developer -->|"enters code"| node_editor
node_developer -->|"starts analysis"| node_app
node_editor -->|"updates input"| node_app
node_app -->|"posts code"| node_endpoint
node_endpoint -->|"validates request"| node_validation
node_endpoint -->|"builds prompt"| node_analysis
node_analysis -->|"requests analysis"| node_gemini
node_gemini -->|"returns JSON"| node_analysis
node_analysis -->|"includes Big O"| node_complexity
node_analysis -->|"includes optimized code"| node_refactoring
node_analysis -->|"includes translation"| node_translation
node_app -->|"renders results"| node_dashboard
node_endpoint -.->|"returns response"| node_app

click node_editor "https://github.com/mehulmathodia/ai-code-genius/blob/main/frontend/src/App.js"
click node_app "https://github.com/mehulmathodia/ai-code-genius/blob/main/frontend/src/App.js"
click node_dashboard "https://github.com/mehulmathodia/ai-code-genius/blob/main/frontend/src/App.js"
click node_endpoint "https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py"
click node_validation "https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py"
click node_analysis "https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py"
click node_complexity "https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py"
click node_refactoring "https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py"
click node_translation "https://github.com/mehulmathodia/ai-code-genius/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_editor,node_app,node_dashboard toneBlue
class node_endpoint,node_validation,node_analysis,node_complexity,node_refactoring,node_translation toneAmber
class node_gemini toneMint
class node_developer toneIndigo
```

## Components

### Analysis dashboard

- [Code editor](https://github.com/mehulmathodia/ai-code-genius/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Analyze workflow](https://github.com/mehulmathodia/ai-code-genius/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Results dashboard](https://github.com/mehulmathodia/ai-code-genius/blob/main/frontend/src/App.js): `frontend/src/App.js`

### Analysis service

- [Analyze endpoint](https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py): `backend/main.py`
- [Request validation](https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py): `backend/main.py`
- [Code analysis](https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py): `backend/main.py`
- [Complexity analysis](https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py): `backend/main.py`
- [Logic refactoring](https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py): `backend/main.py`
- [Language translation](https://github.com/mehulmathodia/ai-code-genius/blob/main/backend/main.py): `backend/main.py`

### AI provider

- **Gemini 2.5 Flash**

### Other components

- **Developer**

## Connections

- Developer → Code editor: enters code (evidence: `frontend/src/App.js`)
- Developer → Analyze workflow: starts analysis (evidence: `frontend/src/App.js`)
- Code editor → Analyze workflow: updates input (evidence: `frontend/src/App.js`)
- Analyze workflow → Analyze endpoint: posts code (evidence: `frontend/src/App.js`)
- Analyze endpoint → Request validation: validates request (evidence: `backend/main.py`)
- Analyze endpoint → Code analysis: builds prompt (evidence: `backend/main.py`)
- Code analysis → Gemini 2.5 Flash: requests analysis (evidence: `backend/main.py`)
- Gemini 2.5 Flash → Code analysis: returns JSON (evidence: `backend/main.py`)
- Code analysis → Complexity analysis: includes Big O (evidence: `backend/main.py`)
- Code analysis → Logic refactoring: includes optimized code (evidence: `backend/main.py`)
- Code analysis → Language translation: includes translation (evidence: `backend/main.py`)
- Analyze workflow → Results dashboard: renders results (evidence: `frontend/src/App.js`)
- Analyze endpoint → Analyze workflow: returns response
