# ntquangminh/quangminh-toeic architecture

> Architecture diagram of the GitHub repository ntquangminh/quangminh-toeic, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ntquangminh/quangminh-toeic
- Repository: https://github.com/ntquangminh/quangminh-toeic

## Overview

Quang Minh TOEIC is a Vietnamese TOEIC vocabulary learning and exam-preparation platform. Learners study vocabulary through flashcards and practice activities, take quizzes, and review difficult or due words; account-backed progress, goals, and streaks track that activity. Separate branches provide registration and login, bookmarks, AI tutoring, and administrator vocabulary management. The graph combines sampled calls and SOURCE INDEX references with capabilities documented in the README; unsampled routes and pages are represented only where their role is clear, and their internal wiring is not inferred.

Main entry points: [`src/lib/db.ts`](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/db.ts) (Persistent database), [`src/app/review/page.tsx`](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/review/page.tsx) (Review page), [`src/lib/auth.ts`](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/auth.ts) (Session and tokens), [`src/app/practice/page.tsx`](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/practice/page.tsx) (Quiz practice)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Study experience"]
  node_study_pages["Study pages<br/>[page.tsx]"]
  node_flashcard["Flashcard<br/>[Flashcard.tsx]"]
  node_audio["Pronunciation audio<br/>[AudioButton.tsx]"]
  node_speech["Speech button"]
  node_tutor_modal["Tutor modal<br/>[AITutorModal.tsx]"]
  node_study_api["Learning endpoint<br/>[route.ts]"]
  node_bookmarks["Bookmarks<br/>[route.ts]"]
  node_progress_ui["Progress dashboard<br/>[page.tsx]"]
  node_exam_widget["Exam countdown"]
  node_progress_bar["Progress bar<br/>[ProgressBar.tsx]"]
  node_confetti["Completion feedback<br/>[Confetti.tsx]"]
end

subgraph group_assessment["Practice and review"]
  node_practice_page["Quiz practice<br/>[page.tsx]"]
  node_quiz_api["Quiz endpoint<br/>[route.ts]"]
  node_match_api["Matching endpoint<br/>[route.ts]"]
  node_review_page["Review page<br/>[page.tsx]"]
  node_review_api["Review endpoint<br/>[route.ts]"]
  node_review_quiz["Review quiz builder<br/>[review-quiz.ts]"]
  node_difficult_words["Difficult words<br/>[page.tsx]"]
end

subgraph group_identity["Accounts and administration"]
  node_account_pages["Account pages<br/>[page.tsx]"]
  node_auth_routes["Authentication routes<br/>[route.ts]"]
  node_admin["Vocabulary admin<br/>[page.tsx]"]
  node_vocab_api["Vocabulary API<br/>[route.ts]"]
end

subgraph group_services["Application services"]
  node_auth_service["Session and tokens<br/>[auth.ts]"]
  node_ai_routes["AI endpoints<br/>[route.ts]"]
  node_ai_service["AI service<br/>[ai.ts]"]
  node_rate_limiter["Rate limiter<br/>[rate-limiter.ts]"]
  node_db[("Persistent database<br/>[db.ts]")]
  node_study_tracker["Study tracker<br/>[study-tracker.ts]"]
  node_sm2["SM-2 scheduler<br/>[sm2.ts]"]
  node_sound["Sound effects<br/>[sound-effects.ts]"]
end

subgraph group_content["Learning content"]
  node_vocabulary["TOEIC vocabulary"]
  node_passages["Reading passages"]
end

node_learner(("Learner"))

node_learner -->|"studies with"| node_study_pages
node_study_pages -.->|"requests words"| node_study_api
node_study_api -->|"reads and writes"| node_db
node_study_api -->|"resolves user"| node_auth_service
node_study_api -->|"records activity"| node_study_tracker
node_study_pages -.->|"presents cards"| node_flashcard
node_flashcard -->|"renders audio"| node_audio
node_flashcard -->|"renders speech"| node_speech
node_flashcard -->|"opens tutor"| node_tutor_modal
node_learner -->|"takes quizzes"| node_practice_page
node_practice_page -->|"submits answers"| node_quiz_api
node_quiz_api -->|"reads and writes"| node_db
node_quiz_api -->|"verifies identity"| node_auth_service
node_quiz_api -->|"records activity"| node_study_tracker
node_learner -->|"plays matching"| node_match_api
node_match_api -->|"reads vocabulary"| node_db
node_match_api -->|"records activity"| node_study_tracker
node_learner -->|"reviews words"| node_review_page
node_review_page -.->|"loads and rates"| node_review_api
node_review_api -->|"reads and writes"| node_db
node_review_api -->|"resolves user"| node_auth_service
node_review_api -->|"calculates schedule"| node_sm2
node_review_api -->|"records activity"| node_study_tracker
node_review_page -->|"builds review quiz"| node_review_quiz
node_learner -->|"reviews mistakes"| node_difficult_words
node_learner -->|"registers account"| node_account_pages
node_account_pages -.->|"submits credentials"| node_auth_routes
node_auth_routes -->|"creates session"| node_auth_service
node_auth_routes -->|"reads and writes"| node_db
node_auth_routes -->|"limits requests"| node_rate_limiter
node_admin -->|"manages vocabulary"| node_vocab_api
node_vocab_api -->|"reads and writes"| node_db
node_vocab_api -->|"checks admin role"| node_auth_service
node_learner -->|"saves words"| node_bookmarks
node_bookmarks -->|"reads and writes"| node_db
node_bookmarks -->|"resolves user"| node_auth_service
node_tutor_modal -.->|"asks tutor"| node_ai_routes
node_ai_routes -->|"generates response"| node_ai_service
node_ai_routes -->|"limits requests"| node_rate_limiter
node_vocabulary -->|"seeds vocabulary"| node_db
node_progress_ui -->|"renders progress"| node_progress_bar
node_progress_ui -->|"shows countdown"| node_exam_widget
node_practice_page -->|"renders progress"| node_progress_bar
node_practice_page -->|"shows completion"| node_confetti
node_practice_page -->|"plays feedback"| node_sound
node_review_page -->|"renders cards"| node_flashcard
node_review_page -->|"uses scheduling"| node_sm2
node_review_page -->|"renders progress"| node_progress_bar

click node_study_pages "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/learn/page.tsx"
click node_flashcard "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/Flashcard.tsx"
click node_audio "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/AudioButton.tsx"
click node_speech "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/VoiceSpeechButton.tsx"
click node_tutor_modal "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/AITutorModal.tsx"
click node_study_api "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/learn/route.ts"
click node_practice_page "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/practice/page.tsx"
click node_quiz_api "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/quiz/route.ts"
click node_match_api "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/match/route.ts"
click node_review_page "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/review/page.tsx"
click node_review_api "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/review/route.ts"
click node_review_quiz "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/review-quiz.ts"
click node_difficult_words "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/difficult-words/page.tsx"
click node_account_pages "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/register/page.tsx"
click node_auth_routes "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/auth/login/route.ts"
click node_auth_service "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/auth.ts"
click node_admin "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/admin/page.tsx"
click node_vocab_api "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/vocabulary/route.ts"
click node_bookmarks "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/bookmarks/route.ts"
click node_ai_routes "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/ai/tutor/route.ts"
click node_ai_service "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/ai.ts"
click node_rate_limiter "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/rate-limiter.ts"
click node_db "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/db.ts"
click node_study_tracker "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/study-tracker.ts"
click node_sm2 "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/sm2.ts"
click node_vocabulary "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/data/toeic-vocab-seed.ts"
click node_progress_ui "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/dashboard/page.tsx"
click node_passages "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/data/toeic-reading-passages.ts"
click node_exam_widget "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/ExamCountdownWidget.tsx"
click node_progress_bar "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/ProgressBar.tsx"
click node_confetti "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/Confetti.tsx"
click node_sound "https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/sound-effects.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_study_pages,node_flashcard,node_audio,node_speech,node_tutor_modal,node_study_api,node_bookmarks,node_progress_ui,node_exam_widget,node_progress_bar,node_confetti toneBlue
class node_practice_page,node_quiz_api,node_match_api,node_review_page,node_review_api,node_review_quiz,node_difficult_words toneAmber
class node_account_pages,node_auth_routes,node_admin,node_vocab_api toneMint
class node_auth_service,node_ai_routes,node_ai_service,node_rate_limiter,node_db,node_study_tracker,node_sm2,node_sound toneRose
class node_vocabulary,node_passages,node_learner toneIndigo
```

## Components

### Study experience

- [Study pages](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/learn/page.tsx): `src/app/learn/page.tsx`
- [Flashcard](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/Flashcard.tsx): `src/components/Flashcard.tsx`
- [Pronunciation audio](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/AudioButton.tsx): `src/components/AudioButton.tsx`
- [Speech button](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/VoiceSpeechButton.tsx): `src/components/VoiceSpeechButton.tsx`
- [Tutor modal](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/AITutorModal.tsx): `src/components/AITutorModal.tsx`
- [Learning endpoint](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/learn/route.ts): `src/app/api/learn/route.ts`
- [Bookmarks](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/bookmarks/route.ts): `src/app/api/bookmarks/route.ts`
- [Progress dashboard](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Exam countdown](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/ExamCountdownWidget.tsx): `src/components/ExamCountdownWidget.tsx`
- [Progress bar](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/ProgressBar.tsx): `src/components/ProgressBar.tsx`
- [Completion feedback](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/components/Confetti.tsx): `src/components/Confetti.tsx`

### Practice and review

- [Quiz practice](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/practice/page.tsx): `src/app/practice/page.tsx`
- [Quiz endpoint](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/quiz/route.ts): `src/app/api/quiz/route.ts`
- [Matching endpoint](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/match/route.ts): `src/app/api/match/route.ts`
- [Review page](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/review/page.tsx): `src/app/review/page.tsx`
- [Review endpoint](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/review/route.ts): `src/app/api/review/route.ts`
- [Review quiz builder](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/review-quiz.ts): `src/lib/review-quiz.ts`
- [Difficult words](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/difficult-words/page.tsx): `src/app/difficult-words/page.tsx`

### Accounts and administration

- [Account pages](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/register/page.tsx): `src/app/register/page.tsx`
- [Authentication routes](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [Vocabulary admin](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Vocabulary API](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/vocabulary/route.ts): `src/app/api/vocabulary/route.ts`

### Application services

- [Session and tokens](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [AI endpoints](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/app/api/ai/tutor/route.ts): `src/app/api/ai/tutor/route.ts`
- [AI service](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/ai.ts): `src/lib/ai.ts`
- [Rate limiter](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/rate-limiter.ts): `src/lib/rate-limiter.ts`
- [Persistent database](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Study tracker](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/study-tracker.ts): `src/lib/study-tracker.ts`
- [SM-2 scheduler](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/sm2.ts): `src/lib/sm2.ts`
- [Sound effects](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/lib/sound-effects.ts): `src/lib/sound-effects.ts`

### Learning content

- [TOEIC vocabulary](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/data/toeic-vocab-seed.ts): `src/data/toeic-vocab-seed.ts`
- [Reading passages](https://github.com/ntquangminh/quangminh-toeic/blob/main/src/data/toeic-reading-passages.ts): `src/data/toeic-reading-passages.ts`

### Other components

- **Learner**

## Connections

- Learner → Study pages: studies with
- Study pages → Learning endpoint: requests words
- Learning endpoint → Persistent database: reads and writes (evidence: `src/app/api/learn/route.ts`)
- Learning endpoint → Session and tokens: resolves user (evidence: `src/app/api/learn/route.ts`)
- Learning endpoint → Study tracker: records activity (evidence: `src/app/api/learn/route.ts`)
- Study pages → Flashcard: presents cards
- Flashcard → Pronunciation audio: renders audio (evidence: `src/components/Flashcard.tsx`)
- Flashcard → Speech button: renders speech (evidence: `src/components/Flashcard.tsx`)
- Flashcard → Tutor modal: opens tutor (evidence: `src/components/Flashcard.tsx`)
- Learner → Quiz practice: takes quizzes
- Quiz practice → Quiz endpoint: submits answers (evidence: `src/app/practice/page.tsx`)
- Quiz endpoint → Persistent database: reads and writes (evidence: `src/app/api/quiz/route.ts`)
- Quiz endpoint → Session and tokens: verifies identity (evidence: `src/app/api/quiz/route.ts`)
- Quiz endpoint → Study tracker: records activity (evidence: `src/app/api/quiz/route.ts`)
- Learner → Matching endpoint: plays matching
- Matching endpoint → Persistent database: reads vocabulary (evidence: `src/app/api/match/route.ts`)
- Matching endpoint → Study tracker: records activity (evidence: `src/app/api/match/route.ts`)
- Learner → Review page: reviews words
- Review page → Review endpoint: loads and rates
- Review endpoint → Persistent database: reads and writes (evidence: `src/app/api/review/route.ts`)
- Review endpoint → Session and tokens: resolves user (evidence: `src/app/api/review/route.ts`)
- Review endpoint → SM-2 scheduler: calculates schedule (evidence: `src/app/api/review/route.ts`)
- Review endpoint → Study tracker: records activity (evidence: `src/app/api/review/route.ts`)
- Review page → Review quiz builder: builds review quiz (evidence: `src/app/review/page.tsx`)
- Learner → Difficult words: reviews mistakes
- Learner → Account pages: registers account
- Account pages → Authentication routes: submits credentials
- Authentication routes → Session and tokens: creates session (evidence: `src/app/api/auth/login/route.ts`)
- Authentication routes → Persistent database: reads and writes (evidence: `src/app/api/auth/login/route.ts`)
- Authentication routes → Rate limiter: limits requests (evidence: `src/app/api/auth/login/route.ts`)
- Vocabulary admin → Vocabulary API: manages vocabulary
- Vocabulary API → Persistent database: reads and writes (evidence: `src/app/api/vocabulary/route.ts`)
- Vocabulary API → Session and tokens: checks admin role (evidence: `src/app/api/vocabulary/route.ts`)
- Learner → Bookmarks: saves words
- Bookmarks → Persistent database: reads and writes (evidence: `src/app/api/bookmarks/route.ts`)
- Bookmarks → Session and tokens: resolves user (evidence: `src/app/api/bookmarks/route.ts`)
- Tutor modal → AI endpoints: asks tutor
- AI endpoints → AI service: generates response (evidence: `src/app/api/ai/tutor/route.ts`)
- AI endpoints → Rate limiter: limits requests (evidence: `src/app/api/ai/tutor/route.ts`)
- TOEIC vocabulary → Persistent database: seeds vocabulary (evidence: `src/lib/db.ts`)
- Progress dashboard → Progress bar: renders progress (evidence: `src/app/dashboard/page.tsx`)
- Progress dashboard → Exam countdown: shows countdown (evidence: `src/app/dashboard/page.tsx`)
- Quiz practice → Progress bar: renders progress (evidence: `src/app/practice/page.tsx`)
- Quiz practice → Completion feedback: shows completion (evidence: `src/app/practice/page.tsx`)
- Quiz practice → Sound effects: plays feedback (evidence: `src/app/practice/page.tsx`)
- Review page → Flashcard: renders cards (evidence: `src/app/review/page.tsx`)
- Review page → SM-2 scheduler: uses scheduling (evidence: `src/app/review/page.tsx`)
- Review page → Progress bar: renders progress (evidence: `src/app/review/page.tsx`)
