# hpsanjel/magicchalk architecture

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

- Interactive diagram: https://gitdiagram.com/hpsanjel/magicchalk
- Repository: https://github.com/hpsanjel/magicchalk

## Overview

This is a Next.js school website and management portal. Families can explore school information, submit admissions, contact, and tour requests; authenticated parents, teachers, and administrators use dashboards for students, appointments, assignments, and school operations. The sampled routes show MongoDB-backed student, teacher, appointment, and tour-booking workflows, with email notifications in some flows. Many listed capabilities are represented by route and page paths, but their internal wiring was not sampled, so the graph limits detailed connections to indexed references and excerpts.

Main entry points: [`app/api/students/route.js`](https://github.com/hpsanjel/magicchalk/blob/main/app/api/students/route.js) (Student API), [`app/api/appointments/route.js`](https://github.com/hpsanjel/magicchalk/blob/main/app/api/appointments/route.js) (Appointment API), [`lib/mongodb.js`](https://github.com/hpsanjel/magicchalk/blob/main/lib/mongodb.js) (MongoDB connection), [`app/api/teachers/route.js`](https://github.com/hpsanjel/magicchalk/blob/main/app/api/teachers/route.js) (Teacher API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public Website"]
  node_homepage["School homepage<br/>[page.tsx]"]
  node_school_content["School content pages<br/>[page.tsx]"]
  node_contact["Contact form<br/>[page.tsx]"]
  node_admissions["Admissions form<br/>[page.jsx]"]
  node_tour_form["Tour booking form<br/>[page.jsx]"]
end

subgraph group_portals["School Portals"]
  node_admin["Administrator dashboard<br/>[page.jsx]"]
  node_parent_portal["Parent dashboard<br/>[page.tsx]"]
  node_teacher_portal["Teacher dashboard<br/>[page.jsx]"]
  node_student_form["Student enrollment UI<br/>[StudentForm.tsx]"]
  node_appointment_ui["Appointment dialog"]
end

subgraph group_services["Application Services"]
  node_fetch_hook["API data hook<br/>[useFetchData.js]"]
  node_student_api["Student API<br/>[route.js]"]
  node_teacher_api["Teacher API<br/>[route.js]"]
  node_appointment_api["Appointment API<br/>[route.js]"]
  node_assignment_api["Assignment API<br/>[route.js]"]
  node_tour_api["Tour booking API<br/>[route.js]"]
  node_message_action["Message submission action<br/>[submitMessage.ts]"]
  node_email["Email notifications<br/>[email.ts]"]
end

subgraph group_data["Persistence"]
  node_db_connection["MongoDB connection<br/>[mongodb.js]"]
  node_student_model[("Student records<br/>[Student.Model.js]")]
  node_teacher_model[("Teacher records<br/>[Teacher.Model.js]")]
  node_user_model[("User accounts<br/>[User.Model.js]")]
  node_appointment_model[("Appointment records")]
  node_tour_model[("Tour booking records")]
  node_message_model[("Messages<br/>[Message.Model.js]")]
  node_assignment_model[("Assignments")]
end

node_visitor(("Visitor or family"))

node_visitor -->|"browses"| node_homepage
node_visitor -.->|"views"| node_school_content
node_visitor -->|"submits message"| node_contact
node_visitor -->|"starts enrollment"| node_admissions
node_visitor -.->|"requests tour"| node_tour_form
node_contact -->|"submits"| node_message_action
node_message_action -->|"connects"| node_db_connection
node_message_action -->|"saves message"| node_message_model
node_homepage -->|"renders sections"| node_school_content
node_homepage -.->|"loads content"| node_fetch_hook
node_parent_portal -->|"opens dialog"| node_appointment_ui
node_student_form -.->|"submits enrollment"| node_student_api
node_parent_portal -.->|"loads students"| node_student_api
node_parent_portal -.->|"requests appointments"| node_appointment_api
node_teacher_portal -.->|"manages assignments"| node_assignment_api
node_admin -.->|"manages bookings"| node_tour_api
node_student_api -->|"connects"| node_db_connection
node_student_api -->|"reads and writes"| node_student_model
node_student_api -->|"creates parent account"| node_user_model
node_student_api -->|"sends welcome email"| node_email
node_teacher_api -->|"connects"| node_db_connection
node_teacher_api -->|"reads and writes"| node_teacher_model
node_teacher_api -->|"checks and creates"| node_user_model
node_teacher_api -->|"sends invite"| node_email
node_appointment_api -->|"connects"| node_db_connection
node_appointment_api -->|"creates and queries"| node_appointment_model
node_appointment_api -->|"looks up student"| node_student_model
node_appointment_api -->|"looks up teacher"| node_teacher_model
node_appointment_api -->|"looks up parent"| node_user_model
node_tour_api -->|"connects"| node_db_connection
node_tour_api -->|"creates and updates"| node_tour_model
node_tour_api -->|"sends confirmation"| node_email
node_assignment_api -->|"connects"| node_db_connection
node_assignment_api -->|"filters by students"| node_student_model
node_fetch_hook -.->|"fetches data"| node_student_api

click node_homepage "https://github.com/hpsanjel/magicchalk/blob/main/app/page.tsx"
click node_school_content "https://github.com/hpsanjel/magicchalk/blob/main/app/programs/page.tsx"
click node_contact "https://github.com/hpsanjel/magicchalk/blob/main/app/contact/page.tsx"
click node_admissions "https://github.com/hpsanjel/magicchalk/blob/main/app/admission/page.jsx"
click node_tour_form "https://github.com/hpsanjel/magicchalk/blob/main/app/school-tour-form/page.jsx"
click node_admin "https://github.com/hpsanjel/magicchalk/blob/main/app/dashboard/page.jsx"
click node_parent_portal "https://github.com/hpsanjel/magicchalk/blob/main/app/parents/dashboard/page.tsx"
click node_teacher_portal "https://github.com/hpsanjel/magicchalk/blob/main/app/teachers/dashboard/page.jsx"
click node_student_form "https://github.com/hpsanjel/magicchalk/blob/main/components/StudentForm.tsx"
click node_appointment_ui "https://github.com/hpsanjel/magicchalk/blob/main/app/parents/dashboard/appointment-modal.tsx"
click node_fetch_hook "https://github.com/hpsanjel/magicchalk/blob/main/hooks/useFetchData.js"
click node_student_api "https://github.com/hpsanjel/magicchalk/blob/main/app/api/students/route.js"
click node_teacher_api "https://github.com/hpsanjel/magicchalk/blob/main/app/api/teachers/route.js"
click node_appointment_api "https://github.com/hpsanjel/magicchalk/blob/main/app/api/appointments/route.js"
click node_assignment_api "https://github.com/hpsanjel/magicchalk/blob/main/app/api/assignments/route.js"
click node_tour_api "https://github.com/hpsanjel/magicchalk/blob/main/app/api/tour-bookings/route.js"
click node_message_action "https://github.com/hpsanjel/magicchalk/blob/main/app/actions/submitMessage.ts"
click node_email "https://github.com/hpsanjel/magicchalk/blob/main/lib/email.ts"
click node_db_connection "https://github.com/hpsanjel/magicchalk/blob/main/lib/mongodb.js"
click node_student_model "https://github.com/hpsanjel/magicchalk/blob/main/models/Student.Model.js"
click node_teacher_model "https://github.com/hpsanjel/magicchalk/blob/main/models/Teacher.Model.js"
click node_user_model "https://github.com/hpsanjel/magicchalk/blob/main/models/User.Model.js"
click node_appointment_model "https://github.com/hpsanjel/magicchalk/blob/main/models/Appointment.Model.js"
click node_tour_model "https://github.com/hpsanjel/magicchalk/blob/main/models/TourBooking.Model.js"
click node_message_model "https://github.com/hpsanjel/magicchalk/blob/main/models/Message.Model.js"
click node_assignment_model "https://github.com/hpsanjel/magicchalk/blob/main/models/Assignment.Model.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_homepage,node_school_content,node_contact,node_admissions,node_tour_form toneBlue
class node_admin,node_parent_portal,node_teacher_portal,node_student_form,node_appointment_ui toneAmber
class node_fetch_hook,node_student_api,node_teacher_api,node_appointment_api,node_assignment_api,node_tour_api,node_message_action,node_email toneMint
class node_db_connection,node_student_model,node_teacher_model,node_user_model,node_appointment_model,node_tour_model,node_message_model,node_assignment_model toneRose
class node_visitor toneIndigo
```

## Components

### Public Website

- [School homepage](https://github.com/hpsanjel/magicchalk/blob/main/app/page.tsx): `app/page.tsx`
- [School content pages](https://github.com/hpsanjel/magicchalk/blob/main/app/programs/page.tsx): `app/programs/page.tsx`
- [Contact form](https://github.com/hpsanjel/magicchalk/blob/main/app/contact/page.tsx): `app/contact/page.tsx`
- [Admissions form](https://github.com/hpsanjel/magicchalk/blob/main/app/admission/page.jsx): `app/admission/page.jsx`
- [Tour booking form](https://github.com/hpsanjel/magicchalk/blob/main/app/school-tour-form/page.jsx): `app/school-tour-form/page.jsx`

### School Portals

- [Administrator dashboard](https://github.com/hpsanjel/magicchalk/blob/main/app/dashboard/page.jsx): `app/dashboard/page.jsx`
- [Parent dashboard](https://github.com/hpsanjel/magicchalk/blob/main/app/parents/dashboard/page.tsx): `app/parents/dashboard/page.tsx`
- [Teacher dashboard](https://github.com/hpsanjel/magicchalk/blob/main/app/teachers/dashboard/page.jsx): `app/teachers/dashboard/page.jsx`
- [Student enrollment UI](https://github.com/hpsanjel/magicchalk/blob/main/components/StudentForm.tsx): `components/StudentForm.tsx`
- [Appointment dialog](https://github.com/hpsanjel/magicchalk/blob/main/app/parents/dashboard/appointment-modal.tsx): `app/parents/dashboard/appointment-modal.tsx`

### Application Services

- [API data hook](https://github.com/hpsanjel/magicchalk/blob/main/hooks/useFetchData.js): `hooks/useFetchData.js`
- [Student API](https://github.com/hpsanjel/magicchalk/blob/main/app/api/students/route.js): `app/api/students/route.js`
- [Teacher API](https://github.com/hpsanjel/magicchalk/blob/main/app/api/teachers/route.js): `app/api/teachers/route.js`
- [Appointment API](https://github.com/hpsanjel/magicchalk/blob/main/app/api/appointments/route.js): `app/api/appointments/route.js`
- [Assignment API](https://github.com/hpsanjel/magicchalk/blob/main/app/api/assignments/route.js): `app/api/assignments/route.js`
- [Tour booking API](https://github.com/hpsanjel/magicchalk/blob/main/app/api/tour-bookings/route.js): `app/api/tour-bookings/route.js`
- [Message submission action](https://github.com/hpsanjel/magicchalk/blob/main/app/actions/submitMessage.ts): `app/actions/submitMessage.ts`
- [Email notifications](https://github.com/hpsanjel/magicchalk/blob/main/lib/email.ts): `lib/email.ts`

### Persistence

- [MongoDB connection](https://github.com/hpsanjel/magicchalk/blob/main/lib/mongodb.js): `lib/mongodb.js`
- [Student records](https://github.com/hpsanjel/magicchalk/blob/main/models/Student.Model.js): `models/Student.Model.js`
- [Teacher records](https://github.com/hpsanjel/magicchalk/blob/main/models/Teacher.Model.js): `models/Teacher.Model.js`
- [User accounts](https://github.com/hpsanjel/magicchalk/blob/main/models/User.Model.js): `models/User.Model.js`
- [Appointment records](https://github.com/hpsanjel/magicchalk/blob/main/models/Appointment.Model.js): `models/Appointment.Model.js`
- [Tour booking records](https://github.com/hpsanjel/magicchalk/blob/main/models/TourBooking.Model.js): `models/TourBooking.Model.js`
- [Messages](https://github.com/hpsanjel/magicchalk/blob/main/models/Message.Model.js): `models/Message.Model.js`
- [Assignments](https://github.com/hpsanjel/magicchalk/blob/main/models/Assignment.Model.js): `models/Assignment.Model.js`

### Other components

- **Visitor or family**

## Connections

- Visitor or family → School homepage: browses (evidence: `app/page.tsx`)
- Visitor or family → School content pages: views
- Visitor or family → Contact form: submits message (evidence: `app/contact/page.tsx`)
- Visitor or family → Admissions form: starts enrollment (evidence: `app/admission/page.jsx`)
- Visitor or family → Tour booking form: requests tour
- Contact form → Message submission action: submits (evidence: `app/contact/page.tsx`)
- Message submission action → MongoDB connection: connects (evidence: `app/actions/submitMessage.ts`)
- Message submission action → Messages: saves message (evidence: `app/actions/submitMessage.ts`)
- School homepage → School content pages: renders sections (evidence: `app/page.tsx`)
- School homepage → API data hook: loads content
- Parent dashboard → Appointment dialog: opens dialog (evidence: `app/parents/dashboard/page.tsx`)
- Student enrollment UI → Student API: submits enrollment
- Parent dashboard → Student API: loads students
- Parent dashboard → Appointment API: requests appointments
- Teacher dashboard → Assignment API: manages assignments
- Administrator dashboard → Tour booking API: manages bookings
- Student API → MongoDB connection: connects (evidence: `app/api/students/route.js`)
- Student API → Student records: reads and writes (evidence: `app/api/students/route.js`)
- Student API → User accounts: creates parent account (evidence: `app/api/students/route.js`)
- Student API → Email notifications: sends welcome email (evidence: `app/api/students/route.js`)
- Teacher API → MongoDB connection: connects (evidence: `app/api/teachers/route.js`)
- Teacher API → Teacher records: reads and writes (evidence: `app/api/teachers/route.js`)
- Teacher API → User accounts: checks and creates (evidence: `app/api/teachers/route.js`)
- Teacher API → Email notifications: sends invite (evidence: `app/api/teachers/route.js`)
- Appointment API → MongoDB connection: connects (evidence: `app/api/appointments/route.js`)
- Appointment API → Appointment records: creates and queries (evidence: `app/api/appointments/route.js`)
- Appointment API → Student records: looks up student (evidence: `app/api/appointments/route.js`)
- Appointment API → Teacher records: looks up teacher (evidence: `app/api/appointments/route.js`)
- Appointment API → User accounts: looks up parent (evidence: `app/api/appointments/route.js`)
- Tour booking API → MongoDB connection: connects (evidence: `app/api/tour-bookings/route.js`)
- Tour booking API → Tour booking records: creates and updates (evidence: `app/api/tour-bookings/route.js`)
- Tour booking API → Email notifications: sends confirmation (evidence: `app/api/tour-bookings/route.js`)
- Assignment API → MongoDB connection: connects (evidence: `app/api/assignments/route.js`)
- Assignment API → Student records: filters by students (evidence: `app/api/assignments/route.js`)
- API data hook → Student API: fetches data
