# based-watermelon/pesu_reimagined architecture

> Architecture diagram of the GitHub repository based-watermelon/pesu_reimagined, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/based-watermelon/pesu_reimagined
- Repository: https://github.com/based-watermelon/pesu_reimagined

## Overview

PESU Reimagined is a FastAPI-backed university portal assistant with student, faculty, parent, and guest modes. Users log in to retrieve academic records or ask role-aware questions; guests can ask about public university information. The main flow combines portal data, role filtering, institutional knowledge retrieval, and Gemini-generated answers. The README describes a future portal-replacement goal but gives little architectural detail; links for frontend interactions are therefore not inferred from the HTML files, which were not sampled.

Main entry points: [`root/main.py`](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/main.py) (FastAPI routes), [`root/ai_handler.py`](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/ai_handler.py) (AI response generation), [`root/security.py`](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/security.py) (Prompt assembly), [`root/data_fetcher.py`](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/data_fetcher.py) (Student records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and sessions"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_sessions["Session management<br/>[auth.py]"]
  node_data_cache[("Session data cache<br/>[main.py]")]
end

subgraph group_portal["University data"]
  node_student_fetch["Student records<br/>[data_fetcher.py]"]
  node_faculty_fetch["Faculty records<br/>[data_fetcher.py]"]
  node_guest_fetch["Guest information<br/>[data_fetcher.py]"]
end

subgraph group_assistant["AI assistant"]
  node_role_filter["Role data filtering<br/>[security.py]"]
  node_context["Prompt assembly<br/>[security.py]"]
  node_knowledge["Institutional knowledge"]
  node_rag["Knowledge retrieval<br/>[rag.py]"]
  node_ai["AI response generation<br/>[ai_handler.py]"]
end

subgraph group_client["Web interface"]
  node_frontend["Login and dashboard"]
end

node_user(("Portal user"))
node_pesu{{"PESU Academy"}}
node_gemini{{"Gemini API"}}

node_user -->|"uses"| node_frontend
node_frontend -.->|"requests"| node_api
node_api -->|"creates or checks"| node_sessions
node_api -->|"deletes"| node_sessions
node_api -->|"fetches records"| node_student_fetch
node_api -->|"fetches records"| node_faculty_fetch
node_api -->|"loads public data"| node_guest_fetch
node_student_fetch -->|"reads portal data"| node_pesu
node_faculty_fetch -->|"reads portal data"| node_pesu
node_api -->|"stores and reads"| node_data_cache
node_api -->|"filters chat data"| node_role_filter
node_role_filter -->|"supplies filtered data"| node_context
node_context -->|"retrieves context"| node_rag
node_knowledge -->|"loads text"| node_rag
node_context -->|"builds prompt"| node_ai
node_api -->|"submits prompt"| node_ai
node_ai -.->|"generates answer"| node_gemini
node_ai -->|"returns answer"| node_api

click node_api "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/main.py"
click node_sessions "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/auth.py"
click node_data_cache "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/main.py"
click node_student_fetch "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/data_fetcher.py"
click node_faculty_fetch "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/data_fetcher.py"
click node_guest_fetch "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/data_fetcher.py"
click node_role_filter "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/security.py"
click node_context "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/security.py"
click node_knowledge "https://github.com/based-watermelon/pesu_reimagined/tree/main/root/knowledge"
click node_rag "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/rag.py"
click node_ai "https://github.com/based-watermelon/pesu_reimagined/blob/main/root/ai_handler.py"
click node_frontend "https://github.com/based-watermelon/pesu_reimagined/tree/main/root/frontend"

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_sessions,node_data_cache,node_user toneBlue
class node_student_fetch,node_faculty_fetch,node_guest_fetch toneAmber
class node_role_filter,node_context,node_knowledge,node_rag,node_ai,node_gemini toneMint
class node_frontend toneRose
class node_pesu toneIndigo
```

## Components

### API and sessions

- [FastAPI routes](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/main.py): `root/main.py`
- [Session management](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/auth.py): `root/auth.py`
- [Session data cache](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/main.py): `root/main.py`

### University data

- [Student records](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/data_fetcher.py): `root/data_fetcher.py`
- [Faculty records](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/data_fetcher.py): `root/data_fetcher.py`
- [Guest information](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/data_fetcher.py): `root/data_fetcher.py`

### AI assistant

- [Role data filtering](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/security.py): `root/security.py`
- [Prompt assembly](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/security.py): `root/security.py`
- [Institutional knowledge](https://github.com/based-watermelon/pesu_reimagined/tree/main/root/knowledge): `root/knowledge`
- [Knowledge retrieval](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/rag.py): `root/rag.py`
- [AI response generation](https://github.com/based-watermelon/pesu_reimagined/blob/main/root/ai_handler.py): `root/ai_handler.py`

### Web interface

- [Login and dashboard](https://github.com/based-watermelon/pesu_reimagined/tree/main/root/frontend): `root/frontend`

### Other components

- **Portal user**
- **PESU Academy**
- **Gemini API**

## Connections

- Portal user → Login and dashboard: uses
- Login and dashboard → FastAPI routes: requests
- FastAPI routes → Session management: creates or checks
- FastAPI routes → Session management: deletes
- FastAPI routes → Student records: fetches records
- FastAPI routes → Faculty records: fetches records
- FastAPI routes → Guest information: loads public data
- Student records → PESU Academy: reads portal data
- Faculty records → PESU Academy: reads portal data
- FastAPI routes → Session data cache: stores and reads
- FastAPI routes → Role data filtering: filters chat data
- Role data filtering → Prompt assembly: supplies filtered data
- Prompt assembly → Knowledge retrieval: retrieves context
- Institutional knowledge → Knowledge retrieval: loads text
- Prompt assembly → AI response generation: builds prompt
- FastAPI routes → AI response generation: submits prompt
- AI response generation → Gemini API: generates answer
- AI response generation → FastAPI routes: returns answer
