# arunktr123/anonymous-pdf-reader architecture

> Architecture diagram of the GitHub repository arunktr123/anonymous-pdf-reader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arunktr123/anonymous-pdf-reader
- Repository: https://github.com/arunktr123/anonymous-pdf-reader

## Overview

#### Purpose and entry points
Anonymous PDF Reader Chat provides session-based rooms where anonymous participants receive PDFs, discuss them in real time, and upload or download documents. The backend starts from `backend/main.py`; the Vite React client starts from `frontend/src/main.jsx` and renders `frontend/src/App.jsx`. Backend OpenAPI documentation is exposed at `/docs`.

#### Backend application boundary
The Python backend is organized as an API application with configuration and persistence separated from route handlers:
- `backend/main.py` creates and serves the application.
- `backend/app/config.py` centralizes runtime settings.
- `backend/app/database.py` establishes database access.
- `backend/app/routes/__init__.py` groups route modules into the application surface.

HTTP/API handling is the boundary between the browser client and session, PDF, and chat operations.

#### Session lifecycle and anonymous participation
Session creation, lookup, and participation are handled by `backend/app/routes/sessions.py`. This is the room-level control plane: clients enter a shared session without an identified user account, and subsequent PDF/chat actions are scoped to that session.

Persistent session and related domain entities are represented in:
- `backend/app/models/models.py`
- `backend/app/schemas/schemas.py`
- `backend/database_schema.sql`

Models define database-facing entities; schemas define API request/response contracts.

#### PDF ingestion, allocation, and delivery
PDF-specific operations are isolated in `backend/app/routes/pdfs.py`. This route layer owns upload/download-facing API behavior and the application’s random PDF allocation feature. Supporting non-route logic is kept under `backend/app/utils/helpers.py`, separating reusable file or allocation behavior from request handling.

The PDF boundary is material: uploaded document content must move between client requests, backend processing/storage, and session-scoped assignment without leaking across rooms.

#### Real-time chat flow
`backend/app/routes/chat.py` provides the chat-facing backend endpoint(s), likely including the real-time transport required by the stated chat feature. The key flow is: a session participant connects through the frontend, sends or receives session-scoped messages through the chat route, and backend persistence/domain models retain the relevant state where configured.

Chat is deliberately separate from `sessions.py`: sessions establish room context, while chat handles ongoing communication within it.

#### Frontend composition and API integration
The React client has two primary user-interface states:
- `frontend/src/components/HomePage.jsx` is the session discovery/creation entry experience.
- `frontend/src/components/SessionPage.jsx` is the in-room PDF and discussion experience.
- `frontend/src/services/api.js` is the client’s backend integration boundary.

`frontend/src/App.jsx` selects or coordinates these views. UI state and browser interactions should call `api.js`, rather than embedding backend transport details in page components.

#### Runtime and infrastructure
The backend runs on Python with dependencies declared in `backend/requirements.txt` and targets MySQL via `backend/database_schema.sql`. The frontend runs as a Vite-built React application (`frontend/package.json`, `frontend/vite.config.js`) and includes Vercel deployment configuration in `frontend/vercel.json`. Development defaults are backend `localhost:8000` and frontend `localhost:3000`.

Main entry points: [`backend/main.py`](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/main.py) (API application), [`backend/app/routes/__init__.py`](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/__init__.py) (Route registry), [`backend/app/routes/pdfs.py`](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/pdfs.py) (PDF routes), [`backend/app/models/models.py`](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/models/models.py) (Domain models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React Client"]
  node_client_entry["Client entry<br/>Vite bootstrap<br/>[main.jsx]"]
  node_app["App coordinator<br/>React shell<br/>[App.jsx]"]
  node_home["Home page<br/>session UI<br/>[HomePage.jsx]"]
  node_session_page["Session page<br/>room UI<br/>[SessionPage.jsx]"]
  node_api_client["API client<br/>transport boundary<br/>[api.js]"]
end

subgraph group_backend["Python API"]
  node_backend_main["API application<br/>Python entry point<br/>[main.py]"]
  node_route_registry["Route registry<br/>API composition<br/>[__init__.py]"]
  node_sessions["Session routes<br/>room control plane<br/>[sessions.py]"]
  node_pdfs["PDF routes<br/>document API<br/>[pdfs.py]"]
  node_chat["Chat routes<br/>real-time API<br/>[chat.py]"]
  node_helpers["PDF helpers<br/>reusable logic<br/>[helpers.py]"]
  node_config["Runtime settings<br/>configuration<br/>[config.py]"]
  node_database["Database access<br/>persistence adapter<br/>[database.py]"]
end

subgraph group_data["Persistence"]
  node_models["Domain models<br/>database entities<br/>[models.py]"]
  node_schemas["API schemas<br/>request/response contracts<br/>[schemas.py]"]
  node_mysql_schema[("MySQL schema<br/>database schema")]
end

node_client_entry -->|"renders"| node_app
node_app -->|"shows"| node_home
node_app -->|"shows"| node_session_page
node_home -->|"session actions"| node_api_client
node_session_page -->|"PDF and chat actions"| node_api_client
node_api_client -->|"HTTP / real-time API"| node_backend_main
node_backend_main -->|"mounts"| node_route_registry
node_route_registry -->|"routes"| node_sessions
node_route_registry -->|"routes"| node_pdfs
node_route_registry -->|"routes"| node_chat
node_backend_main -->|"loads"| node_config
node_backend_main -->|"initializes"| node_database
node_sessions -->|"uses contracts"| node_schemas
node_pdfs -->|"uses contracts"| node_schemas
node_chat -->|"uses contracts"| node_schemas
node_pdfs -->|"delegates file/allocation logic"| node_helpers
node_sessions -->|"persists rooms"| node_models
node_pdfs -->|"scopes document assignments"| node_models
node_chat -.->|"persists configured state"| node_models
node_database -->|"accesses"| node_mysql_schema
node_models -->|"maps to"| node_mysql_schema

click node_client_entry "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/main.jsx"
click node_app "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/components/HomePage.jsx"
click node_session_page "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/components/SessionPage.jsx"
click node_api_client "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/services/api.js"
click node_backend_main "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/main.py"
click node_route_registry "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/__init__.py"
click node_sessions "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/sessions.py"
click node_pdfs "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/pdfs.py"
click node_chat "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/chat.py"
click node_helpers "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/utils/helpers.py"
click node_config "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/config.py"
click node_database "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/database.py"
click node_models "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/models/models.py"
click node_schemas "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/schemas/schemas.py"
click node_mysql_schema "https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/database_schema.sql"

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_client_entry,node_app,node_home,node_session_page,node_api_client toneBlue
class node_backend_main,node_route_registry,node_sessions,node_pdfs,node_chat,node_helpers,node_config,node_database toneAmber
class node_models,node_schemas,node_mysql_schema toneMint
```

## Components

### React Client

- [Client entry](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/main.jsx): Vite bootstrap · `frontend/src/main.jsx`
- [App coordinator](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/App.jsx): React shell · Selects the home and in-session views. · `frontend/src/App.jsx`
- [Home page](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/components/HomePage.jsx): session UI · Anonymous session discovery and creation. · `frontend/src/components/HomePage.jsx`
- [Session page](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/components/SessionPage.jsx): room UI · In-room PDF and discussion experience. · `frontend/src/components/SessionPage.jsx`
- [API client](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/frontend/src/services/api.js): transport boundary · Centralizes browser calls to the backend. · `frontend/src/services/api.js`

### Python API

- [API application](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/main.py): Python entry point · Serves the application and OpenAPI docs. · `backend/main.py`
- [Route registry](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/__init__.py): API composition · `backend/app/routes/__init__.py`
- [Session routes](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/sessions.py): room control plane · Creates, finds, and joins anonymous rooms. · `backend/app/routes/sessions.py`
- [PDF routes](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/pdfs.py): document API · Handles upload, download, and random PDF allocation. · `backend/app/routes/pdfs.py`
- [Chat routes](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/routes/chat.py): real-time API · Handles session-scoped messaging transport. · `backend/app/routes/chat.py`
- [PDF helpers](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/utils/helpers.py): reusable logic · Supports file handling and allocation outside request handlers. · `backend/app/utils/helpers.py`
- [Runtime settings](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/config.py): configuration · `backend/app/config.py`
- [Database access](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/database.py): persistence adapter · `backend/app/database.py`

### Persistence

- [Domain models](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/models/models.py): database entities · Session and related persisted entities. · `backend/app/models/models.py`
- [API schemas](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/app/schemas/schemas.py): request/response contracts · `backend/app/schemas/schemas.py`
- [MySQL schema](https://github.com/arunktr123/anonymous-pdf-reader/blob/main/backend/database_schema.sql): database schema · Defines the MySQL persistence target. · `backend/database_schema.sql`

## Connections

- Client entry → App coordinator: renders
- App coordinator → Home page: shows
- App coordinator → Session page: shows
- Home page → API client: session actions
- Session page → API client: PDF and chat actions
- API client → API application: HTTP / real-time API
- API application → Route registry: mounts
- Route registry → Session routes: routes
- Route registry → PDF routes: routes
- Route registry → Chat routes: routes
- API application → Runtime settings: loads
- API application → Database access: initializes
- Session routes → API schemas: uses contracts
- PDF routes → API schemas: uses contracts
- Chat routes → API schemas: uses contracts
- PDF routes → PDF helpers: delegates file/allocation logic
- Session routes → Domain models: persists rooms
- PDF routes → Domain models: scopes document assignments
- Chat routes → Domain models: persists configured state
- Database access → MySQL schema: accesses
- Domain models → MySQL schema: maps to
