# abuzargabol/code-debug-ai-agent architecture

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

- Interactive diagram: https://gitdiagram.com/abuzargabol/code-debug-ai-agent
- Repository: https://github.com/abuzargabol/code-debug-ai-agent

## Overview

This is a small Flask code-fixing web app. A user opens the page, logs in, submits code, and receives a formatted diagnosis, corrected code, and explanation from OpenRouter or, if that fails, a local Ollama model. Successful answers are saved to and served from a JSON history file. The HTML is served by Flask; its client-side request behavior is not shown, so that connection is documented only at the route level. The graph reflects the single sampled runtime file.

Main entry points: [`APP.py`](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py) (Code submission), [`index.html`](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/index.html) (Web page), [`history.json`](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/history.json) (History JSON)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_flask["Flask app and routes<br/>[APP.py]"]
  node_page["Web page<br/>[index.html]"]
end

subgraph group_workflow["Code-fixing workflow"]
  node_login["Login session<br/>[APP.py]"]
  node_ask["Code submission<br/>[APP.py]"]
  node_prompt["Fix prompt<br/>[APP.py]"]
  node_openrouter{{"OpenRouter model"}}
  node_ollama{{"Local Ollama model"}}
  node_answer["Formatted answer<br/>[APP.py]"]
end

subgraph group_persistence["Chat history"]
  node_history_store[("History JSON<br/>[history.json]")]
  node_history_route["History endpoint<br/>[APP.py]"]
end

node_user(("User"))

node_user -->|"opens"| node_page
node_flask -->|"serves"| node_page
node_user -->|"logs in"| node_login
node_login -->|"sets session"| node_flask
node_user -->|"submits code"| node_ask
node_ask -->|"formats"| node_prompt
node_ask -->|"requests answer"| node_openrouter
node_ask -->|"fallback request"| node_ollama
node_openrouter -->|"returns text"| node_answer
node_ollama -->|"returns text"| node_answer
node_ask -->|"saves answer"| node_history_store
node_user -->|"requests history"| node_history_route
node_history_route -->|"reads"| node_history_store
node_ask -->|"returns answer"| node_user

click node_flask "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py"
click node_page "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/index.html"
click node_login "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py"
click node_ask "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py"
click node_prompt "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py"
click node_answer "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py"
click node_history_store "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/history.json"
click node_history_route "https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.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_flask,node_page,node_user toneBlue
class node_login,node_ask,node_prompt,node_openrouter,node_ollama,node_answer toneAmber
class node_history_store,node_history_route toneMint
```

## Components

### Web interface

- [Flask app and routes](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py): `APP.py`
- [Web page](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/index.html): `index.html`

### Code-fixing workflow

- [Login session](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py): `APP.py`
- [Code submission](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py): `APP.py`
- [Fix prompt](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py): `APP.py`
- **OpenRouter model**
- **Local Ollama model**
- [Formatted answer](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py): `APP.py`

### Chat history

- [History JSON](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/history.json): `history.json`
- [History endpoint](https://github.com/abuzargabol/code-debug-ai-agent/blob/main/APP.py): `APP.py`

### Other components

- **User**

## Connections

- User → Web page: opens
- Flask app and routes → Web page: serves (evidence: `APP.py`)
- User → Login session: logs in (evidence: `APP.py`)
- Login session → Flask app and routes: sets session (evidence: `APP.py`)
- User → Code submission: submits code (evidence: `APP.py`)
- Code submission → Fix prompt: formats (evidence: `APP.py`)
- Code submission → OpenRouter model: requests answer (evidence: `APP.py`)
- Code submission → Local Ollama model: fallback request (evidence: `APP.py`)
- OpenRouter model → Formatted answer: returns text (evidence: `APP.py`)
- Local Ollama model → Formatted answer: returns text (evidence: `APP.py`)
- Code submission → History JSON: saves answer (evidence: `APP.py`)
- User → History endpoint: requests history (evidence: `APP.py`)
- History endpoint → History JSON: reads (evidence: `APP.py`)
- Code submission → User: returns answer (evidence: `APP.py`)
