# vivekrai-gif/multi-tenant-erp architecture

> Architecture diagram of the GitHub repository vivekrai-gif/multi-tenant-erp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vivekrai-gif/multi-tenant-erp
- Repository: https://github.com/vivekrai-gif/multi-tenant-erp

## Overview

1. This is a React single-page application bootstrapped with Create React App. The runtime is entirely client-side, with `public/index.html` as the host shell and `src/index.js` mounting the app.

2. The application is organized as a multi-role ERP/portal UI rather than a single-purpose app. The major product surfaces are:
   - public landing and login
   - global admin
   - school admin
   - teacher
   - parent
   - student

3. Navigation and page composition are centralized in `src/routes/AppRoutes.jsx`, `src/App.jsx`, and `src/layouts/MainLayout.jsx`. Each role then has its own layout and shell components, which strongly suggests route-level separation by persona.

4. The shared design system lives under `src/components/shared`, `src/components/ui`, and `src/components/erp/global`. These folders contain reusable UI primitives and app shell pieces such as sidebars, top bars, headers, cards, pagination, charts, and table components.

5. State that crosses multiple screens is handled with React context providers in `src/context`: `ThemeContext`, `ParentProvider`, `SchoolAdminProvider`, and `StudentProvider`. This indicates role-specific state hydration and theme handling at the top of the component tree.

6. The service layer is concentrated under `src/services`. `axiosClient.js`, `apiClient.js`, and `api.js` appear to be the shared HTTP foundation, while `parentAPIs.js`, `schoolAdminApi.js`, and `studentAPIs.js` split API access by role. `exportService.js` suggests a separate reporting/export flow. The UI pages likely fetch and mutate data through these wrappers rather than calling backend endpoints directly.

7. The global admin area is a platform-management subsystem. Its pages cover schools, domains, subscriptions, payment infrastructure, AI configuration, email configuration, security/access, notifications, settings, and school creation. This is the clearest boundary for tenant/platform administration.

8. The school admin area is the operational management subsystem for a school tenant. It includes students, teachers, parents, class levels, academic years, classes/sections, subjects, role/permission setup, teacher assignment, parent-student mapping, and entity detail/edit pages. This is the main data administration layer for the school domain.

9. The teacher area is the instructional workflow subsystem. It includes class hubs, attendance, assignments, exams, grading, student analytics, performance management, notifications, profile/settings, and a substantial AI content workspace. The AI tool pages cover lesson plans, quizzes, worksheets, rubrics, study notes, question papers, presentations, and history.

10. The student area is the learner-facing subsystem. It includes dashboards, subjects, assignments, attendance, grades, learning materials, quizzes, AI tutor, recommendations, fees/payments, help desk, notifications, profile, and settings. This area is oriented around consuming content and submitting/receiving academic results.

11. The parent area is a monitoring and guidance subsystem. Its pages focus on child overview, attendance, grades/assessment, assignments, recommendations/insights, notifications, and portal settings. This role appears read-heavy compared with teacher and school admin roles.

12. The landing experience under `src/components/landing` and `src/pages/Landing.jsx` is a separate marketing/public entry path. It contains hero, roles, flow, intelligence, CTA, navbar, and footer sections, implying a public funnel that leads into login and the role-based app.

13. Styling and presentation are layered through `src/index.css`, `src/styles/aiTheme.css`, `tailwind.config.js`, and `postcss.config.js`. The presence of Tailwind/PostCSS config plus AI-specific theming suggests the UI is built from utility styling with some custom theme treatment for AI workspace screens.

14. `src/hooks/useStaleData.js` and `src/utils/calculations.js` provide cross-cutting client logic for data freshness and derived metrics. These are supporting utilities rather than primary domains, but they likely feed dashboards, charts, and summary cards.

15. `fix-darkmode.js` and `fix_student_section.js` look like one-off maintenance scripts rather than runtime application code. They should be treated as repo utilities, not as part of the main request/response architecture.

16. For an architecture diagram, the key boundaries are: public landing/auth, shared client shell, role-specific portals, centralized HTTP/service layer, and context-driven state. The main data flow is user action in a role-specific page → service/API wrapper → backend response → contextual state and dashboard/UI rendering.

Main entry points: [`src/routes/AppRoutes.jsx`](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/routes/AppRoutes.jsx) (Routes), [`src/services/apiClient.js`](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/services/apiClient.js) (HTTP core), [`src/layouts/MainLayout.jsx`](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/layouts/MainLayout.jsx) (Main layout), [`src/pages/schoolAdmin/Dashboard.jsx`](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/schoolAdmin/Dashboard.jsx) (School admin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public entry"]
  node_public_shell["Landing<br/>public entry<br/>[Landing.jsx]"]
  node_login_page["Login<br/>auth page<br/>[Login.jsx]"]
end

subgraph group_core["Client core"]
  node_index_html["Host shell<br/>spa host<br/>[index.html]"]
  node_index_js["App mount<br/>bootstrap<br/>[index.js]"]
  node_app_routes["Routes<br/>router<br/>[AppRoutes.jsx]"]
  node_main_layout["Main layout<br/>app shell<br/>[MainLayout.jsx]"]
  node_theme_ctx(("Theme context<br/>[ThemeContext.jsx]"))
  node_shared_ui["Shared UI<br/>design system"]
  node_erp_global_ui["ERP shell<br/>shell components"]
  node_service_core[("HTTP core<br/>api foundation<br/>[apiClient.js]")]
end

subgraph group_global["Global admin"]
  node_global_admin["Global admin<br/>platform admin"]
  node_global_admin_routes["Admin pages<br/>admin screens"]
end

subgraph group_school["School admin"]
  node_school_admin["School admin<br/>tenant admin<br/>[Dashboard.jsx]"]
  node_school_admin_pages["School screens<br/>tenant screens"]
  node_school_context(("School context"))
end

subgraph group_teacher["Teacher portal"]
  node_teacher_portal["Teacher portal<br/>instructional portal<br/>[Dashboard.jsx]"]
  node_teacher_tools["Teacher tools<br/>workflow screens"]
end

subgraph group_student["Student portal"]
  node_student_portal["Student portal<br/>learner portal<br/>[Dashboard.jsx]"]
  node_student_study["Student screens<br/>study screens"]
  node_student_context(("Student context"))
end

subgraph group_parent["Parent portal"]
  node_parent_portal["Parent portal<br/>guardian portal"]
  node_parent_views["Parent screens<br/>monitoring screens"]
  node_parent_context(("Parent context<br/>[ParentProvider.jsx]"))
end

node_index_html -->|"mounts"| node_index_js
node_index_js -->|"renders"| node_app_routes
node_app_routes -->|"routes to"| node_public_shell
node_app_routes -->|"routes to"| node_login_page
node_app_routes -->|"routes to"| node_global_admin
node_app_routes -->|"routes to"| node_school_admin
node_app_routes -->|"routes to"| node_teacher_portal
node_app_routes -->|"routes to"| node_student_portal
node_app_routes -->|"routes to"| node_parent_portal
node_main_layout -->|"wraps"| node_app_routes
node_theme_ctx -->|"provides"| node_main_layout
node_shared_ui -->|"supports"| node_main_layout
node_erp_global_ui -->|"supports"| node_teacher_portal
node_service_core -->|"serves"| node_global_admin_routes
node_service_core -->|"serves"| node_school_admin_pages
node_service_core -->|"serves"| node_teacher_tools
node_service_core -->|"serves"| node_student_study
node_service_core -->|"serves"| node_parent_views
node_school_context -->|"feeds"| node_school_admin
node_student_context -->|"feeds"| node_student_portal
node_parent_context -->|"feeds"| node_parent_portal
node_global_admin -->|"contains"| node_global_admin_routes
node_school_admin -->|"contains"| node_school_admin_pages
node_teacher_portal -->|"contains"| node_teacher_tools
node_student_portal -->|"contains"| node_student_study
node_parent_portal -->|"contains"| node_parent_views

click node_public_shell "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/Landing.jsx"
click node_login_page "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/Login.jsx"
click node_index_html "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/public/index.html"
click node_index_js "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/index.js"
click node_app_routes "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/routes/AppRoutes.jsx"
click node_main_layout "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/layouts/MainLayout.jsx"
click node_theme_ctx "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/ThemeContext.jsx"
click node_shared_ui "https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/components/shared"
click node_erp_global_ui "https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/components/erp/global"
click node_service_core "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/services/apiClient.js"
click node_global_admin "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/globalAdmin/GlobalDashboard.jsx"
click node_school_admin "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/schoolAdmin/Dashboard.jsx"
click node_teacher_portal "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/teacher/Dashboard.jsx"
click node_student_portal "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/student/Dashboard.jsx"
click node_parent_portal "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/parent/ParentDashboard.jsx"
click node_global_admin_routes "https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/globalAdmin"
click node_school_admin_pages "https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/schoolAdmin"
click node_teacher_tools "https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/teacher"
click node_student_study "https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/student"
click node_parent_views "https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/parent"
click node_school_context "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/SchoolAdminProvider.jsx"
click node_student_context "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/StudentProvider.jsx"
click node_parent_context "https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/ParentProvider.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_public_shell,node_login_page,node_parent_portal,node_parent_views,node_parent_context toneBlue
class node_index_html,node_index_js,node_app_routes,node_main_layout,node_theme_ctx,node_shared_ui,node_erp_global_ui,node_service_core toneAmber
class node_global_admin,node_global_admin_routes toneMint
class node_school_admin,node_school_admin_pages,node_school_context toneRose
class node_teacher_portal,node_teacher_tools toneIndigo
class node_student_portal,node_student_study,node_student_context toneTeal
```

## Components

### Public entry

Marketing site and login entry path

- [Landing](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/Landing.jsx): public entry · Marketing pages and login gateway · `src/pages/Landing.jsx`
- [Login](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/Login.jsx): auth page · Authentication entry into the role-based app · `src/pages/Login.jsx`

### Client core

App bootstrap, routing, layouts, shared state, and design system

- [Host shell](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/public/index.html): spa host · Static HTML mount point for the React app · `public/index.html`
- [App mount](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/index.js): bootstrap · Client-side runtime entry that mounts React · `src/index.js`
- [Routes](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/routes/AppRoutes.jsx): router · Central route map across personas and entry points · `src/routes/AppRoutes.jsx`
- [Main layout](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/layouts/MainLayout.jsx): app shell · Top-level layout composition for the SPA · `src/layouts/MainLayout.jsx`
- [Theme context](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/ThemeContext.jsx): context · Global theme and appearance state · `src/context/ThemeContext.jsx`
- [Shared UI](https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/components/shared): design system · Reusable cards, nav, sidebar, and topbar primitives · `src/components/shared`
- [ERP shell](https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/components/erp/global): shell components · Common ERP dashboard chrome and widgets · `src/components/erp/global`
- [HTTP core](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/services/apiClient.js): api foundation · Shared axios/client wrappers used by all portals · `src/services/apiClient.js`

### Global admin

Platform-level tenant administration

- [Global admin](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/globalAdmin/GlobalDashboard.jsx): platform admin · Tenant, billing, security, and platform settings · `src/pages/globalAdmin/GlobalDashboard.jsx`
- [Admin pages](https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/globalAdmin): admin screens · Schools, domains, subscriptions, payment, AI, email, security, notifications · `src/pages/globalAdmin`

### School admin

School tenant operational administration

- [School admin](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/schoolAdmin/Dashboard.jsx): tenant admin · School operations, roster, mapping, and roles · `src/pages/schoolAdmin/Dashboard.jsx`
- [School screens](https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/schoolAdmin): tenant screens · Students, teachers, parents, classes, sections, years, mappings, and permissions · `src/pages/schoolAdmin`
- [School context](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/SchoolAdminProvider.jsx): context · School-admin state hydration across screens · `src/context/SchoolAdminProvider.jsx`

### Teacher portal

Instructional workflow and AI content tools

- [Teacher portal](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/teacher/Dashboard.jsx): instructional portal · Classroom workflow, grading, analytics, and AI tools · `src/pages/teacher/Dashboard.jsx`
- [Teacher tools](https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/teacher): workflow screens · Attendance, assignments, exams, grades, analytics, class hubs, and AI workspaces · `src/pages/teacher`

### Student portal

Learner-facing dashboard and study flows

- [Student portal](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/student/Dashboard.jsx): learner portal · Student dashboard, study materials, assessments, and support · `src/pages/student/Dashboard.jsx`
- [Student screens](https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/student): study screens · Subjects, materials, quizzes, AI tutor, fees, help desk, and settings · `src/pages/student`
- [Student context](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/StudentProvider.jsx): context · Student state hydration across screens · `src/context/StudentProvider.jsx`

### Parent portal

Monitoring and guidance flows for guardians

- [Parent portal](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/pages/parent/ParentDashboard.jsx): guardian portal · Child progress, attendance, grades, and insights · `src/pages/parent/ParentDashboard.jsx`
- [Parent screens](https://github.com/vivekrai-gif/multi-tenant-erp/tree/main/src/pages/parent): monitoring screens · Child overview, attendance, grades, assignments, recommendations, and settings · `src/pages/parent`
- [Parent context](https://github.com/vivekrai-gif/multi-tenant-erp/blob/main/src/context/ParentProvider.jsx): context · Parent state hydration across screens · `src/context/ParentProvider.jsx`

## Connections

- Host shell → App mount: mounts · HTML host shell loads the React bundle
- App mount → Routes: renders · Bootstrap hands off to the router
- Routes → Landing: routes to · Public landing path
- Routes → Login: routes to · Authentication path
- Routes → Global admin: routes to · Global admin persona
- Routes → School admin: routes to · School admin persona
- Routes → Teacher portal: routes to · Teacher persona
- Routes → Student portal: routes to · Student persona
- Routes → Parent portal: routes to · Parent persona
- Main layout → Routes: wraps · Shared shell composes routed pages
- Theme context → Main layout: provides · Theme state is injected at the app boundary
- Shared UI → Main layout: supports · Reusable navigation and UI primitives
- ERP shell → Teacher portal: supports · Dashboard and workflow widgets used across ERP screens
- HTTP core → Admin pages: serves · Shared API foundation behind global admin calls
- HTTP core → School screens: serves · Shared API foundation behind school admin calls
- HTTP core → Teacher tools: serves · Shared API foundation behind teacher workflow calls
- HTTP core → Student screens: serves · Shared API foundation behind student calls
- HTTP core → Parent screens: serves · Shared API foundation behind parent calls
- School context → School admin: feeds · Role-specific state provider for school admin screens
- Student context → Student portal: feeds · Role-specific state provider for student screens
- Parent context → Parent portal: feeds · Role-specific state provider for parent screens
- Global admin → Admin pages: contains · Platform management screens
- School admin → School screens: contains · Tenant administration screens
- Teacher portal → Teacher tools: contains · Instructional workflow screens
- Student portal → Student screens: contains · Learner-facing screens
- Parent portal → Parent screens: contains · Guardian-facing screens
