# alasaihi001/quizforge architecture

> Architecture diagram of the GitHub repository alasaihi001/quizforge, 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/alasaihi001/quizforge
- Repository: https://github.com/alasaihi001/quizforge

## Overview

QuizForge AI turns course material into streamed MCQs, flashcards, or summaries, with multilingual input, saved generation history, sharing, and PRO PDF export. The main workflow runs from the dashboard generation form through the API’s authentication, rate-limit, credit, prompt, and Groq steps; the client parses and renders the result. Separate branches cover accounts, subscriptions, and daily credit resets. Paths and links reflect the provided tree, excerpts, and README; unsampled details are represented only where documented, and uncertain sharing wiring is left unverified.

Main entry points: [`src/app/api/generate/route.ts`](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/generate/route.ts) (Generation API), [`src/lib/prisma.ts`](https://github.com/alasaihi001/quizforge/blob/main/src/lib/prisma.ts) (Prisma client), [`src/components/dashboard/generate-page-client.tsx`](https://github.com/alasaihi001/quizforge/blob/main/src/components/dashboard/generate-page-client.tsx) (Generation form), [`src/app/api/auth/[...nextauth]/route.ts`](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts) (Credentials auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and accounts"]
  node_auth["Credentials auth<br/>[route.ts]"]
  node_registration["Registration<br/>[register-form.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
end

subgraph group_study["Study generation"]
  node_generator["Generation form"]
  node_generate_api["Generation API<br/>[route.ts]"]
  node_prompts["Mode prompts<br/>[prompts.ts]"]
  node_groq["Groq AI"]
  node_parser["Result parser<br/>[parsers.ts]"]
  node_result_views["Result displays"]
  node_history["Generation history<br/>[page.tsx]"]
  node_sharing["Public share links<br/>[page.tsx]"]
  node_share_api["Share endpoint<br/>[route.ts]"]
  node_pdf_ui["PDF download"]
  node_pdf_formats["PDF formats"]
end

subgraph group_plans["Plans and credits"]
  node_billing["Billing endpoints<br/>[route.ts]"]
  node_portal["Subscription portal<br/>[route.ts]"]
  node_webhook["Billing webhook<br/>[route.ts]"]
  node_stripe["Stripe"]
  node_credit_reset["Daily credit reset<br/>[route.ts]"]
end

subgraph group_platform["Persistence and services"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_postgres[("PostgreSQL")]
  node_rate_limit["Rate limiter<br/>[rate-limit.ts]"]
  node_redis[("Upstash Redis")]
end

node_student(("Student"))

node_student -->|"registers"| node_registration
node_student -->|"signs in"| node_auth
node_student -->|"uses"| node_dashboard
node_registration -.->|"creates account"| node_auth
node_auth -->|"reads users"| node_prisma
node_dashboard -->|"opens"| node_generator
node_generator -->|"submits content"| node_generate_api
node_generate_api -->|"checks session"| node_auth
node_generate_api -->|"checks limit"| node_rate_limit
node_rate_limit -->|"limits requests"| node_redis
node_generate_api -->|"checks credits"| node_prisma
node_generate_api -->|"builds prompt"| node_prompts
node_generate_api -->|"streams request"| node_groq
node_generate_api -->|"saves and decrements"| node_prisma
node_generate_api -->|"streams response"| node_generator
node_generator -->|"parses output"| node_parser
node_generator -->|"renders results"| node_result_views
node_dashboard -.->|"opens history"| node_history
node_prisma -->|"persists records"| node_postgres
node_share_api -->|"reads generation"| node_prisma
node_sharing -.->|"loads shared item"| node_share_api
node_generator -.->|"offers share link"| node_sharing
node_generator -->|"offers export"| node_pdf_ui
node_pdf_ui -->|"formats document"| node_pdf_formats
node_billing -->|"checks session"| node_auth
node_billing -->|"loads customer"| node_prisma
node_billing -->|"creates checkout"| node_stripe
node_portal -->|"creates portal"| node_stripe
node_webhook -->|"verifies events"| node_stripe
node_webhook -->|"updates plan credits"| node_prisma
node_credit_reset -->|"resets credits"| node_prisma

click node_auth "https://github.com/alasaihi001/quizforge/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts"
click node_registration "https://github.com/alasaihi001/quizforge/blob/main/src/components/auth/register-form.tsx"
click node_dashboard "https://github.com/alasaihi001/quizforge/blob/main/src/app/dashboard/page.tsx"
click node_generator "https://github.com/alasaihi001/quizforge/blob/main/src/components/dashboard/generate-page-client.tsx"
click node_generate_api "https://github.com/alasaihi001/quizforge/blob/main/src/app/api/generate/route.ts"
click node_prompts "https://github.com/alasaihi001/quizforge/blob/main/src/lib/prompts.ts"
click node_parser "https://github.com/alasaihi001/quizforge/blob/main/src/lib/parsers.ts"
click node_result_views "https://github.com/alasaihi001/quizforge/tree/main/src/components/dashboard/results"
click node_history "https://github.com/alasaihi001/quizforge/blob/main/src/app/dashboard/history/page.tsx"
click node_sharing "https://github.com/alasaihi001/quizforge/blob/main/src/app/share/%5Btoken%5D/page.tsx"
click node_share_api "https://github.com/alasaihi001/quizforge/blob/main/src/app/api/share/%5Btoken%5D/route.ts"
click node_pdf_ui "https://github.com/alasaihi001/quizforge/blob/main/src/components/dashboard/pdf-download-button.tsx"
click node_pdf_formats "https://github.com/alasaihi001/quizforge/tree/main/src/components/pdf"
click node_prisma "https://github.com/alasaihi001/quizforge/blob/main/src/lib/prisma.ts"
click node_rate_limit "https://github.com/alasaihi001/quizforge/blob/main/src/lib/rate-limit.ts"
click node_billing "https://github.com/alasaihi001/quizforge/blob/main/src/app/api/stripe/checkout/route.ts"
click node_portal "https://github.com/alasaihi001/quizforge/blob/main/src/app/api/stripe/portal/route.ts"
click node_webhook "https://github.com/alasaihi001/quizforge/blob/main/src/app/api/stripe/webhook/route.ts"
click node_credit_reset "https://github.com/alasaihi001/quizforge/blob/main/src/app/api/cron/reset-credits/route.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_auth,node_registration,node_dashboard toneBlue
class node_generator,node_generate_api,node_prompts,node_groq,node_parser,node_result_views,node_history,node_sharing,node_share_api,node_pdf_ui,node_pdf_formats toneAmber
class node_billing,node_portal,node_webhook,node_stripe,node_credit_reset toneMint
class node_prisma,node_postgres,node_rate_limit,node_redis toneRose
class node_student toneIndigo
```

## Components

### Access and accounts

- [Credentials auth](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts): `src/app/api/auth/[...nextauth]/route.ts`
- [Registration](https://github.com/alasaihi001/quizforge/blob/main/src/components/auth/register-form.tsx): `src/components/auth/register-form.tsx`
- [Dashboard](https://github.com/alasaihi001/quizforge/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`

### Study generation

- [Generation form](https://github.com/alasaihi001/quizforge/blob/main/src/components/dashboard/generate-page-client.tsx): `src/components/dashboard/generate-page-client.tsx`
- [Generation API](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/generate/route.ts): `src/app/api/generate/route.ts`
- [Mode prompts](https://github.com/alasaihi001/quizforge/blob/main/src/lib/prompts.ts): `src/lib/prompts.ts`
- **Groq AI**
- [Result parser](https://github.com/alasaihi001/quizforge/blob/main/src/lib/parsers.ts): `src/lib/parsers.ts`
- [Result displays](https://github.com/alasaihi001/quizforge/tree/main/src/components/dashboard/results): `src/components/dashboard/results`
- [Generation history](https://github.com/alasaihi001/quizforge/blob/main/src/app/dashboard/history/page.tsx): `src/app/dashboard/history/page.tsx`
- [Public share links](https://github.com/alasaihi001/quizforge/blob/main/src/app/share/%5Btoken%5D/page.tsx): `src/app/share/[token]/page.tsx`
- [Share endpoint](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/share/%5Btoken%5D/route.ts): `src/app/api/share/[token]/route.ts`
- [PDF download](https://github.com/alasaihi001/quizforge/blob/main/src/components/dashboard/pdf-download-button.tsx): `src/components/dashboard/pdf-download-button.tsx`
- [PDF formats](https://github.com/alasaihi001/quizforge/tree/main/src/components/pdf): `src/components/pdf`

### Plans and credits

- [Billing endpoints](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/stripe/checkout/route.ts): `src/app/api/stripe/checkout/route.ts`
- [Subscription portal](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/stripe/portal/route.ts): `src/app/api/stripe/portal/route.ts`
- [Billing webhook](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/stripe/webhook/route.ts): `src/app/api/stripe/webhook/route.ts`
- **Stripe**
- [Daily credit reset](https://github.com/alasaihi001/quizforge/blob/main/src/app/api/cron/reset-credits/route.ts): `src/app/api/cron/reset-credits/route.ts`

### Persistence and services

- [Prisma client](https://github.com/alasaihi001/quizforge/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- **PostgreSQL**
- [Rate limiter](https://github.com/alasaihi001/quizforge/blob/main/src/lib/rate-limit.ts): `src/lib/rate-limit.ts`
- **Upstash Redis**

### Other components

- **Student**

## Connections

- Student → Registration: registers
- Student → Credentials auth: signs in
- Student → Dashboard: uses
- Registration → Credentials auth: creates account
- Credentials auth → Prisma client: reads users (evidence: `src/app/api/auth/[...nextauth]/route.ts`)
- Dashboard → Generation form: opens (evidence: `src/app/dashboard/page.tsx`)
- Generation form → Generation API: submits content (evidence: `src/components/dashboard/generate-page-client.tsx`)
- Generation API → Credentials auth: checks session (evidence: `src/app/api/generate/route.ts`)
- Generation API → Rate limiter: checks limit (evidence: `src/app/api/generate/route.ts`)
- Rate limiter → Upstash Redis: limits requests
- Generation API → Prisma client: checks credits (evidence: `src/app/api/generate/route.ts`)
- Generation API → Mode prompts: builds prompt (evidence: `src/app/api/generate/route.ts`)
- Generation API → Groq AI: streams request (evidence: `src/app/api/generate/route.ts`)
- Generation API → Prisma client: saves and decrements (evidence: `src/app/api/generate/route.ts`)
- Generation API → Generation form: streams response
- Generation form → Result parser: parses output (evidence: `src/components/dashboard/generate-page-client.tsx`)
- Generation form → Result displays: renders results (evidence: `src/components/dashboard/generate-page-client.tsx`)
- Dashboard → Generation history: opens history
- Prisma client → PostgreSQL: persists records
- Share endpoint → Prisma client: reads generation (evidence: `src/app/api/share/[token]/route.ts`)
- Public share links → Share endpoint: loads shared item
- Generation form → Public share links: offers share link
- Generation form → PDF download: offers export (evidence: `src/components/dashboard/generate-page-client.tsx`)
- PDF download → PDF formats: formats document (evidence: `src/components/dashboard/pdf-download-button.tsx`)
- Billing endpoints → Credentials auth: checks session (evidence: `src/app/api/stripe/checkout/route.ts`)
- Billing endpoints → Prisma client: loads customer (evidence: `src/app/api/stripe/checkout/route.ts`)
- Billing endpoints → Stripe: creates checkout (evidence: `src/app/api/stripe/checkout/route.ts`)
- Subscription portal → Stripe: creates portal (evidence: `src/app/api/stripe/portal/route.ts`)
- Billing webhook → Stripe: verifies events (evidence: `src/app/api/stripe/webhook/route.ts`)
- Billing webhook → Prisma client: updates plan credits (evidence: `src/app/api/stripe/webhook/route.ts`)
- Daily credit reset → Prisma client: resets credits (evidence: `src/app/api/cron/reset-credits/route.ts`)
