# code-with-antonio/nextjs-duolingo-clone architecture

> Architecture diagram of the GitHub repository code-with-antonio/nextjs-duolingo-clone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/code-with-antonio/nextjs-duolingo-clone
- Repository: https://github.com/code-with-antonio/nextjs-duolingo-clone

## Overview

This is a Duolingo-style language-learning web app. Learners choose a course, follow its units and lessons, answer challenges, and earn points while managing hearts; course progress and lesson results are persisted. Separate branches provide shop/refills, quests, leaderboard, subscriptions, marketing, and admin content management. The graph follows documented and indexed relationships; unsampled modules are represented at their exact directory where appropriate, and optional integrations are marked unverified.

Main entry points: [`db/queries.ts`](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/queries.ts) (Application queries), [`db/drizzle.ts`](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/drizzle.ts) (Database client), [`app/(main)/courses/page.tsx`](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/courses/page.tsx) (Course selection), [`app/(main)/learn/page.tsx`](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/learn/page.tsx) (Learning map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning experience"]
  node_courses["Course selection<br/>[page.tsx]"]
  node_course_list["Course list<br/>[list.tsx]"]
  node_learn["Learning map<br/>[page.tsx]"]
  node_units["Unit lesson map<br/>[unit.tsx]"]
  node_lesson_entry["Lesson entry<br/>[page.tsx]"]
  node_quiz["Challenge quiz<br/>[quiz.tsx]"]
  node_challenge_action["Challenge progress"]
end

subgraph group_engagement["Progress and rewards"]
  node_progress_action["User progress actions<br/>[user-progress.ts]"]
  node_shop["Shop items<br/>[items.tsx]"]
  node_quests["Quests<br/>[page.tsx]"]
  node_leaderboard["Leaderboard<br/>[page.tsx]"]
end

subgraph group_platform["Data and billing"]
  node_queries["Application queries<br/>[queries.ts]"]
  node_database_client["Database client<br/>[drizzle.ts]"]
  node_schema[("Learning and user data<br/>[schema.ts]")]
  node_stripe_webhook["Stripe webhook<br/>[route.ts]"]
  node_subscription_action["Subscription actions"]
  node_neon[("Neon Postgres")]
  node_stripe["Stripe"]
end

subgraph group_management["Content management"]
  node_admin_ui["Admin console<br/>[app.tsx]"]
  node_admin_api["Admin content API"]
end

subgraph group_discovery["Public entry"]
  node_marketing["Landing page<br/>[page.tsx]"]
end

node_learner(("Learner"))
node_admin(("Administrator"))

node_learner -->|"chooses course"| node_courses
node_courses -->|"loads courses"| node_queries
node_courses -->|"renders list"| node_course_list
node_course_list -->|"sets course"| node_progress_action
node_learner -->|"opens learning"| node_learn
node_learn -->|"loads progress"| node_queries
node_learn -->|"renders units"| node_units
node_units -.->|"opens lesson"| node_lesson_entry
node_lesson_entry -->|"loads lesson"| node_queries
node_lesson_entry -->|"renders quiz"| node_quiz
node_quiz -->|"records challenge"| node_challenge_action
node_quiz -->|"updates progress"| node_progress_action
node_learner -->|"visits shop"| node_shop
node_shop -->|"refills hearts"| node_progress_action
node_shop -->|"starts subscription"| node_subscription_action
node_learner -->|"views milestones"| node_quests
node_quests -->|"loads points"| node_queries
node_learner -->|"views rankings"| node_leaderboard
node_leaderboard -->|"loads rankings"| node_queries
node_admin -->|"manages content"| node_admin_ui
node_admin_ui -->|"requests resources"| node_admin_api
node_admin_api -->|"reads and writes"| node_database_client
node_queries -->|"queries data"| node_database_client
node_database_client -->|"uses schema"| node_schema
node_database_client -->|"connects to"| node_neon
node_subscription_action -.->|"uses billing"| node_stripe
node_stripe -.->|"sends events"| node_stripe_webhook
node_stripe_webhook -->|"updates subscription"| node_database_client
node_learner -->|"visits landing"| node_marketing

click node_courses "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/courses/page.tsx"
click node_course_list "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/courses/list.tsx"
click node_learn "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/learn/page.tsx"
click node_units "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/learn/unit.tsx"
click node_lesson_entry "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/lesson/%5BlessonId%5D/page.tsx"
click node_quiz "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/lesson/quiz.tsx"
click node_challenge_action "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/actions/challenge-progress.ts"
click node_progress_action "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/actions/user-progress.ts"
click node_shop "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/shop/items.tsx"
click node_quests "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/quests/page.tsx"
click node_leaderboard "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/leaderboard/page.tsx"
click node_admin_ui "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/admin/app.tsx"
click node_admin_api "https://github.com/code-with-antonio/nextjs-duolingo-clone/tree/master/app/api"
click node_queries "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/queries.ts"
click node_database_client "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/drizzle.ts"
click node_schema "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/schema.ts"
click node_stripe_webhook "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/api/webhooks/stripe/route.ts"
click node_subscription_action "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/actions/user-subscription.ts"
click node_marketing "https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(marketing)/page.tsx"

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_courses,node_course_list,node_learn,node_units,node_lesson_entry,node_quiz,node_challenge_action toneBlue
class node_progress_action,node_shop,node_quests,node_leaderboard toneAmber
class node_queries,node_database_client,node_schema,node_stripe_webhook,node_subscription_action,node_neon,node_stripe toneMint
class node_admin_ui,node_admin_api toneRose
class node_marketing,node_learner,node_admin toneIndigo
```

## Components

### Learning experience

- [Course selection](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/courses/page.tsx): `app/(main)/courses/page.tsx`
- [Course list](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/courses/list.tsx): `app/(main)/courses/list.tsx`
- [Learning map](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/learn/page.tsx): `app/(main)/learn/page.tsx`
- [Unit lesson map](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/learn/unit.tsx): `app/(main)/learn/unit.tsx`
- [Lesson entry](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/lesson/%5BlessonId%5D/page.tsx): `app/lesson/[lessonId]/page.tsx`
- [Challenge quiz](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/lesson/quiz.tsx): `app/lesson/quiz.tsx`
- [Challenge progress](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/actions/challenge-progress.ts): `actions/challenge-progress.ts`

### Progress and rewards

- [User progress actions](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/actions/user-progress.ts): `actions/user-progress.ts`
- [Shop items](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/shop/items.tsx): `app/(main)/shop/items.tsx`
- [Quests](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/quests/page.tsx): `app/(main)/quests/page.tsx`
- [Leaderboard](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(main)/leaderboard/page.tsx): `app/(main)/leaderboard/page.tsx`

### Data and billing

- [Application queries](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/queries.ts): `db/queries.ts`
- [Database client](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/drizzle.ts): `db/drizzle.ts`
- [Learning and user data](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/db/schema.ts): `db/schema.ts`
- [Stripe webhook](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/api/webhooks/stripe/route.ts): `app/api/webhooks/stripe/route.ts`
- [Subscription actions](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/actions/user-subscription.ts): `actions/user-subscription.ts`
- **Neon Postgres**
- **Stripe**

### Content management

- [Admin console](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/admin/app.tsx): `app/admin/app.tsx`
- [Admin content API](https://github.com/code-with-antonio/nextjs-duolingo-clone/tree/master/app/api): `app/api`

### Public entry

- [Landing page](https://github.com/code-with-antonio/nextjs-duolingo-clone/blob/master/app/(marketing)/page.tsx): `app/(marketing)/page.tsx`

### Other components

- **Learner**
- **Administrator**

## Connections

- Learner → Course selection: chooses course (evidence: `app/(main)/courses/page.tsx`)
- Course selection → Application queries: loads courses (evidence: `app/(main)/courses/page.tsx`)
- Course selection → Course list: renders list (evidence: `app/(main)/courses/page.tsx`)
- Course list → User progress actions: sets course (evidence: `app/(main)/courses/list.tsx`)
- Learner → Learning map: opens learning (evidence: `app/(main)/learn/page.tsx`)
- Learning map → Application queries: loads progress (evidence: `app/(main)/learn/page.tsx`)
- Learning map → Unit lesson map: renders units (evidence: `app/(main)/learn/page.tsx`)
- Unit lesson map → Lesson entry: opens lesson
- Lesson entry → Application queries: loads lesson (evidence: `app/lesson/[lessonId]/page.tsx`)
- Lesson entry → Challenge quiz: renders quiz (evidence: `app/lesson/[lessonId]/page.tsx`)
- Challenge quiz → Challenge progress: records challenge (evidence: `app/lesson/quiz.tsx`)
- Challenge quiz → User progress actions: updates progress (evidence: `app/lesson/quiz.tsx`)
- Learner → Shop items: visits shop
- Shop items → User progress actions: refills hearts (evidence: `app/(main)/shop/items.tsx`)
- Shop items → Subscription actions: starts subscription (evidence: `app/(main)/shop/items.tsx`)
- Learner → Quests: views milestones (evidence: `app/(main)/quests/page.tsx`)
- Quests → Application queries: loads points (evidence: `app/(main)/quests/page.tsx`)
- Learner → Leaderboard: views rankings (evidence: `app/(main)/leaderboard/page.tsx`)
- Leaderboard → Application queries: loads rankings (evidence: `app/(main)/leaderboard/page.tsx`)
- Administrator → Admin console: manages content
- Admin console → Admin content API: requests resources (evidence: `app/admin/app.tsx`)
- Admin content API → Database client: reads and writes (evidence: `app/api/challengeOptions/route.ts`)
- Application queries → Database client: queries data (evidence: `db/queries.ts`)
- Database client → Learning and user data: uses schema (evidence: `db/drizzle.ts`)
- Database client → Neon Postgres: connects to (evidence: `db/drizzle.ts`)
- Subscription actions → Stripe: uses billing
- Stripe → Stripe webhook: sends events
- Stripe webhook → Database client: updates subscription (evidence: `app/api/webhooks/stripe/route.ts`)
- Learner → Landing page: visits landing (evidence: `README.md`)
