# bhanuteja856/archi-ai-exam-prep architecture

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

- Interactive diagram: https://gitdiagram.com/bhanuteja856/archi-ai-exam-prep
- Repository: https://github.com/bhanuteja856/archi-ai-exam-prep

## Overview

Exam Prep AI is a mobile study app that turns an uploaded PDF into a timed practice quiz, presents the quiz and score, and saves results for later review. The main path runs from the React Native app through its API service to the Express backend, which extracts PDF text and attempts to use the Python quiz agent; the backend also has a direct Gemini generation path. Firebase supplies authentication, profiles, and quiz history, with local fallbacks. The excerpts show these main calls, but not the Express-to-agent request details or all quiz-screen logic.

Main entry points: [`mobile/App.js`](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/App.js) (Quiz app UI), [`server/index.js`](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/index.js) (HTTP API), [`mobile/src/services/firebase.js`](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/src/services/firebase.js) (Auth and data service), [`server/agent/quiz_agent.py`](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/quiz_agent.py) (Quiz orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_app["Quiz app UI<br/>[App.js]"]
  node_quiz_attempt["Quiz attempt<br/>[App.js]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_backend["Quiz backend"]
  node_express["HTTP API<br/>[index.js]"]
  node_pdf_extract["PDF extraction<br/>[index.js]"]
  node_direct_gemini["Direct Gemini generation<br/>[index.js]"]
end

subgraph group_agent["AI agent"]
  node_fastapi["Agent API<br/>[main.py]"]
  node_agent_pdf["Agent PDF indexing<br/>[main.py]"]
  node_quiz_agent["Quiz orchestration<br/>[quiz_agent.py]"]
  node_study_retrieval["Study text retrieval<br/>[quiz_agent.py]"]
  node_web_search["Web search<br/>[quiz_agent.py]"]
end

subgraph group_persistence["Identity and history"]
  node_firebase_service["Auth and data service<br/>[firebase.js]"]
end

node_student(("Student"))
node_gemini{{"Google Gemini"}}
node_tavily{{"Tavily search"}}
node_firebase_auth{{"Firebase Auth"}}
node_firestore[("Cloud Firestore")]

node_student -->|"uses"| node_app
node_app -->|"requests quiz"| node_api
node_api -->|"posts PDF"| node_express
node_express -->|"extracts text"| node_pdf_extract
node_express -->|"routes generation"| node_fastapi
node_fastapi -->|"indexes text"| node_agent_pdf
node_fastapi -->|"generates quiz"| node_quiz_agent
node_quiz_agent -->|"retrieves context"| node_study_retrieval
node_quiz_agent -->|"searches updates"| node_web_search
node_web_search -->|"queries"| node_tavily
node_quiz_agent -->|"generates questions"| node_gemini
node_express -->|"fallback generation"| node_direct_gemini
node_direct_gemini -->|"generates questions"| node_gemini
node_express -->|"returns quiz"| node_api
node_app -->|"presents quiz"| node_quiz_attempt
node_quiz_attempt -->|"saves results"| node_firebase_service
node_app -->|"loads history and profile"| node_firebase_service
node_app -->|"authenticates"| node_firebase_service
node_firebase_service -->|"signs in users"| node_firebase_auth
node_firebase_service -->|"reads and writes"| node_firestore

click node_app "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/App.js"
click node_quiz_attempt "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/App.js"
click node_api "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/src/services/api.js"
click node_express "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/index.js"
click node_pdf_extract "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/index.js"
click node_direct_gemini "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/index.js"
click node_fastapi "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/main.py"
click node_agent_pdf "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/main.py"
click node_quiz_agent "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/quiz_agent.py"
click node_study_retrieval "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/quiz_agent.py"
click node_web_search "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/quiz_agent.py"
click node_firebase_service "https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/src/services/firebase.js"

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_app,node_quiz_attempt,node_api toneBlue
class node_express,node_pdf_extract,node_direct_gemini,node_firestore toneAmber
class node_fastapi,node_agent_pdf,node_quiz_agent,node_study_retrieval,node_web_search toneMint
class node_firebase_service toneRose
class node_student,node_gemini,node_tavily,node_firebase_auth toneIndigo
```

## Components

### Mobile app

- [Quiz app UI](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/App.js): `mobile/App.js`
- [Quiz attempt](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/App.js): `mobile/App.js`
- [API client](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/src/services/api.js): `mobile/src/services/api.js`

### Quiz backend

- [HTTP API](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/index.js): `server/index.js`
- [PDF extraction](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/index.js): `server/index.js`
- [Direct Gemini generation](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/index.js): `server/index.js`

### AI agent

- [Agent API](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/main.py): `server/agent/main.py`
- [Agent PDF indexing](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/main.py): `server/agent/main.py`
- [Quiz orchestration](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/quiz_agent.py): `server/agent/quiz_agent.py`
- [Study text retrieval](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/quiz_agent.py): `server/agent/quiz_agent.py`
- [Web search](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/server/agent/quiz_agent.py): `server/agent/quiz_agent.py`

### Identity and history

- [Auth and data service](https://github.com/bhanuteja856/archi-ai-exam-prep/blob/main/mobile/src/services/firebase.js): `mobile/src/services/firebase.js`

### Other components

- **Student**
- **Google Gemini**
- **Tavily search**
- **Firebase Auth**
- **Cloud Firestore**

## Connections

- Student → Quiz app UI: uses (evidence: `mobile/App.js`)
- Quiz app UI → API client: requests quiz (evidence: `mobile/App.js`)
- API client → HTTP API: posts PDF (evidence: `mobile/src/services/api.js`)
- HTTP API → PDF extraction: extracts text (evidence: `server/index.js`)
- HTTP API → Agent API: routes generation (evidence: `server/index.js`)
- Agent API → Agent PDF indexing: indexes text (evidence: `server/agent/main.py`)
- Agent API → Quiz orchestration: generates quiz (evidence: `server/agent/main.py`)
- Quiz orchestration → Study text retrieval: retrieves context (evidence: `server/agent/quiz_agent.py`)
- Quiz orchestration → Web search: searches updates (evidence: `server/agent/quiz_agent.py`)
- Web search → Tavily search: queries (evidence: `server/agent/quiz_agent.py`)
- Quiz orchestration → Google Gemini: generates questions (evidence: `server/agent/quiz_agent.py`)
- HTTP API → Direct Gemini generation: fallback generation (evidence: `server/index.js`)
- Direct Gemini generation → Google Gemini: generates questions (evidence: `server/index.js`)
- HTTP API → API client: returns quiz (evidence: `mobile/src/services/api.js`)
- Quiz app UI → Quiz attempt: presents quiz (evidence: `mobile/App.js`)
- Quiz attempt → Auth and data service: saves results (evidence: `mobile/App.js`)
- Quiz app UI → Auth and data service: loads history and profile (evidence: `mobile/App.js`)
- Quiz app UI → Auth and data service: authenticates (evidence: `mobile/App.js`)
- Auth and data service → Firebase Auth: signs in users (evidence: `mobile/src/services/firebase.js`)
- Auth and data service → Cloud Firestore: reads and writes (evidence: `mobile/src/services/firebase.js`)
