# narendra2904/jntuh-backend architecture

> Architecture diagram of the GitHub repository narendra2904/jntuh-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/narendra2904/jntuh-backend
- Repository: https://github.com/narendra2904/jntuh-backend

## Overview

Backbenchers’ repository is the FastAPI results backend: a hall-ticket request checks Redis, falls back to SQLite, and on a miss scrapes JNTUH, normalizes the semester results, then persists them. The scraper uses exam-code and branch-code reference data and a bundled college PDF. The README also describes a separate frontend with analytics, AI, and ecosystem features; those are represented only as an external client, not as backend modules. Relationships shown below are supported by the excerpts or README; the frontend’s internal behavior is outside this tree.

Main entry points: [`scraper.py`](https://github.com/narendra2904/jntuh-backend/blob/main/scraper.py) (Result scraper), [`main.py`](https://github.com/narendra2904/jntuh-backend/blob/main/main.py) (Results API), [`exam_codes.py`](https://github.com/narendra2904/jntuh-backend/blob/main/exam_codes.py) (Exam codes), [`branch_codes.py`](https://github.com/narendra2904/jntuh-backend/blob/main/branch_codes.py) (Branch codes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API orchestration"]
  node_api["Results API<br/>[main.py]"]
end

subgraph group_acquisition["Result acquisition"]
  node_scraper["Result scraper<br/>[scraper.py]"]
  node_exam_codes["Exam codes<br/>[exam_codes.py]"]
  node_branch_codes["Branch codes<br/>[branch_codes.py]"]
  node_college_pdf["College directory"]
end

subgraph group_persistence["Persistence"]
  node_cache[("Redis cache<br/>[cache.py]")]
  node_database[("SQLite results<br/>[database.py]")]
end

node_student(("Student"))
node_frontend["Frontend portal"]
node_jntuh["JNTUH results"]

node_student -->|"requests results"| node_frontend
node_frontend -->|"proxies requests"| node_api
node_api -->|"checks / writes"| node_cache
node_api -->|"reads / saves"| node_database
node_api -->|"scrapes on miss"| node_scraper
node_scraper -->|"fetches results"| node_jntuh
node_scraper -->|"iterates codes"| node_exam_codes
node_scraper -->|"looks up branch"| node_branch_codes
node_scraper -->|"loads directory"| node_college_pdf

click node_api "https://github.com/narendra2904/jntuh-backend/blob/main/main.py"
click node_scraper "https://github.com/narendra2904/jntuh-backend/blob/main/scraper.py"
click node_exam_codes "https://github.com/narendra2904/jntuh-backend/blob/main/exam_codes.py"
click node_branch_codes "https://github.com/narendra2904/jntuh-backend/blob/main/branch_codes.py"
click node_college_pdf "https://github.com/narendra2904/jntuh-backend/blob/main/data/btech_mba_centers_reviewed.pdf"
click node_cache "https://github.com/narendra2904/jntuh-backend/blob/main/cache.py"
click node_database "https://github.com/narendra2904/jntuh-backend/blob/main/database.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_api,node_frontend toneBlue
class node_scraper,node_exam_codes,node_branch_codes,node_college_pdf toneAmber
class node_cache,node_database toneMint
class node_student,node_jntuh toneIndigo
```

## Components

### API orchestration

- [Results API](https://github.com/narendra2904/jntuh-backend/blob/main/main.py): `main.py`

### Result acquisition

- [Result scraper](https://github.com/narendra2904/jntuh-backend/blob/main/scraper.py): `scraper.py`
- [Exam codes](https://github.com/narendra2904/jntuh-backend/blob/main/exam_codes.py): `exam_codes.py`
- [Branch codes](https://github.com/narendra2904/jntuh-backend/blob/main/branch_codes.py): `branch_codes.py`
- [College directory](https://github.com/narendra2904/jntuh-backend/blob/main/data/btech_mba_centers_reviewed.pdf): `data/btech_mba_centers_reviewed.pdf`

### Persistence

- [Redis cache](https://github.com/narendra2904/jntuh-backend/blob/main/cache.py): `cache.py`
- [SQLite results](https://github.com/narendra2904/jntuh-backend/blob/main/database.py): `database.py`

### Other components

- **Student**
- **Frontend portal**
- **JNTUH results**

## Connections

- Student → Frontend portal: requests results (evidence: `README.md`)
- Frontend portal → Results API: proxies requests (evidence: `README.md`)
- Results API → Redis cache: checks / writes (evidence: `main.py`)
- Results API → SQLite results: reads / saves (evidence: `main.py`)
- Results API → Result scraper: scrapes on miss (evidence: `main.py`)
- Result scraper → JNTUH results: fetches results (evidence: `scraper.py`)
- Result scraper → Exam codes: iterates codes (evidence: `scraper.py`)
- Result scraper → Branch codes: looks up branch (evidence: `scraper.py`)
- Result scraper → College directory: loads directory (evidence: `scraper.py`)
