How arunktr123/anonymous-pdf-reader works
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: main.py API application · __init__.py Route registry · pdfs.py PDF routes · models.py Domain models
Components 16
React Client
- Client entry
frontend/src/main.jsx - App coordinator · Selects the home and in-session views.
frontend/src/App.jsx - Home page · Anonymous session discovery and creation.
frontend/src/components/HomePage.jsx - Session page · In-room PDF and discussion experience.
frontend/src/components/SessionPage.jsx - API client · Centralizes browser calls to the backend.
frontend/src/services/api.js
Python API
- API application · Serves the application and OpenAPI docs.
backend/main.py - Route registry
backend/app/routes/__init__.py - Session routes · Creates, finds, and joins anonymous rooms.
backend/app/routes/sessions.py - PDF routes · Handles upload, download, and random PDF allocation.
backend/app/routes/pdfs.py - Chat routes · Handles session-scoped messaging transport.
backend/app/routes/chat.py - PDF helpers · Supports file handling and allocation outside request handlers.
backend/app/utils/helpers.py - Runtime settings
backend/app/config.py - Database access
backend/app/database.py
Persistence
- Domain models · Session and related persisted entities.
backend/app/models/models.py - API schemas
backend/app/schemas/schemas.py - MySQL schema · Defines the MySQL persistence target.
backend/database_schema.sql
Connections 21
- 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