# hiteshgarg2004/attendance architecture

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

- Interactive diagram: https://gitdiagram.com/hiteshgarg2004/attendance
- Repository: https://github.com/hiteshgarg2004/attendance

## Overview

1. **High-level shape**
   - This is a classic two-part application: a **Node.js backend** in `backend/` and a **React frontend SPA** in `frontend/`.
   - The system centers on **attendance management for classes, students, teachers, and attendance records**.

2. **Backend boundary**
   - `backend/server.js` is the entrypoint for the API server.
   - The backend is organized around **route modules** under `backend/routes/` and **data models** under `backend/models/`.
   - The presence of model files strongly suggests a **MongoDB/Mongoose-style persistence layer**, with environment configuration in `backend/.env`.

3. **Domain data model**
   - The core entities are:
     - `Student`
     - `Teacher`
     - `Class`
     - `Attendance`
     - `StudentMaster`
   - `StudentMaster` likely acts as a canonical student registry, separate from class-specific enrollment or attendance state.

4. **Backend API surface**
   - Routes are separated by domain:
     - `auth.js` for login/signup/session or token handling
     - `classes.js` for class lifecycle and class-related queries
     - `students.js` for student CRUD and/or enrollment
     - `studentMaster.js` for the master student list
     - `attendance.js` for attendance creation/querying
     - `attendance-batch-students.js` for bulk attendance operations by batch
   - This suggests a **REST-style API** with domain-specific endpoints rather than a single monolithic controller.

5. **Authentication boundary**
   - `backend/utils/auth.js` likely contains reusable auth middleware/helpers, used to protect selected routes.
   - The frontend includes `Login` and `Signup` pages, so authentication is a first-class boundary between client and API.

6. **Bulk attendance workflow**
   - The presence of `attendance-batch-students.js` and the frontend `BatchAttendance.jsx`/`AttendanceSheet.jsx` implies a specialized flow for taking attendance for many students at once.
   - This is likely distinct from single-student attendance actions and is an important data-flow boundary in the app.

7. **Frontend structure**
   - The frontend is a **Vite-based React app** (`frontend/vite.config.js`, `frontend/src/main.jsx`).
   - Pages are organized by use case:
     - `Dashboard`
     - `ClassPage`
     - `CreateClass`
     - `AddStudent`
     - `StudentAttendance`
     - `BatchAttendance`
     - `AttendanceHistory`
     - `Login`
     - `Signup`

8. **Frontend composition**
   - Shared UI is kept in `frontend/src/components/`:
     - `Header.jsx` for top-level navigation or app shell
     - `ToastProvider.jsx` for notifications
     - `AttendanceSheet.jsx` as a reusable attendance UI unit
   - `frontend/src/api/apiClient.js` is the client-side boundary for all backend calls, so the pages likely do not talk to the server directly.

9. **Primary data flows**
   - Typical flow is:
     1. User authenticates through `Login`/`Signup`
     2. Frontend stores or uses auth state via the API client
     3. User navigates to class/student/attendance pages
     4. Pages call backend endpoints through `apiClient.js`
     5. Backend routes validate/authenticate, then read/write models
     6. Responses drive UI updates and history views
   - Attendance history and batch entry are the main read/write loops.

10. **Operational/configuration concerns**
   - `backend/.env` indicates backend secrets/config are environment-driven.
   - `package.json` and lockfiles in both backend and frontend show the project is managed as two independent npm apps.
   - The frontend also includes Tailwind/PostCSS config, so styling is utility-based rather than a custom CSS architecture only.

11. **Seed and maintenance utilities**
   - `backend/seedStudents.js` is a one-off data seeding script, likely used to populate the student registry or test data.
   - `TODO.md` suggests there may be planned features or cleanup items, but it is not part of the runtime architecture.

12. **Diagram-friendly summary**
   - Draw the repo as:
     - **React SPA** on one side with pages and shared components
     - **API client** as the frontend’s network boundary
     - **Node/Express backend** in the middle with route modules
     - **Persistence models** behind the routes
     - **Auth middleware/utilities** guarding protected endpoints
   - The central business capability is **creating classes, managing students, and recording/querying attendance**, especially in batch form.

Main entry points: [`frontend/src/App.jsx`](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/App.jsx) (App shell), [`frontend/src/api/apiClient.js`](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/api/apiClient.js) (API client), [`backend/server.js`](https://github.com/hiteshgarg2004/attendance/blob/main/backend/server.js) (Server), [`backend/models/Student.js`](https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Student.js) (Student)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_frontend_main["Entry<br/>Vite bootstrap<br/>[main.jsx]"]
  node_frontend_app["App shell<br/>React shell<br/>[App.jsx]"]
  node_api_client["API client<br/>HTTP client<br/>[apiClient.js]"]
  node_header["Header<br/>UI component<br/>[Header.jsx]"]
  node_toast["Toasts<br/>UI provider<br/>[ToastProvider.jsx]"]
  node_attendance_sheet["Sheet<br/>UI component"]
  node_dashboard["Dashboard<br/>Page<br/>[Dashboard.jsx]"]
  node_class_page["Class page<br/>[ClassPage.jsx]"]
  node_create_class["Create class<br/>Page<br/>[CreateClass.jsx]"]
  node_add_student["Add student<br/>Page<br/>[AddStudent.jsx]"]
  node_student_attendance["Student attendance<br/>Page"]
  node_batch_attendance["Batch attendance<br/>Page"]
  node_attendance_history["History<br/>Page"]
  node_login["Login<br/>Page<br/>[Login.jsx]"]
  node_signup["Signup<br/>Page<br/>[Signup.jsx]"]
end

subgraph group_backend["Backend API"]
  node_server["Server<br/>Express entrypoint<br/>[server.js]"]
  node_route_auth["Auth routes<br/>API route<br/>[auth.js]"]
  node_route_classes["Class routes<br/>API route<br/>[classes.js]"]
  node_route_students["Student routes<br/>API route<br/>[students.js]"]
  node_route_student_master["Master routes<br/>API route<br/>[studentMaster.js]"]
  node_route_attendance["Attendance routes<br/>API route<br/>[attendance.js]"]
  node_route_batch_attendance["Batch routes<br/>API route"]
  node_auth_utils["Auth utils<br/>Middleware/helpers<br/>[auth.js]"]
  node_seed_students["Seed data<br/>Script<br/>[seedStudents.js]"]
end

subgraph group_domain["Domain Model"]
  node_model_student_master[("StudentMaster<br/>Mongoose model<br/>[StudentMaster.js]")]
  node_model_student[("Student<br/>Mongoose model<br/>[Student.js]")]
  node_model_class[("Class<br/>Mongoose model<br/>[Class.js]")]
  node_model_attendance[("Attendance<br/>Mongoose model<br/>[Attendance.js]")]
  node_model_teacher[("Teacher<br/>Mongoose model<br/>[Teacher.js]")]
end

node_frontend_main -->|"bootstraps"| node_frontend_app
node_frontend_app -->|"uses"| node_header
node_frontend_app -->|"uses"| node_toast
node_frontend_app -->|"routes to"| node_dashboard
node_frontend_app -->|"routes to"| node_login
node_frontend_app -->|"routes to"| node_signup
node_frontend_app -->|"routes to"| node_class_page
node_frontend_app -->|"routes to"| node_create_class
node_frontend_app -->|"routes to"| node_add_student
node_frontend_app -->|"routes to"| node_student_attendance
node_frontend_app -->|"routes to"| node_batch_attendance
node_frontend_app -->|"routes to"| node_attendance_history
node_student_attendance -->|"uses"| node_attendance_sheet
node_batch_attendance -->|"uses"| node_attendance_sheet
node_dashboard -->|"calls"| node_api_client
node_class_page -->|"calls"| node_api_client
node_create_class -->|"calls"| node_api_client
node_add_student -->|"calls"| node_api_client
node_student_attendance -->|"calls"| node_api_client
node_batch_attendance -->|"calls"| node_api_client
node_attendance_history -->|"calls"| node_api_client
node_login -->|"calls"| node_api_client
node_signup -->|"calls"| node_api_client
node_api_client -->|"talks to"| node_server
node_server -->|"mounts"| node_route_auth
node_server -->|"mounts"| node_route_classes
node_server -->|"mounts"| node_route_students
node_server -->|"mounts"| node_route_student_master
node_server -->|"mounts"| node_route_attendance
node_server -->|"mounts"| node_route_batch_attendance
node_route_auth -->|"uses"| node_auth_utils
node_route_classes -->|"reads/writes"| node_model_class
node_route_students -->|"reads/writes"| node_model_student
node_route_students -->|"relates to"| node_model_class
node_route_student_master -->|"reads/writes"| node_model_student_master
node_route_attendance -->|"reads/writes"| node_model_attendance
node_route_attendance -->|"relates to"| node_model_student
node_route_attendance -->|"relates to"| node_model_class
node_route_batch_attendance -->|"reads/writes"| node_model_attendance
node_route_batch_attendance -->|"relates to"| node_model_student
node_seed_students -->|"seeds"| node_model_student_master
node_seed_students -->|"seeds"| node_model_student
node_model_student -.->|"related domain"| node_model_teacher

click node_frontend_main "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/main.jsx"
click node_frontend_app "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/api/apiClient.js"
click node_header "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/components/Header.jsx"
click node_toast "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/components/ToastProvider.jsx"
click node_attendance_sheet "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/components/AttendanceSheet.jsx"
click node_dashboard "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/Dashboard.jsx"
click node_class_page "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/ClassPage.jsx"
click node_create_class "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/CreateClass.jsx"
click node_add_student "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/AddStudent.jsx"
click node_student_attendance "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/StudentAttendance.jsx"
click node_batch_attendance "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/BatchAttendance.jsx"
click node_attendance_history "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/AttendanceHistory.jsx"
click node_login "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/Login.jsx"
click node_signup "https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/Signup.jsx"
click node_server "https://github.com/hiteshgarg2004/attendance/blob/main/backend/server.js"
click node_route_auth "https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/auth.js"
click node_route_classes "https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/classes.js"
click node_route_students "https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/students.js"
click node_route_student_master "https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/studentMaster.js"
click node_route_attendance "https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/attendance.js"
click node_route_batch_attendance "https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/attendance-batch-students.js"
click node_auth_utils "https://github.com/hiteshgarg2004/attendance/blob/main/backend/utils/auth.js"
click node_model_student_master "https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/StudentMaster.js"
click node_model_student "https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Student.js"
click node_model_class "https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Class.js"
click node_model_attendance "https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Attendance.js"
click node_model_teacher "https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Teacher.js"
click node_seed_students "https://github.com/hiteshgarg2004/attendance/blob/main/backend/seedStudents.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_frontend_main,node_frontend_app,node_api_client,node_header,node_toast,node_attendance_sheet,node_dashboard,node_class_page,node_create_class,node_add_student,node_student_attendance,node_batch_attendance,node_attendance_history,node_login,node_signup toneBlue
class node_server,node_route_auth,node_route_classes,node_route_students,node_route_student_master,node_route_attendance,node_route_batch_attendance,node_auth_utils,node_seed_students toneAmber
class node_model_student_master,node_model_student,node_model_class,node_model_attendance,node_model_teacher toneMint
```

## Components

### Frontend SPA

React/Vite client application

- [Entry](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/main.jsx): Vite bootstrap · Frontend application entrypoint · `frontend/src/main.jsx`
- [App shell](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/App.jsx): React shell · Top-level client routing and layout · `frontend/src/App.jsx`
- [API client](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/api/apiClient.js): HTTP client · Frontend boundary for backend requests · `frontend/src/api/apiClient.js`
- [Header](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/components/Header.jsx): UI component · Top navigation and app chrome · `frontend/src/components/Header.jsx`
- [Toasts](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/components/ToastProvider.jsx): UI provider · Notification and feedback provider · `frontend/src/components/ToastProvider.jsx`
- [Sheet](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/components/AttendanceSheet.jsx): UI component · Reusable attendance-taking interface · `frontend/src/components/AttendanceSheet.jsx`
- [Dashboard](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/Dashboard.jsx): Page · Landing and overview screen · `frontend/src/pages/Dashboard.jsx`
- [Class page](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/ClassPage.jsx): Page · Class details and class actions · `frontend/src/pages/ClassPage.jsx`
- [Create class](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/CreateClass.jsx): Page · Class creation workflow · `frontend/src/pages/CreateClass.jsx`
- [Add student](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/AddStudent.jsx): Page · Student creation or enrollment flow · `frontend/src/pages/AddStudent.jsx`
- [Student attendance](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/StudentAttendance.jsx): Page · Single-student attendance workflow · `frontend/src/pages/StudentAttendance.jsx`
- [Batch attendance](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/BatchAttendance.jsx): Page · Bulk attendance workflow · `frontend/src/pages/BatchAttendance.jsx`
- [History](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/AttendanceHistory.jsx): Page · Attendance lookup and history view · `frontend/src/pages/AttendanceHistory.jsx`
- [Login](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/Login.jsx): Page · Authentication entry screen · `frontend/src/pages/Login.jsx`
- [Signup](https://github.com/hiteshgarg2004/attendance/blob/main/frontend/src/pages/Signup.jsx): Page · Account registration screen · `frontend/src/pages/Signup.jsx`

### Backend API

Node/Express server and data layer

- [Server](https://github.com/hiteshgarg2004/attendance/blob/main/backend/server.js): Express entrypoint · Backend application bootstrap · `backend/server.js`
- [Auth routes](https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/auth.js): API route · Login and signup endpoints · `backend/routes/auth.js`
- [Class routes](https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/classes.js): API route · Class lifecycle and queries · `backend/routes/classes.js`
- [Student routes](https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/students.js): API route · Student CRUD and enrollment endpoints · `backend/routes/students.js`
- [Master routes](https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/studentMaster.js): API route · Canonical student registry endpoints · `backend/routes/studentMaster.js`
- [Attendance routes](https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/attendance.js): API route · Attendance create and query endpoints · `backend/routes/attendance.js`
- [Batch routes](https://github.com/hiteshgarg2004/attendance/blob/main/backend/routes/attendance-batch-students.js): API route · Bulk attendance endpoints · `backend/routes/attendance-batch-students.js`
- [Auth utils](https://github.com/hiteshgarg2004/attendance/blob/main/backend/utils/auth.js): Middleware/helpers · Reusable authentication guard and helpers · `backend/utils/auth.js`
- [Seed data](https://github.com/hiteshgarg2004/attendance/blob/main/backend/seedStudents.js): Script · One-off student population script · `backend/seedStudents.js`

### Domain Model

Core attendance entities

- [StudentMaster](https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/StudentMaster.js): Mongoose model · Canonical student registry · `backend/models/StudentMaster.js`
- [Student](https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Student.js): Mongoose model · Student records and enrollment data · `backend/models/Student.js`
- [Class](https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Class.js): Mongoose model · Classroom or cohort entity · `backend/models/Class.js`
- [Attendance](https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Attendance.js): Mongoose model · Attendance record store · `backend/models/Attendance.js`
- [Teacher](https://github.com/hiteshgarg2004/attendance/blob/main/backend/models/Teacher.js): Mongoose model · Teacher records · `backend/models/Teacher.js`

## Connections

- Entry → App shell: bootstraps · Vite starts the React application
- App shell → Header: uses · App shell composes shared navigation
- App shell → Toasts: uses · App shell provides notifications
- App shell → Dashboard: routes to · Top-level navigation between pages
- App shell → Login: routes to · Authentication entry screen
- App shell → Signup: routes to · Registration screen
- App shell → Class page: routes to · Class management views
- App shell → Create class: routes to · Class creation flow
- App shell → Add student: routes to · Student management flow
- App shell → Student attendance: routes to · Single attendance workflow
- App shell → Batch attendance: routes to · Bulk attendance workflow
- App shell → History: routes to · Historical attendance views
- Student attendance → Sheet: uses · Attendance page reuses shared sheet UI
- Batch attendance → Sheet: uses · Bulk flow reuses shared sheet UI
- Dashboard → API client: calls · Pages fetch data through the API client
- Class page → API client: calls · Class data and actions
- Create class → API client: calls · Creates classes through backend APIs
- Add student → API client: calls · Creates or links students through backend APIs
- Student attendance → API client: calls · Writes attendance records
- Batch attendance → API client: calls · Submits bulk attendance updates
- History → API client: calls · Reads attendance history
- Login → API client: calls · Authenticates against backend
- Signup → API client: calls · Registers new users
- API client → Server: talks to · Frontend network boundary into backend server
- Server → Auth routes: mounts · Express server registers auth routes
- Server → Class routes: mounts · Express server registers class routes
- Server → Student routes: mounts · Express server registers student routes
- Server → Master routes: mounts · Express server registers master student routes
- Server → Attendance routes: mounts · Express server registers attendance routes
- Server → Batch routes: mounts · Express server registers bulk attendance routes
- Auth routes → Auth utils: uses · Auth routes share middleware and helpers
- Class routes → Class: reads/writes · Class endpoints persist class data
- Student routes → Student: reads/writes · Student endpoints persist student data
- Student routes → Class: relates to · Student enrollment is tied to classes
- Master routes → StudentMaster: reads/writes · Master registry persistence
- Attendance routes → Attendance: reads/writes · Attendance endpoints persist records
- Attendance routes → Student: relates to · Attendance is associated with students
- Attendance routes → Class: relates to · Attendance is associated with classes
- Batch routes → Attendance: reads/writes · Bulk attendance updates records
- Batch routes → Student: relates to · Batch flow operates over student lists
- Seed data → StudentMaster: seeds · Seed script populates canonical student data
- Seed data → Student: seeds · Seed script can also create student records
- Student → Teacher: related domain · Teacher and student entities are part of the same academic model
