# ammarasad2005/exam-table architecture

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

- Interactive diagram: https://gitdiagram.com/ammarasad2005/exam-table
- Repository: https://github.com/ammarasad2005/exam-table

## Overview

1. **Overall shape**  
   This is a Next.js 14 App Router application that behaves like a static, data-driven scheduling portal. The runtime is mostly client-rendered UI over precomputed JSON files, with one small server API for filtered exam data.

2. **Primary feature boundaries**  
   The app is split into three main user-facing subsystems: **Exam Schedule**, **Weekly Timetable**, and **Free Rooms**. Two additional workflows support irregular students: **Custom Exams** and **Custom Timetable**. Each feature has its own page route and its own filtering/output behavior.

3. **Routing and page organization**  
   Feature routes live under `src/app/`: `/schedule`, `/timetable`, `/rooms`, `/custom`, `/timetable/custom`, plus supporting pages like `/faculty` and `/semester`. `src/app/layout.tsx` and shared shell components provide the common navigation/header/theme structure across these pages.

4. **Data sources and generated artifacts**  
   The app depends on prebuilt data in `public/data/`. Exam-related data is generated from `exam_schedule.xlsx` into a normalized JSON artifact consumed by the schedule feature. Timetable and room data come from a semester schedule source fetched from Google Sheets and are normalized into `public/data/timetable.json`. Faculty-specific schedule data lives in `public/data/faculty/*.json`.

5. **Exam schedule pipeline**  
   The exam flow is driven by the parsed exam dataset and exposed through `/api/schedule`, which returns filtered results for the UI. The client pages support filtering by batch, school, department, and text search, then present grouped-by-date results with a detail drawer and export options.

6. **Timetable pipeline**  
   The timetable feature reads the generated timetable JSON directly and filters it by batch, department, and section. It supports both a list/detail view and a visual grid view, and includes conflict detection plus a repeat-course toggle. This feature is mostly local computation on top of static timetable data.

7. **Free room computation**  
   The room finder is not a separate source of truth; it derives availability from the same timetable dataset. The `room-logic` layer calculates which rooms are fully vacant or partially vacant for a selected day and slot, and also produces a week-wide availability map.

8. **Custom workflows and persistence**  
   The custom exam and custom timetable pages let users build mixed sets from multiple cohorts or course rows. These workflows persist user preferences and reusable bundles in browser storage, so they work without a backend database or account system.

9. **Shared domain logic**  
   Most business rules are centralized in `src/lib/`: date formatting, filtering, export generation, room availability logic, timetable filtering, and shared TypeScript types. This keeps the page components thin and makes the data transformations reusable across exam, timetable, and room views.

10. **UI composition layer**  
   `src/components/` contains reusable UI pieces such as search, cards, detail drawers, export buttons, navigation, theme toggle, and empty states. These components are combined differently per page, but the underlying data model stays consistent across desktop and mobile layouts.

11. **Tooling and build-time automation**  
   `scripts/parse-excel.ts` is the exam-data ingestion step, and `scripts/capture-screenshots.js` automates UI screenshots. The repository also includes a GitHub Actions workflow for timetable updates, plus a few auxiliary scripts/tests for schedule generation and validation. These are build/maintenance tools, not part of the runtime app path.

12. **Architecture summary for a diagram**  
   The key boundaries are: external source data -> build-time normalization scripts -> static JSON in `public/data` -> Next.js pages/components -> optional browser storage for custom bundles. The only server-side runtime endpoint is the exam filter API; everything else is driven by precomputed data and client-side filtering/rendering.

Main entry points: [`src/lib`](https://github.com/ammarasad2005/exam-table/tree/main/src/lib) (Domain Logic), [`public/data/timetable.json`](https://github.com/ammarasad2005/exam-table/blob/main/public/data/timetable.json) (Timetable Data), [`src/app/layout.tsx`](https://github.com/ammarasad2005/exam-table/blob/main/src/app/layout.tsx) (Root Layout), [`src/app/schedule/page.tsx`](https://github.com/ammarasad2005/exam-table/blob/main/src/app/schedule/page.tsx) (Schedule Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Build & Data"]
  node_n1["Exam XLSX<br/>source data<br/>[exam_schedule.xlsx]"]
  node_n2["Sheet Source<br/>external source"]
  node_n3["Parse Excel<br/>ingestion script<br/>[parse-excel.ts]"]
  node_n4["Timetable Update<br/>workflow"]
  node_n5["Screenshots<br/>automation"]
  node_n6[("Exam Data<br/>static dataset")]
  node_n7[("Timetable Data<br/>static dataset<br/>[timetable.json]")]
  node_n8[("Faculty Data<br/>static dataset")]
end

subgraph group_g2["App Runtime"]
  node_n9["Root Layout<br/>app shell<br/>[layout.tsx]"]
  node_n10["Home Pages<br/>landing routes<br/>[page.tsx]"]
  node_n11["Exam API<br/>route handler<br/>[route.ts]"]
  node_n12["Schedule Page<br/>exam UI<br/>[page.tsx]"]
  node_n13["Timetable Page<br/>timetable UI<br/>[page.tsx]"]
  node_n14["Room Finder<br/>availability UI<br/>[page.tsx]"]
  node_n15["Custom Exams<br/>custom workflow<br/>[page.tsx]"]
  node_n16["Custom Timetable<br/>custom workflow<br/>[page.tsx]"]
  node_n17["Faculty View<br/>faculty UI<br/>[page.tsx]"]
  node_n18["Semester View<br/>semester UI<br/>[page.tsx]"]
end

subgraph group_g3["Shared Logic & UI"]
  node_n19["Domain Logic<br/>shared rules"]
  node_n20["UI Components<br/>shared components"]
end

node_n1 -->|"input"| node_n3
node_n2 -->|"source"| node_n4
node_n3 -->|"writes"| node_n6
node_n4 -->|"writes"| node_n7
node_n4 -->|"writes"| node_n8
node_n5 -.->|"captures"| node_n10
node_n9 -->|"wraps"| node_n10
node_n9 -->|"wraps"| node_n12
node_n9 -->|"wraps"| node_n13
node_n9 -->|"wraps"| node_n14
node_n11 -->|"reads"| node_n6
node_n12 -->|"fetches"| node_n11
node_n12 -->|"uses"| node_n19
node_n12 -->|"composes"| node_n20
node_n13 -->|"reads"| node_n7
node_n13 -->|"uses"| node_n19
node_n13 -->|"composes"| node_n20
node_n14 -->|"derives from"| node_n7
node_n14 -->|"uses"| node_n19
node_n15 -->|"reads"| node_n6
node_n15 -->|"uses"| node_n19
node_n16 -->|"reads"| node_n7
node_n16 -->|"uses"| node_n19
node_n17 -->|"reads"| node_n8
node_n17 -->|"uses"| node_n19
node_n18 -->|"reads"| node_n7
node_n18 -->|"composes"| node_n20

click node_n1 "https://github.com/ammarasad2005/exam-table/blob/main/exam_schedule.xlsx"
click node_n3 "https://github.com/ammarasad2005/exam-table/blob/main/scripts/parse-excel.ts"
click node_n4 "https://github.com/ammarasad2005/exam-table/blob/main/.github/workflows/update-timetable.yml"
click node_n5 "https://github.com/ammarasad2005/exam-table/blob/main/scripts/capture-screenshots.js"
click node_n6 "https://github.com/ammarasad2005/exam-table/tree/main/public/data"
click node_n7 "https://github.com/ammarasad2005/exam-table/blob/main/public/data/timetable.json"
click node_n8 "https://github.com/ammarasad2005/exam-table/tree/main/public/data/faculty"
click node_n9 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/layout.tsx"
click node_n10 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/page.tsx"
click node_n11 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/api/schedule/route.ts"
click node_n12 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/schedule/page.tsx"
click node_n13 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/timetable/page.tsx"
click node_n14 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/rooms/page.tsx"
click node_n15 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/custom/page.tsx"
click node_n16 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/timetable/custom/page.tsx"
click node_n17 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/faculty/page.tsx"
click node_n18 "https://github.com/ammarasad2005/exam-table/blob/main/src/app/semester/page.tsx"
click node_n19 "https://github.com/ammarasad2005/exam-table/tree/main/src/lib"
click node_n20 "https://github.com/ammarasad2005/exam-table/tree/main/src/components"

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_n1,node_n2,node_n3,node_n4,node_n5,node_n6,node_n7,node_n8 toneBlue
class node_n9,node_n10,node_n11,node_n12,node_n13,node_n14,node_n15,node_n16,node_n17,node_n18 toneAmber
class node_n19,node_n20 toneMint
```

## Components

### Build & Data

External sources, normalization scripts, and generated static datasets

- [Exam XLSX](https://github.com/ammarasad2005/exam-table/blob/main/exam_schedule.xlsx): source data · Raw exam schedule workbook ingested at build time · `exam_schedule.xlsx`
- **Sheet Source**: external source · Semester timetable source fetched from Google Sheets
- [Parse Excel](https://github.com/ammarasad2005/exam-table/blob/main/scripts/parse-excel.ts): ingestion script · Normalizes exam workbook into app-ready data · `scripts/parse-excel.ts`
- [Timetable Update](https://github.com/ammarasad2005/exam-table/blob/main/.github/workflows/update-timetable.yml): workflow · Automates timetable refresh in CI · `.github/workflows/update-timetable.yml`
- [Screenshots](https://github.com/ammarasad2005/exam-table/blob/main/scripts/capture-screenshots.js): automation · Captures UI screenshots for maintenance and publishing · `scripts/capture-screenshots.js`
- [Exam Data](https://github.com/ammarasad2005/exam-table/tree/main/public/data): static dataset · Normalized exam schedule consumed by schedule pages and API · `public/data`
- [Timetable Data](https://github.com/ammarasad2005/exam-table/blob/main/public/data/timetable.json): static dataset · Generated timetable and faculty JSON used by timetable and room views · `public/data/timetable.json`
- [Faculty Data](https://github.com/ammarasad2005/exam-table/tree/main/public/data/faculty): static dataset · Faculty-specific schedule bundles · `public/data/faculty`

### App Runtime

Next.js routes, pages, and API surface

- [Root Layout](https://github.com/ammarasad2005/exam-table/blob/main/src/app/layout.tsx): app shell · Common app chrome and providers · `src/app/layout.tsx`
- [Home Pages](https://github.com/ammarasad2005/exam-table/blob/main/src/app/page.tsx): landing routes · Entry routes that point users into the main portal · `src/app/page.tsx`
- [Exam API](https://github.com/ammarasad2005/exam-table/blob/main/src/app/api/schedule/route.ts): route handler · Filters exam data for the client schedule views · `src/app/api/schedule/route.ts`
- [Schedule Page](https://github.com/ammarasad2005/exam-table/blob/main/src/app/schedule/page.tsx): exam UI · Grouped exam schedule with filtering, detail drawer, and export · `src/app/schedule/page.tsx`
- [Timetable Page](https://github.com/ammarasad2005/exam-table/blob/main/src/app/timetable/page.tsx): timetable UI · Batch, department, and section filtered timetable with grid/list views · `src/app/timetable/page.tsx`
- [Room Finder](https://github.com/ammarasad2005/exam-table/blob/main/src/app/rooms/page.tsx): availability UI · Derives empty and partially free rooms from timetable data · `src/app/rooms/page.tsx`
- [Custom Exams](https://github.com/ammarasad2005/exam-table/blob/main/src/app/custom/page.tsx): custom workflow · User-built exam sets across cohorts with browser persistence · `src/app/custom/page.tsx`
- [Custom Timetable](https://github.com/ammarasad2005/exam-table/blob/main/src/app/timetable/custom/page.tsx): custom workflow · User-built timetable bundles across course rows with browser persistence · `src/app/timetable/custom/page.tsx`
- [Faculty View](https://github.com/ammarasad2005/exam-table/blob/main/src/app/faculty/page.tsx): faculty UI · Faculty-specific schedule browsing and detail display · `src/app/faculty/page.tsx`
- [Semester View](https://github.com/ammarasad2005/exam-table/blob/main/src/app/semester/page.tsx): semester UI · Supporting semester schedule browsing page · `src/app/semester/page.tsx`

### Shared Logic & UI

Reusable business rules and presentation components

- [Domain Logic](https://github.com/ammarasad2005/exam-table/tree/main/src/lib): shared rules · Dates, filtering, export generation, room logic, and timetable rules · `src/lib`
- [UI Components](https://github.com/ammarasad2005/exam-table/tree/main/src/components): shared components · Search, cards, drawers, navigation, theme, and empty states · `src/components`

## Connections

- Exam XLSX → Parse Excel: input · Workbook parsed into normalized exam records
- Sheet Source → Timetable Update: source · Workflow refreshes timetable artifacts from sheet data
- Parse Excel → Exam Data: writes · Build step produces static exam dataset
- Timetable Update → Timetable Data: writes · CI pipeline updates timetable JSON
- Timetable Update → Faculty Data: writes · Refreshes faculty schedule artifacts
- Screenshots → Home Pages: captures · Uses rendered pages for screenshots
- Root Layout → Home Pages: wraps · Shared shell around the app routes
- Root Layout → Schedule Page: wraps · Common layout for schedule flow
- Root Layout → Timetable Page: wraps · Common layout for timetable flow
- Root Layout → Room Finder: wraps · Common layout for room finder
- Exam API → Exam Data: reads · API filters the generated exam dataset
- Schedule Page → Exam API: fetches · Schedule UI requests filtered exam results
- Schedule Page → Domain Logic: uses · Relies on shared filtering, dates, and exports
- Schedule Page → UI Components: composes · Uses cards, search, drawer, and export controls
- Timetable Page → Timetable Data: reads · Timetable UI consumes static timetable JSON
- Timetable Page → Domain Logic: uses · Applies timetable filtering and conflict logic
- Timetable Page → UI Components: composes · Uses timetable cards, detail view, and export UI
- Room Finder → Timetable Data: derives from · Room availability is computed from timetable data
- Room Finder → Domain Logic: uses · Uses room-logic and date helpers
- Custom Exams → Exam Data: reads · Builds custom exam sets from exam data
- Custom Exams → Domain Logic: uses · Shares export and filtering helpers
- Custom Timetable → Timetable Data: reads · Builds custom timetable bundles from timetable data
- Custom Timetable → Domain Logic: uses · Shares timetable filtering and formatting helpers
- Faculty View → Faculty Data: reads · Faculty page consumes faculty-specific JSON
- Faculty View → Domain Logic: uses · Uses shared date and formatting logic
- Semester View → Timetable Data: reads · Semester page is backed by timetable data
- Semester View → UI Components: composes · Uses shared presentation pieces
