# migzjr025/gamified_math architecture

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

- Interactive diagram: https://gitdiagram.com/migzjr025/gamified_math
- Repository: https://github.com/migzjr025/gamified_math

## Overview

This is a Next.js teacher-facing student assessment and learning-game application. Teachers manage students, units, questions, assessments, grades, and achievement records; students take game assessments whose results contribute to grading and reporting. The graph separates user-facing surfaces, domain APIs, authentication, and persistence. Several UI-to-API links are shown as unverified because the sampled UI source does not expose its HTTP calls; unsampled features are retained where the tree and source index establish them.

Main entry points: [`src/db/index.ts`](https://github.com/migzjr025/gamified_math/blob/main/src/db/index.ts) (PostgreSQL connection), [`src/lib/auth.ts`](https://github.com/migzjr025/gamified_math/blob/main/src/lib/auth.ts) (Session and access control), [`src/components/StudentsInteractive.tsx`](https://github.com/migzjr025/gamified_math/blob/main/src/components/StudentsInteractive.tsx) (Student management), [`src/components/UnitsInteractive.tsx`](https://github.com/migzjr025/gamified_math/blob/main/src/components/UnitsInteractive.tsx) (Unit management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["Teacher and learner surfaces"]
  node_dashboard["Dashboard"]
  node_student_ui["Student management"]
  node_units_ui["Unit management"]
  node_questions_ui["Question management"]
  node_assess_ui["Assessment management"]
  node_game_ui["Learning game"]
  node_grades_ui["Grades and reports"]
  node_achieve_ui["Achievements"]
  node_settings_ui["Settings"]
  node_admin_ui["User administration"]
  node_sidebar["Navigation<br/>[SidebarNav.tsx]"]
end

subgraph group_learning["Learning and assessment"]
  node_students_api["Student records API<br/>[route.ts]"]
  node_units_api["Units API<br/>[route.ts]"]
  node_questions_api["Questions API<br/>[route.ts]"]
  node_assess_api["Assessments API<br/>[route.ts]"]
  node_results_api["Game results API<br/>[route.ts]"]
  node_grades_api["Grades API<br/>[route.ts]"]
  node_achievements_api["Achievements API<br/>[route.ts]"]
end

subgraph group_identity["Identity and administration"]
  node_login_api["Login API<br/>[route.ts]"]
  node_otp["OTP verification<br/>[otp.ts]"]
  node_email["OTP email delivery<br/>[email.ts]"]
  node_auth["Session and access control<br/>[auth.ts]"]
  node_admin_api["Admin users API<br/>[route.ts]"]
end

subgraph group_platform["Data and services"]
  node_db[("PostgreSQL connection<br/>[index.ts]")]
  node_schema[("Relational data model<br/>[schema.ts]")]
  node_postgres[("PostgreSQL")]
end

node_teacher(("Teacher or learner"))

node_teacher -->|"uses"| node_dashboard
node_teacher -.->|"manages"| node_student_ui
node_teacher -.->|"configures"| node_units_ui
node_teacher -.->|"authors"| node_questions_ui
node_teacher -.->|"creates"| node_assess_ui
node_teacher -.->|"plays"| node_game_ui
node_teacher -.->|"reviews"| node_grades_ui
node_teacher -.->|"reviews"| node_achieve_ui
node_teacher -->|"configures"| node_settings_ui
node_teacher -.->|"administers"| node_admin_ui
node_questions_ui -->|"uses"| node_sidebar
node_student_ui -->|"uses"| node_sidebar
node_units_ui -->|"uses"| node_sidebar
node_student_ui -.->|"requests records"| node_students_api
node_units_ui -.->|"requests units"| node_units_api
node_questions_ui -.->|"requests questions"| node_questions_api
node_assess_ui -.->|"requests assessments"| node_assess_api
node_game_ui -.->|"loads questions"| node_questions_api
node_game_ui -.->|"submits results"| node_results_api
node_grades_ui -.->|"requests grades"| node_grades_api
node_achieve_ui -.->|"requests achievements"| node_achievements_api
node_admin_ui -.->|"requests users"| node_admin_api
node_login_api -->|"creates session"| node_auth
node_login_api -->|"starts verification"| node_otp
node_otp -->|"sends code"| node_email
node_students_api -->|"checks session"| node_auth
node_assess_api -->|"checks session"| node_auth
node_grades_api -->|"checks session"| node_auth
node_results_api -->|"checks session"| node_auth
node_admin_api -->|"checks admin"| node_auth
node_students_api -->|"queries data"| node_db
node_units_api -->|"queries data"| node_db
node_questions_api -->|"queries data"| node_db
node_assess_api -->|"queries data"| node_db
node_results_api -->|"reads and writes"| node_db
node_grades_api -->|"reads and writes"| node_db
node_achievements_api -->|"queries data"| node_db
node_admin_api -->|"queries data"| node_db
node_auth -->|"loads user"| node_db
node_otp -->|"stores codes"| node_db
node_db -->|"connects"| node_postgres

click node_dashboard "https://github.com/migzjr025/gamified_math/blob/main/src/components/DashboardInteractive.tsx"
click node_student_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/StudentsInteractive.tsx"
click node_units_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/UnitsInteractive.tsx"
click node_questions_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/QuestionsInteractive.tsx"
click node_assess_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/AssessmentsInteractive.tsx"
click node_game_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/GameInteractive.tsx"
click node_grades_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/GradesInteractive.tsx"
click node_achieve_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/AchievementsInteractive.tsx"
click node_settings_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/SettingsInteractive.tsx"
click node_admin_ui "https://github.com/migzjr025/gamified_math/blob/main/src/components/AdminUsersInteractive.tsx"
click node_sidebar "https://github.com/migzjr025/gamified_math/blob/main/src/components/SidebarNav.tsx"
click node_students_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/students/route.ts"
click node_units_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/units/route.ts"
click node_questions_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/questions/route.ts"
click node_assess_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/assessments/route.ts"
click node_results_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/game-results/route.ts"
click node_grades_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/grades/route.ts"
click node_achievements_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/achievements/route.ts"
click node_login_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/auth/login/route.ts"
click node_otp "https://github.com/migzjr025/gamified_math/blob/main/src/lib/otp.ts"
click node_email "https://github.com/migzjr025/gamified_math/blob/main/src/lib/email.ts"
click node_auth "https://github.com/migzjr025/gamified_math/blob/main/src/lib/auth.ts"
click node_admin_api "https://github.com/migzjr025/gamified_math/blob/main/src/app/api/admin/users/route.ts"
click node_db "https://github.com/migzjr025/gamified_math/blob/main/src/db/index.ts"
click node_schema "https://github.com/migzjr025/gamified_math/blob/main/src/db/schema.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_dashboard,node_student_ui,node_units_ui,node_questions_ui,node_assess_ui,node_game_ui,node_grades_ui,node_achieve_ui,node_settings_ui,node_admin_ui,node_sidebar toneBlue
class node_students_api,node_units_api,node_questions_api,node_assess_api,node_results_api,node_grades_api,node_achievements_api toneAmber
class node_login_api,node_otp,node_email,node_auth,node_admin_api toneMint
class node_db,node_schema,node_postgres toneRose
class node_teacher toneIndigo
```

## Components

### Teacher and learner surfaces

- [Dashboard](https://github.com/migzjr025/gamified_math/blob/main/src/components/DashboardInteractive.tsx): `src/components/DashboardInteractive.tsx`
- [Student management](https://github.com/migzjr025/gamified_math/blob/main/src/components/StudentsInteractive.tsx): `src/components/StudentsInteractive.tsx`
- [Unit management](https://github.com/migzjr025/gamified_math/blob/main/src/components/UnitsInteractive.tsx): `src/components/UnitsInteractive.tsx`
- [Question management](https://github.com/migzjr025/gamified_math/blob/main/src/components/QuestionsInteractive.tsx): `src/components/QuestionsInteractive.tsx`
- [Assessment management](https://github.com/migzjr025/gamified_math/blob/main/src/components/AssessmentsInteractive.tsx): `src/components/AssessmentsInteractive.tsx`
- [Learning game](https://github.com/migzjr025/gamified_math/blob/main/src/components/GameInteractive.tsx): `src/components/GameInteractive.tsx`
- [Grades and reports](https://github.com/migzjr025/gamified_math/blob/main/src/components/GradesInteractive.tsx): `src/components/GradesInteractive.tsx`
- [Achievements](https://github.com/migzjr025/gamified_math/blob/main/src/components/AchievementsInteractive.tsx): `src/components/AchievementsInteractive.tsx`
- [Settings](https://github.com/migzjr025/gamified_math/blob/main/src/components/SettingsInteractive.tsx): `src/components/SettingsInteractive.tsx`
- [User administration](https://github.com/migzjr025/gamified_math/blob/main/src/components/AdminUsersInteractive.tsx): `src/components/AdminUsersInteractive.tsx`
- [Navigation](https://github.com/migzjr025/gamified_math/blob/main/src/components/SidebarNav.tsx): `src/components/SidebarNav.tsx`

### Learning and assessment

- [Student records API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/students/route.ts): `src/app/api/students/route.ts`
- [Units API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/units/route.ts): `src/app/api/units/route.ts`
- [Questions API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/questions/route.ts): `src/app/api/questions/route.ts`
- [Assessments API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/assessments/route.ts): `src/app/api/assessments/route.ts`
- [Game results API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/game-results/route.ts): `src/app/api/game-results/route.ts`
- [Grades API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/grades/route.ts): `src/app/api/grades/route.ts`
- [Achievements API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/achievements/route.ts): `src/app/api/achievements/route.ts`

### Identity and administration

- [Login API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [OTP verification](https://github.com/migzjr025/gamified_math/blob/main/src/lib/otp.ts): `src/lib/otp.ts`
- [OTP email delivery](https://github.com/migzjr025/gamified_math/blob/main/src/lib/email.ts): `src/lib/email.ts`
- [Session and access control](https://github.com/migzjr025/gamified_math/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Admin users API](https://github.com/migzjr025/gamified_math/blob/main/src/app/api/admin/users/route.ts): `src/app/api/admin/users/route.ts`

### Data and services

- [PostgreSQL connection](https://github.com/migzjr025/gamified_math/blob/main/src/db/index.ts): `src/db/index.ts`
- [Relational data model](https://github.com/migzjr025/gamified_math/blob/main/src/db/schema.ts): `src/db/schema.ts`
- **PostgreSQL**

### Other components

- **Teacher or learner**

## Connections

- Teacher or learner → Dashboard: uses
- Teacher or learner → Student management: manages
- Teacher or learner → Unit management: configures
- Teacher or learner → Question management: authors
- Teacher or learner → Assessment management: creates
- Teacher or learner → Learning game: plays
- Teacher or learner → Grades and reports: reviews
- Teacher or learner → Achievements: reviews
- Teacher or learner → Settings: configures
- Teacher or learner → User administration: administers
- Question management → Navigation: uses (evidence: `src/components/QuestionsInteractive.tsx`)
- Student management → Navigation: uses (evidence: `src/components/StudentsInteractive.tsx`)
- Unit management → Navigation: uses (evidence: `src/components/UnitsInteractive.tsx`)
- Student management → Student records API: requests records
- Unit management → Units API: requests units
- Question management → Questions API: requests questions
- Assessment management → Assessments API: requests assessments
- Learning game → Questions API: loads questions
- Learning game → Game results API: submits results
- Grades and reports → Grades API: requests grades
- Achievements → Achievements API: requests achievements
- User administration → Admin users API: requests users
- Login API → Session and access control: creates session (evidence: `src/app/api/auth/login/route.ts`)
- Login API → OTP verification: starts verification (evidence: `src/app/api/auth/login/route.ts`)
- OTP verification → OTP email delivery: sends code (evidence: `src/lib/otp.ts`)
- Student records API → Session and access control: checks session (evidence: `src/app/api/students/route.ts`)
- Assessments API → Session and access control: checks session (evidence: `src/app/api/assessments/route.ts`)
- Grades API → Session and access control: checks session (evidence: `src/app/api/grades/route.ts`)
- Game results API → Session and access control: checks session (evidence: `src/app/api/game-results/route.ts`)
- Admin users API → Session and access control: checks admin (evidence: `src/app/api/admin/users/route.ts`)
- Student records API → PostgreSQL connection: queries data (evidence: `src/app/api/students/route.ts`)
- Units API → PostgreSQL connection: queries data (evidence: `src/app/api/units/route.ts`)
- Questions API → PostgreSQL connection: queries data (evidence: `src/app/api/questions/route.ts`)
- Assessments API → PostgreSQL connection: queries data (evidence: `src/app/api/assessments/route.ts`)
- Game results API → PostgreSQL connection: reads and writes (evidence: `src/app/api/game-results/route.ts`)
- Grades API → PostgreSQL connection: reads and writes (evidence: `src/app/api/grades/route.ts`)
- Achievements API → PostgreSQL connection: queries data (evidence: `src/app/api/achievements/route.ts`)
- Admin users API → PostgreSQL connection: queries data (evidence: `src/app/api/admin/users/route.ts`)
- Session and access control → PostgreSQL connection: loads user (evidence: `src/lib/auth.ts`)
- OTP verification → PostgreSQL connection: stores codes (evidence: `src/lib/otp.ts`)
- PostgreSQL connection → PostgreSQL: connects (evidence: `src/db/index.ts`)
