# mydfreecoaching/freemock architecture

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

- Interactive diagram: https://gitdiagram.com/mydfreecoaching/freemock
- Repository: https://github.com/mydfreecoaching/freemock

## Overview

This is a Next.js web platform for free online mock exams and student support, backed by PostgreSQL. Students register, browse and take exams, then review results, rankings and analysis; the README also documents weekly analysis and faculty-submitted tests with admin approval. The graph includes the registration/profile, exam analytics, administration and faculty branches. Some runtime routes were not sampled, so workflow links supported only by product documentation cite the README; unsampled implementation details are not inferred.

Main entry points: [`lib/db.js`](https://github.com/mydfreecoaching/freemock/blob/main/lib/db.js) (PostgreSQL data), [`lib/analysis.js`](https://github.com/mydfreecoaching/freemock/blob/main/lib/analysis.js) (Analysis engine), [`app/api/register/route.js`](https://github.com/mydfreecoaching/freemock/blob/main/app/api/register/route.js) (Registration), [`app/dashboard/page.js`](https://github.com/mydfreecoaching/freemock/blob/main/app/dashboard/page.js) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student["Student experience"]
  node_register["Registration<br/>[route.js]"]
  node_profile["Student profile<br/>[route.js]"]
  node_dashboard["Dashboard<br/>[page.js]"]
end

subgraph group_exam["Exam and analytics"]
  node_exam_catalog["Exam catalog<br/>[exams.js]"]
  node_exam_pages["Exam pages<br/>[page.js]"]
  node_attempt["Exam attempts<br/>[attempt.js]"]
  node_scoring["Scoring<br/>[scoring.js]"]
  node_result["Results<br/>[page.js]"]
  node_rank["Rankings<br/>[rank.js]"]
  node_leaderboard["Leaderboards<br/>[lb.js]"]
  node_analysis_page["Test analysis<br/>[page.js]"]
  node_analysis["Analysis engine<br/>[analysis.js]"]
  node_weekly["Weekly analysis<br/>[page.js]"]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin console<br/>[page.js]"]
  node_admin_export["Admin exports<br/>[route.js]"]
end

subgraph group_faculty["Faculty submissions"]
  node_faculty_ui["Faculty portal<br/>[page.js]"]
  node_faculty_register["Faculty registration<br/>[route.js]"]
  node_coaching["Course management<br/>[coaching.js]"]
end

subgraph group_runtime["Shared runtime"]
  node_database[("PostgreSQL data<br/>[db.js]")]
  node_auth["Session auth<br/>[auth.js]"]
end

node_student(("Student"))

node_student -->|"registers"| node_register
node_register -->|"writes profile"| node_database
node_register -.->|"updates later"| node_profile
node_register -.->|"creates session"| node_auth
node_student -->|"opens account"| node_dashboard
node_dashboard -->|"loads student data"| node_database
node_dashboard -->|"loads exams"| node_exam_catalog
node_dashboard -.->|"shows rankings"| node_leaderboard
node_student -.->|"chooses exam"| node_exam_pages
node_exam_pages -.->|"starts attempt"| node_attempt
node_attempt -.->|"scores answers"| node_scoring
node_scoring -.->|"produces result"| node_result
node_result -->|"shows rank"| node_rank
node_analysis_page -->|"requests analysis"| node_analysis
node_analysis -->|"reads attempts"| node_database
node_analysis -->|"uses ranking"| node_rank
node_weekly -->|"computes weekly view"| node_analysis
node_leaderboard -->|"reads results"| node_database
node_leaderboard -->|"finalizes attempts"| node_scoring
node_leaderboard -->|"loads exam list"| node_exam_catalog
node_admin_ui -->|"manages records"| node_database
node_admin_export -->|"exports analysis"| node_analysis
node_admin_export -->|"queries records"| node_database
node_faculty_ui -->|"loads courses"| node_coaching
node_faculty_ui -->|"submits registration"| node_faculty_register
node_faculty_register -->|"checks courses"| node_coaching
node_coaching -->|"stores courses"| node_database

click node_register "https://github.com/mydfreecoaching/freemock/blob/main/app/api/register/route.js"
click node_profile "https://github.com/mydfreecoaching/freemock/blob/main/app/api/profile/route.js"
click node_dashboard "https://github.com/mydfreecoaching/freemock/blob/main/app/dashboard/page.js"
click node_exam_catalog "https://github.com/mydfreecoaching/freemock/blob/main/lib/exams.js"
click node_exam_pages "https://github.com/mydfreecoaching/freemock/blob/main/app/exam/%5Bcode%5D/page.js"
click node_attempt "https://github.com/mydfreecoaching/freemock/blob/main/lib/attempt.js"
click node_scoring "https://github.com/mydfreecoaching/freemock/blob/main/lib/scoring.js"
click node_result "https://github.com/mydfreecoaching/freemock/blob/main/app/result/%5Bid%5D/page.js"
click node_rank "https://github.com/mydfreecoaching/freemock/blob/main/lib/rank.js"
click node_leaderboard "https://github.com/mydfreecoaching/freemock/blob/main/lib/lb.js"
click node_analysis_page "https://github.com/mydfreecoaching/freemock/blob/main/app/analysis/%5Bid%5D/page.js"
click node_analysis "https://github.com/mydfreecoaching/freemock/blob/main/lib/analysis.js"
click node_weekly "https://github.com/mydfreecoaching/freemock/blob/main/app/weekly/page.js"
click node_admin_ui "https://github.com/mydfreecoaching/freemock/blob/main/app/admin/page.js"
click node_admin_export "https://github.com/mydfreecoaching/freemock/blob/main/app/api/admin/export/route.js"
click node_faculty_ui "https://github.com/mydfreecoaching/freemock/blob/main/app/faculty/page.js"
click node_faculty_register "https://github.com/mydfreecoaching/freemock/blob/main/app/api/faculty/register/route.js"
click node_coaching "https://github.com/mydfreecoaching/freemock/blob/main/lib/coaching.js"
click node_database "https://github.com/mydfreecoaching/freemock/blob/main/lib/db.js"
click node_auth "https://github.com/mydfreecoaching/freemock/blob/main/lib/auth.js"

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_register,node_profile,node_dashboard toneBlue
class node_exam_catalog,node_exam_pages,node_attempt,node_scoring,node_result,node_rank,node_leaderboard,node_analysis_page,node_analysis,node_weekly toneAmber
class node_admin_ui,node_admin_export toneMint
class node_faculty_ui,node_faculty_register,node_coaching toneRose
class node_database,node_auth,node_student toneIndigo
```

## Components

### Student experience

- [Registration](https://github.com/mydfreecoaching/freemock/blob/main/app/api/register/route.js): `app/api/register/route.js`
- [Student profile](https://github.com/mydfreecoaching/freemock/blob/main/app/api/profile/route.js): `app/api/profile/route.js`
- [Dashboard](https://github.com/mydfreecoaching/freemock/blob/main/app/dashboard/page.js): `app/dashboard/page.js`

### Exam and analytics

- [Exam catalog](https://github.com/mydfreecoaching/freemock/blob/main/lib/exams.js): `lib/exams.js`
- [Exam pages](https://github.com/mydfreecoaching/freemock/blob/main/app/exam/%5Bcode%5D/page.js): `app/exam/[code]/page.js`
- [Exam attempts](https://github.com/mydfreecoaching/freemock/blob/main/lib/attempt.js): `lib/attempt.js`
- [Scoring](https://github.com/mydfreecoaching/freemock/blob/main/lib/scoring.js): `lib/scoring.js`
- [Results](https://github.com/mydfreecoaching/freemock/blob/main/app/result/%5Bid%5D/page.js): `app/result/[id]/page.js`
- [Rankings](https://github.com/mydfreecoaching/freemock/blob/main/lib/rank.js): `lib/rank.js`
- [Leaderboards](https://github.com/mydfreecoaching/freemock/blob/main/lib/lb.js): `lib/lb.js`
- [Test analysis](https://github.com/mydfreecoaching/freemock/blob/main/app/analysis/%5Bid%5D/page.js): `app/analysis/[id]/page.js`
- [Analysis engine](https://github.com/mydfreecoaching/freemock/blob/main/lib/analysis.js): `lib/analysis.js`
- [Weekly analysis](https://github.com/mydfreecoaching/freemock/blob/main/app/weekly/page.js): `app/weekly/page.js`

### Administration

- [Admin console](https://github.com/mydfreecoaching/freemock/blob/main/app/admin/page.js): `app/admin/page.js`
- [Admin exports](https://github.com/mydfreecoaching/freemock/blob/main/app/api/admin/export/route.js): `app/api/admin/export/route.js`

### Faculty submissions

- [Faculty portal](https://github.com/mydfreecoaching/freemock/blob/main/app/faculty/page.js): `app/faculty/page.js`
- [Faculty registration](https://github.com/mydfreecoaching/freemock/blob/main/app/api/faculty/register/route.js): `app/api/faculty/register/route.js`
- [Course management](https://github.com/mydfreecoaching/freemock/blob/main/lib/coaching.js): `lib/coaching.js`

### Shared runtime

- [PostgreSQL data](https://github.com/mydfreecoaching/freemock/blob/main/lib/db.js): `lib/db.js`
- [Session auth](https://github.com/mydfreecoaching/freemock/blob/main/lib/auth.js): `lib/auth.js`

### Other components

- **Student**

## Connections

- Student → Registration: registers (evidence: `app/api/register/route.js`)
- Registration → PostgreSQL data: writes profile (evidence: `app/api/register/route.js`)
- Registration → Student profile: updates later
- Registration → Session auth: creates session (evidence: `app/api/register/route.js`)
- Student → Dashboard: opens account (evidence: `app/dashboard/page.js`)
- Dashboard → PostgreSQL data: loads student data (evidence: `app/dashboard/page.js`)
- Dashboard → Exam catalog: loads exams (evidence: `app/dashboard/page.js`)
- Dashboard → Leaderboards: shows rankings
- Student → Exam pages: chooses exam
- Exam pages → Exam attempts: starts attempt
- Exam attempts → Scoring: scores answers
- Scoring → Results: produces result (evidence: `app/result/[id]/page.js`)
- Results → Rankings: shows rank (evidence: `app/result/[id]/page.js`)
- Test analysis → Analysis engine: requests analysis (evidence: `app/analysis/[id]/page.js`)
- Analysis engine → PostgreSQL data: reads attempts (evidence: `lib/analysis.js`)
- Analysis engine → Rankings: uses ranking (evidence: `lib/analysis.js`)
- Weekly analysis → Analysis engine: computes weekly view (evidence: `app/weekly/page.js`)
- Leaderboards → PostgreSQL data: reads results (evidence: `lib/lb.js`)
- Leaderboards → Scoring: finalizes attempts (evidence: `lib/lb.js`)
- Leaderboards → Exam catalog: loads exam list (evidence: `lib/lb.js`)
- Admin console → PostgreSQL data: manages records (evidence: `app/admin/page.js`)
- Admin exports → Analysis engine: exports analysis (evidence: `app/api/admin/export/route.js`)
- Admin exports → PostgreSQL data: queries records (evidence: `app/api/admin/export/route.js`)
- Faculty portal → Course management: loads courses (evidence: `app/faculty/page.js`)
- Faculty portal → Faculty registration: submits registration (evidence: `app/faculty/page.js`)
- Faculty registration → Course management: checks courses (evidence: `app/api/faculty/register/route.js`)
- Course management → PostgreSQL data: stores courses (evidence: `lib/coaching.js`)
