# gopal-md/code-summarizer architecture

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

- Interactive diagram: https://gitdiagram.com/gopal-md/code-summarizer
- Repository: https://github.com/gopal-md/code-summarizer

## Overview

Code Summarizer accepts pasted code, uploaded files, or project ZIPs through a Flask API, then returns beginner-oriented explanations and related analysis. The primary browser flow runs from the web client through the summarize endpoint to parsing or analysis, with a CLI as another API client. Project uploads support an overview followed by deeper analysis of a selected file. The README documents Groq-backed analysis with local fallback; the sampled excerpts show the API integration and fallback selection, but not every analysis detail.

Main entry points: [`app.py`](https://github.com/gopal-md/code-summarizer/blob/main/app.py) (Summarize API), [`src/summarize.py`](https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py) (Structured explanation), [`static/js/chat.js`](https://github.com/gopal-md/code-summarizer/blob/main/static/js/chat.js) (Browser client), [`cli.py`](https://github.com/gopal-md/code-summarizer/blob/main/cli.py) (CLI client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User Interfaces"]
  node_web["Browser client<br/>[chat.js]"]
  node_cli["CLI client<br/>[cli.py]"]
end

subgraph group_intake["Request Intake"]
  node_flask["Summarize API<br/>[app.py]"]
  node_project_upload["Project ZIP intake<br/>[app.py]"]
  node_project_state["Project file state<br/>[app.py]"]
end

subgraph group_analysis["Code Analysis"]
  node_parser["Code parser<br/>[parse_code.py]"]
  node_language["Language detection<br/>[summarize.py]"]
  node_structured["Structured explanation<br/>[summarize.py]"]
  node_advanced["Supplemental analysis<br/>[summarize.py]"]
  node_project_overview["Project overview<br/>[summarize.py]"]
  node_local["Local fallback<br/>[summarize.py]"]
  node_review["Code review<br/>[review.py]"]
end

subgraph group_outputs["Results"]
  node_summary_view["Summary display<br/>[summary.html]"]
end

node_user(("Code author"))
node_groq["Groq API"]

node_user -->|"submits code"| node_web
node_web -->|"posts input"| node_flask
node_user -->|"provides file"| node_cli
node_cli -->|"posts input"| node_flask
node_flask -->|"parses upload"| node_parser
node_flask -->|"requests summary"| node_structured
node_flask -->|"requests analysis"| node_advanced
node_flask -->|"detects language"| node_language
node_flask -->|"handles ZIP"| node_project_upload
node_project_upload -->|"stores project"| node_project_state
node_project_upload -->|"requests overview"| node_project_overview
node_flask -->|"reads selected file"| node_project_state
node_structured -->|"requests analysis"| node_groq
node_structured -->|"falls back"| node_local
node_flask -->|"renders summary"| node_summary_view
node_web -.->|"displays response"| node_summary_view
node_review -.->|"provides findings"| node_structured

click node_web "https://github.com/gopal-md/code-summarizer/blob/main/static/js/chat.js"
click node_cli "https://github.com/gopal-md/code-summarizer/blob/main/cli.py"
click node_flask "https://github.com/gopal-md/code-summarizer/blob/main/app.py"
click node_project_upload "https://github.com/gopal-md/code-summarizer/blob/main/app.py"
click node_project_state "https://github.com/gopal-md/code-summarizer/blob/main/app.py"
click node_parser "https://github.com/gopal-md/code-summarizer/blob/main/src/parse_code.py"
click node_language "https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py"
click node_structured "https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py"
click node_advanced "https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py"
click node_project_overview "https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py"
click node_local "https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py"
click node_review "https://github.com/gopal-md/code-summarizer/blob/main/src/review.py"
click node_summary_view "https://github.com/gopal-md/code-summarizer/blob/main/templates/summary.html"

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_web,node_cli toneBlue
class node_flask,node_project_upload,node_project_state toneAmber
class node_parser,node_language,node_structured,node_advanced,node_project_overview,node_local,node_review,node_groq toneMint
class node_summary_view toneRose
class node_user toneIndigo
```

## Components

### User Interfaces

- [Browser client](https://github.com/gopal-md/code-summarizer/blob/main/static/js/chat.js): `static/js/chat.js`
- [CLI client](https://github.com/gopal-md/code-summarizer/blob/main/cli.py): `cli.py`

### Request Intake

- [Summarize API](https://github.com/gopal-md/code-summarizer/blob/main/app.py): `app.py`
- [Project ZIP intake](https://github.com/gopal-md/code-summarizer/blob/main/app.py): `app.py`
- [Project file state](https://github.com/gopal-md/code-summarizer/blob/main/app.py): `app.py`

### Code Analysis

- [Code parser](https://github.com/gopal-md/code-summarizer/blob/main/src/parse_code.py): `src/parse_code.py`
- [Language detection](https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py): `src/summarize.py`
- [Structured explanation](https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py): `src/summarize.py`
- [Supplemental analysis](https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py): `src/summarize.py`
- [Project overview](https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py): `src/summarize.py`
- [Local fallback](https://github.com/gopal-md/code-summarizer/blob/main/src/summarize.py): `src/summarize.py`
- [Code review](https://github.com/gopal-md/code-summarizer/blob/main/src/review.py): `src/review.py`

### Results

- [Summary display](https://github.com/gopal-md/code-summarizer/blob/main/templates/summary.html): `templates/summary.html`

### Other components

- **Code author**
- **Groq API**

## Connections

- Code author → Browser client: submits code (evidence: `README.md`)
- Browser client → Summarize API: posts input (evidence: `static/js/chat.js`)
- Code author → CLI client: provides file (evidence: `cli.py`)
- CLI client → Summarize API: posts input (evidence: `cli.py`)
- Summarize API → Code parser: parses upload (evidence: `app.py`)
- Summarize API → Structured explanation: requests summary (evidence: `app.py`)
- Summarize API → Supplemental analysis: requests analysis (evidence: `app.py`)
- Summarize API → Language detection: detects language (evidence: `app.py`)
- Summarize API → Project ZIP intake: handles ZIP (evidence: `app.py`)
- Project ZIP intake → Project file state: stores project (evidence: `app.py`)
- Project ZIP intake → Project overview: requests overview (evidence: `app.py`)
- Summarize API → Project file state: reads selected file (evidence: `app.py`)
- Structured explanation → Groq API: requests analysis (evidence: `src/summarize.py`)
- Structured explanation → Local fallback: falls back (evidence: `src/summarize.py`)
- Summarize API → Summary display: renders summary (evidence: `app.py`)
- Browser client → Summary display: displays response
- Code review → Structured explanation: provides findings
