# rgh-code/schoolmanagement architecture

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

- Interactive diagram: https://gitdiagram.com/rgh-code/schoolmanagement
- Repository: https://github.com/rgh-code/schoolmanagement

## Overview

School EMIS is a multi-tenant school management platform. School administrators register or sign in, complete school setup if needed, then manage school records, classes, subjects, marks, attendance, and reports; a separate super-admin workflow manages schools. CDC-aware grading distinguishes CAS assessment for Classes 1–5 from numeric marks for Classes 6–12. The map includes documented backup/export and ledger capabilities. Edges reflect shown routing, calls, imports, or README statements; unsampled implementations are represented only where documented.

Main entry points: [`src/App.jsx`](https://github.com/rgh-code/schoolmanagement/blob/main/src/App.jsx) (Routes and access control), [`src/context/AuthContext.jsx`](https://github.com/rgh-code/schoolmanagement/blob/main/src/context/AuthContext.jsx) (Session and school setup), [`src/pages/school/ExamsLedgers.jsx`](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ExamsLedgers.jsx) (Marks and attendance), [`src/lib/supabaseClient.js`](https://github.com/rgh-code/schoolmanagement/blob/main/src/lib/supabaseClient.js) (Supabase client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app["Routes and access control<br/>[App.jsx]"]
end

subgraph group_identity["Identity and tenancy"]
  node_auth["Session and school setup<br/>[AuthContext.jsx]"]
  node_client["Supabase client<br/>[supabaseClient.js]"]
  node_backend["Supabase services"]
  node_schema[("Tenant data and RLS<br/>[schema.sql]")]
  node_school_login["School sign-in<br/>[SchoolLogin.jsx]"]
  node_school_register["School registration<br/>[SchoolRegister.jsx]"]
  node_complete_setup["Complete school setup"]
end

subgraph group_platform["Platform administration"]
  node_admin_login["Admin sign-in"]
  node_admin_dashboard["School administration"]
  node_create_school["Create-school function<br/>[index.ts]"]
end

subgraph group_school["School operations"]
  node_layout["School workspace shell<br/>[SchoolLayout.jsx]"]
  node_dashboard["Enrollment and profile dashboard<br/>[Dashboard.jsx]"]
  node_profile_helper["School profile updates"]
  node_directory["Student and staff directory<br/>[Directory.jsx]"]
  node_backup["Backup and restore<br/>[BackupSecurity.jsx]"]
end

subgraph group_assessment["Assessment and reporting"]
  node_exams["Marks and attendance<br/>[ExamsLedgers.jsx]"]
  node_class_level["Class-level assessment rules<br/>[classLevel.js]"]
  node_grading["CDC grades and CSV<br/>[grading.js]"]
  node_term_ledger["Term grade ledger"]
  node_combined_ledger["Combined ledger<br/>[CombinedLedger.jsx]"]
  node_grade_sheet["Student grade sheet"]
end

node_users(("School admins and super admin"))

node_users -->|"opens"| node_app
node_app -->|"routes to"| node_school_login
node_app -->|"routes to"| node_school_register
node_app -->|"routes to"| node_admin_login
node_app -->|"routes to"| node_complete_setup
node_app -->|"protects route"| node_admin_dashboard
node_app -->|"protects route"| node_layout
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_directory
node_app -->|"routes to"| node_exams
node_app -->|"routes to"| node_backup
node_app -->|"reads session"| node_auth
node_auth -->|"uses"| node_client
node_client -->|"connects to"| node_backend
node_auth -->|"loads profiles"| node_backend
node_school_login -->|"signs in"| node_auth
node_school_register -->|"registers school"| node_auth
node_complete_setup -->|"completes setup"| node_auth
node_admin_login -->|"signs in"| node_auth
node_admin_dashboard -->|"lists and deletes"| node_client
node_admin_dashboard -->|"invokes"| node_create_school
node_create_school -->|"creates school login"| node_backend
node_backend -->|"enforces tenant RLS"| node_schema
node_layout -->|"reads school context"| node_auth
node_dashboard -->|"queries school data"| node_client
node_dashboard -->|"updates profile"| node_profile_helper
node_directory -->|"manages registries"| node_client
node_directory -->|"uses class list"| node_class_level
node_backup -->|"backs up school data"| node_client
node_exams -->|"loads and saves records"| node_client
node_exams -->|"selects assessment type"| node_class_level
node_exams -->|"exports CSV"| node_grading
node_exams -->|"renders"| node_term_ledger
node_exams -->|"renders"| node_combined_ledger
node_exams -->|"renders"| node_grade_sheet
node_term_ledger -->|"calculates grades"| node_grading
node_combined_ledger -->|"uses class rules"| node_class_level
node_grade_sheet -->|"calculates GPA"| node_grading
node_grade_sheet -->|"loads marks"| node_client

click node_app "https://github.com/rgh-code/schoolmanagement/blob/main/src/App.jsx"
click node_auth "https://github.com/rgh-code/schoolmanagement/blob/main/src/context/AuthContext.jsx"
click node_client "https://github.com/rgh-code/schoolmanagement/blob/main/src/lib/supabaseClient.js"
click node_schema "https://github.com/rgh-code/schoolmanagement/blob/main/supabase/schema.sql"
click node_school_login "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SchoolLogin.jsx"
click node_school_register "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SchoolRegister.jsx"
click node_complete_setup "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/CompleteSchoolSetup.jsx"
click node_admin_login "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SuperAdminLogin.jsx"
click node_admin_dashboard "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SuperAdminDashboard.jsx"
click node_create_school "https://github.com/rgh-code/schoolmanagement/blob/main/supabase/functions/create-school/index.ts"
click node_layout "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/SchoolLayout.jsx"
click node_dashboard "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/Dashboard.jsx"
click node_profile_helper "https://github.com/rgh-code/schoolmanagement/blob/main/src/lib/schoolProfileUpdate.js"
click node_directory "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/Directory.jsx"
click node_backup "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/BackupSecurity.jsx"
click node_exams "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ExamsLedgers.jsx"
click node_class_level "https://github.com/rgh-code/schoolmanagement/blob/main/src/utils/classLevel.js"
click node_grading "https://github.com/rgh-code/schoolmanagement/blob/main/src/utils/grading.js"
click node_term_ledger "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ledgers/TermGradeLedger.jsx"
click node_combined_ledger "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ledgers/CombinedLedger.jsx"
click node_grade_sheet "https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ledgers/StudentGradeSheet.jsx"

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_app toneBlue
class node_auth,node_client,node_backend,node_schema,node_school_login,node_school_register,node_complete_setup toneAmber
class node_admin_login,node_admin_dashboard,node_create_school toneMint
class node_layout,node_dashboard,node_profile_helper,node_directory,node_backup toneRose
class node_exams,node_class_level,node_grading,node_term_ledger,node_combined_ledger,node_grade_sheet,node_users toneIndigo
```

## Components

### Application entry

- [Routes and access control](https://github.com/rgh-code/schoolmanagement/blob/main/src/App.jsx): `src/App.jsx`

### Identity and tenancy

- [Session and school setup](https://github.com/rgh-code/schoolmanagement/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Supabase client](https://github.com/rgh-code/schoolmanagement/blob/main/src/lib/supabaseClient.js): `src/lib/supabaseClient.js`
- **Supabase services**
- [Tenant data and RLS](https://github.com/rgh-code/schoolmanagement/blob/main/supabase/schema.sql): `supabase/schema.sql`
- [School sign-in](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SchoolLogin.jsx): `src/pages/SchoolLogin.jsx`
- [School registration](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SchoolRegister.jsx): `src/pages/SchoolRegister.jsx`
- [Complete school setup](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/CompleteSchoolSetup.jsx): `src/pages/CompleteSchoolSetup.jsx`

### Platform administration

- [Admin sign-in](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SuperAdminLogin.jsx): `src/pages/SuperAdminLogin.jsx`
- [School administration](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/SuperAdminDashboard.jsx): `src/pages/SuperAdminDashboard.jsx`
- [Create-school function](https://github.com/rgh-code/schoolmanagement/blob/main/supabase/functions/create-school/index.ts): `supabase/functions/create-school/index.ts`

### School operations

- [School workspace shell](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/SchoolLayout.jsx): `src/pages/school/SchoolLayout.jsx`
- [Enrollment and profile dashboard](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/Dashboard.jsx): `src/pages/school/Dashboard.jsx`
- [School profile updates](https://github.com/rgh-code/schoolmanagement/blob/main/src/lib/schoolProfileUpdate.js): `src/lib/schoolProfileUpdate.js`
- [Student and staff directory](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/Directory.jsx): `src/pages/school/Directory.jsx`
- [Backup and restore](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/BackupSecurity.jsx): `src/pages/school/BackupSecurity.jsx`

### Assessment and reporting

- [Marks and attendance](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ExamsLedgers.jsx): `src/pages/school/ExamsLedgers.jsx`
- [Class-level assessment rules](https://github.com/rgh-code/schoolmanagement/blob/main/src/utils/classLevel.js): `src/utils/classLevel.js`
- [CDC grades and CSV](https://github.com/rgh-code/schoolmanagement/blob/main/src/utils/grading.js): `src/utils/grading.js`
- [Term grade ledger](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ledgers/TermGradeLedger.jsx): `src/pages/school/ledgers/TermGradeLedger.jsx`
- [Combined ledger](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ledgers/CombinedLedger.jsx): `src/pages/school/ledgers/CombinedLedger.jsx`
- [Student grade sheet](https://github.com/rgh-code/schoolmanagement/blob/main/src/pages/school/ledgers/StudentGradeSheet.jsx): `src/pages/school/ledgers/StudentGradeSheet.jsx`

### Other components

- **School admins and super admin**

## Connections

- School admins and super admin → Routes and access control: opens (evidence: `README.md`)
- Routes and access control → School sign-in: routes to (evidence: `src/App.jsx`)
- Routes and access control → School registration: routes to (evidence: `src/App.jsx`)
- Routes and access control → Admin sign-in: routes to (evidence: `src/App.jsx`)
- Routes and access control → Complete school setup: routes to (evidence: `src/App.jsx`)
- Routes and access control → School administration: protects route (evidence: `src/App.jsx`)
- Routes and access control → School workspace shell: protects route (evidence: `src/App.jsx`)
- Routes and access control → Enrollment and profile dashboard: routes to (evidence: `src/App.jsx`)
- Routes and access control → Student and staff directory: routes to (evidence: `src/App.jsx`)
- Routes and access control → Marks and attendance: routes to (evidence: `src/App.jsx`)
- Routes and access control → Backup and restore: routes to (evidence: `src/App.jsx`)
- Routes and access control → Session and school setup: reads session (evidence: `src/App.jsx`)
- Session and school setup → Supabase client: uses (evidence: `src/context/AuthContext.jsx`)
- Supabase client → Supabase services: connects to (evidence: `src/lib/supabaseClient.js`)
- Session and school setup → Supabase services: loads profiles (evidence: `src/context/AuthContext.jsx`)
- School sign-in → Session and school setup: signs in (evidence: `src/pages/SchoolLogin.jsx`)
- School registration → Session and school setup: registers school (evidence: `src/pages/SchoolRegister.jsx`)
- Complete school setup → Session and school setup: completes setup (evidence: `src/pages/CompleteSchoolSetup.jsx`)
- Admin sign-in → Session and school setup: signs in (evidence: `src/pages/SuperAdminLogin.jsx`)
- School administration → Supabase client: lists and deletes (evidence: `src/pages/SuperAdminDashboard.jsx`)
- School administration → Create-school function: invokes (evidence: `src/pages/SuperAdminDashboard.jsx`)
- Create-school function → Supabase services: creates school login (evidence: `README.md`)
- Supabase services → Tenant data and RLS: enforces tenant RLS (evidence: `README.md`)
- School workspace shell → Session and school setup: reads school context (evidence: `src/pages/school/SchoolLayout.jsx`)
- Enrollment and profile dashboard → Supabase client: queries school data (evidence: `src/pages/school/Dashboard.jsx`)
- Enrollment and profile dashboard → School profile updates: updates profile (evidence: `src/pages/school/Dashboard.jsx`)
- Student and staff directory → Supabase client: manages registries (evidence: `src/pages/school/Directory.jsx`)
- Student and staff directory → Class-level assessment rules: uses class list (evidence: `src/pages/school/Directory.jsx`)
- Backup and restore → Supabase client: backs up school data (evidence: `src/pages/school/BackupSecurity.jsx`)
- Marks and attendance → Supabase client: loads and saves records (evidence: `src/pages/school/ExamsLedgers.jsx`)
- Marks and attendance → Class-level assessment rules: selects assessment type (evidence: `src/pages/school/ExamsLedgers.jsx`)
- Marks and attendance → CDC grades and CSV: exports CSV (evidence: `src/pages/school/ExamsLedgers.jsx`)
- Marks and attendance → Term grade ledger: renders (evidence: `src/pages/school/ExamsLedgers.jsx`)
- Marks and attendance → Combined ledger: renders (evidence: `src/pages/school/ExamsLedgers.jsx`)
- Marks and attendance → Student grade sheet: renders (evidence: `src/pages/school/ExamsLedgers.jsx`)
- Term grade ledger → CDC grades and CSV: calculates grades (evidence: `src/pages/school/ledgers/TermGradeLedger.jsx`)
- Combined ledger → Class-level assessment rules: uses class rules (evidence: `src/pages/school/ledgers/CombinedLedger.jsx`)
- Student grade sheet → CDC grades and CSV: calculates GPA (evidence: `src/pages/school/ledgers/StudentGradeSheet.jsx`)
- Student grade sheet → Supabase client: loads marks (evidence: `src/pages/school/ledgers/StudentGradeSheet.jsx`)
