# movoid12/quiz-my-pdf architecture

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

- Interactive diagram: https://gitdiagram.com/movoid12/quiz-my-pdf
- Repository: https://github.com/movoid12/quiz-my-pdf

## Overview

Quiz My PDF lets signed-in users turn PDFs into AI-generated quizzes, answer them, and review saved attempts. The main generation route validates and scans uploads, extracts and sanitizes text, generates questions, then persists quiz content; the quiz router handles retrieval, scoring, history, and results. Authentication includes Google sign-in and two-factor setup. The README describes database-backed operation, and the sampled generation and auth code use Drizzle. Dashboard pages and other capabilities are included from the file tree, but their client-side wiring was not sampled, so uncertain links are omitted.

Main entry points: [`src/app/api/process-pdf/route.ts`](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/api/process-pdf/route.ts) (PDF processing), [`src/server/db/index.ts`](https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/db/index.ts) (PostgreSQL), [`src/app/page.tsx`](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/page.tsx) (Home), [`src/components/sections/pdf-upload-section.tsx`](https://github.com/movoid12/quiz-my-pdf/blob/main/src/components/sections/pdf-upload-section.tsx) (PDF upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User experience"]
  node_home["Home<br/>[page.tsx]"]
  node_upload["PDF upload"]
  node_start["Quiz start<br/>[page.tsx]"]
  node_quizview["Take quiz<br/>[page.tsx]"]
  node_results["Attempt results<br/>[page.tsx]"]
  node_history["Quiz history<br/>[page.tsx]"]
  node_profile["Profile<br/>[page.tsx]"]
end

subgraph group_identity["Authentication"]
  node_authforms["Auth forms<br/>[sign-up-form.tsx]"]
  node_authclient["Auth client<br/>[auth-client.ts]"]
  node_authroute["Auth endpoint<br/>[route.ts]"]
  node_authservice["Auth service<br/>[auth.ts]"]
end

subgraph group_generation["Quiz generation"]
  node_process["PDF processing<br/>[route.ts]"]
  node_pdfscan["PDF validation<br/>[pdf-scanner.ts]"]
  node_extract["Text extraction<br/>[extract-text.ts]"]
  node_generator["AI generation<br/>[generate-quiz.ts]"]
end

subgraph group_quizdata["Quiz and attempts"]
  node_trpcroute["tRPC endpoint<br/>[route.ts]"]
  node_quizrouter["Quiz operations<br/>[quiz.ts]"]
  node_database[("PostgreSQL<br/>[index.ts]")]
end

node_learner(("Learner"))
node_gemini{{"Google Gemini"}}

node_learner -->|"opens app"| node_home
node_home -->|"navigates to"| node_start
node_learner -->|"provides PDF"| node_upload
node_upload -->|"submits PDF"| node_process
node_process -->|"scans PDF"| node_pdfscan
node_process -->|"extracts text"| node_extract
node_process -->|"generates quiz"| node_generator
node_generator -.->|"requests generation"| node_gemini
node_process -->|"writes quiz data"| node_database
node_learner -->|"signs in"| node_authforms
node_authforms -->|"calls auth"| node_authclient
node_authclient -->|"sends auth request"| node_authroute
node_authroute -->|"dispatches request"| node_authservice
node_authservice -->|"reads and writes"| node_database
node_learner -->|"answers questions"| node_quizview
node_quizview -->|"quiz requests"| node_trpcroute
node_trpcroute -->|"dispatches procedures"| node_quizrouter
node_quizrouter -->|"reads and writes"| node_database
node_learner -->|"views attempts"| node_history
node_learner -->|"reviews attempt"| node_results
node_learner -->|"manages profile"| node_profile

click node_home "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/page.tsx"
click node_upload "https://github.com/movoid12/quiz-my-pdf/blob/main/src/components/sections/pdf-upload-section.tsx"
click node_start "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/start/page.tsx"
click node_quizview "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/quiz/%5BquizId%5D/page.tsx"
click node_results "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/result/%5BattemptId%5D/page.tsx"
click node_history "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/history/page.tsx"
click node_profile "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/profile/page.tsx"
click node_authforms "https://github.com/movoid12/quiz-my-pdf/blob/main/src/components/auth/sign-up-form.tsx"
click node_authclient "https://github.com/movoid12/quiz-my-pdf/blob/main/src/lib/auth-client.ts"
click node_authroute "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/api/auth/%5B...all%5D/route.ts"
click node_authservice "https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/auth.ts"
click node_process "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/api/process-pdf/route.ts"
click node_pdfscan "https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/pdf/pdf-scanner.ts"
click node_extract "https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/pdf/extract-text.ts"
click node_generator "https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/ai/generate-quiz.ts"
click node_trpcroute "https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/api/trpc/%5Btrpc%5D/route.ts"
click node_quizrouter "https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/routers/quiz.ts"
click node_database "https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/db/index.ts"

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_home,node_upload,node_start,node_quizview,node_results,node_history,node_profile toneBlue
class node_authforms,node_authclient,node_authroute,node_authservice toneAmber
class node_process,node_pdfscan,node_extract,node_generator toneMint
class node_trpcroute,node_quizrouter,node_database toneRose
class node_learner,node_gemini toneIndigo
```

## Components

### User experience

- [Home](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [PDF upload](https://github.com/movoid12/quiz-my-pdf/blob/main/src/components/sections/pdf-upload-section.tsx): `src/components/sections/pdf-upload-section.tsx`
- [Quiz start](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/start/page.tsx): `src/app/dashboard/start/page.tsx`
- [Take quiz](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/quiz/%5BquizId%5D/page.tsx): `src/app/dashboard/quiz/[quizId]/page.tsx`
- [Attempt results](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/result/%5BattemptId%5D/page.tsx): `src/app/dashboard/result/[attemptId]/page.tsx`
- [Quiz history](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/history/page.tsx): `src/app/dashboard/history/page.tsx`
- [Profile](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/dashboard/profile/page.tsx): `src/app/dashboard/profile/page.tsx`

### Authentication

- [Auth forms](https://github.com/movoid12/quiz-my-pdf/blob/main/src/components/auth/sign-up-form.tsx): `src/components/auth/sign-up-form.tsx`
- [Auth client](https://github.com/movoid12/quiz-my-pdf/blob/main/src/lib/auth-client.ts): `src/lib/auth-client.ts`
- [Auth endpoint](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/api/auth/%5B...all%5D/route.ts): `src/app/api/auth/[...all]/route.ts`
- [Auth service](https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/auth.ts): `src/server/auth.ts`

### Quiz generation

- [PDF processing](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/api/process-pdf/route.ts): `src/app/api/process-pdf/route.ts`
- [PDF validation](https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/pdf/pdf-scanner.ts): `src/server/pdf/pdf-scanner.ts`
- [Text extraction](https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/pdf/extract-text.ts): `src/server/pdf/extract-text.ts`
- [AI generation](https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/ai/generate-quiz.ts): `src/server/ai/generate-quiz.ts`

### Quiz and attempts

- [tRPC endpoint](https://github.com/movoid12/quiz-my-pdf/blob/main/src/app/api/trpc/%5Btrpc%5D/route.ts): `src/app/api/trpc/[trpc]/route.ts`
- [Quiz operations](https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/routers/quiz.ts): `src/server/routers/quiz.ts`
- [PostgreSQL](https://github.com/movoid12/quiz-my-pdf/blob/main/src/server/db/index.ts): `src/server/db/index.ts`

### Other components

- **Learner**
- **Google Gemini**

## Connections

- Learner → Home: opens app
- Home → Quiz start: navigates to
- Learner → PDF upload: provides PDF
- PDF upload → PDF processing: submits PDF
- PDF processing → PDF validation: scans PDF
- PDF processing → Text extraction: extracts text
- PDF processing → AI generation: generates quiz
- AI generation → Google Gemini: requests generation
- PDF processing → PostgreSQL: writes quiz data
- Learner → Auth forms: signs in
- Auth forms → Auth client: calls auth
- Auth client → Auth endpoint: sends auth request
- Auth endpoint → Auth service: dispatches request
- Auth service → PostgreSQL: reads and writes
- Learner → Take quiz: answers questions
- Take quiz → tRPC endpoint: quiz requests
- tRPC endpoint → Quiz operations: dispatches procedures
- Quiz operations → PostgreSQL: reads and writes
- Learner → Quiz history: views attempts
- Learner → Attempt results: reviews attempt
- Learner → Profile: manages profile
