# testsamp0606/campushub architecture

> Architecture diagram of the GitHub repository testsamp0606/campushub, 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/testsamp0606/campushub
- Repository: https://github.com/testsamp0606/campushub

## Overview

This is a Next.js school-management application backed by Firebase, with routes for student and staff records, academics, finance, operations, and communication. The principal user workflow is to open a school-management screen, view or change domain records, and use Firebase-backed data; the sampled calendar route demonstrates reads of classes, subjects, teachers, and timetables. Dashboard attendance-anomaly detection is a distinct AI capability. The README only identifies a Firebase Studio starter, so several capabilities and their connections are inferred from the route tree; those links are marked unverified where source evidence was not supplied.

Main entry points: [`src/app`](https://github.com/testsamp0606/campushub/tree/main/src/app) (App routes), [`src/firebase/index.ts`](https://github.com/testsamp0606/campushub/blob/main/src/firebase/index.ts) (Firebase client setup), [`src/firebase/client-provider.tsx`](https://github.com/testsamp0606/campushub/blob/main/src/firebase/client-provider.tsx) (Authentication and profile gate), [`src/app/calendar/page.tsx`](https://github.com/testsamp0606/campushub/blob/main/src/app/calendar/page.tsx) (Calendar and timetable)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_routes["App routes"]
  node_shell["Navigation shell"]
  node_ui["UI components"]
end

subgraph group_academics["Academic operations"]
  node_attendance["Attendance<br/>[page.tsx]"]
  node_timetable["Calendar and timetable<br/>[page.tsx]"]
  node_assessment["Assessments and exams"]
  node_results["Results and reports"]
  node_lms["Learning management"]
end

subgraph group_administration["School administration"]
  node_student_records["Student records"]
  node_people_records["People and classes"]
  node_school_operations["School operations"]
  node_finance["Fees and payments"]
  node_accounts["Accounts and expenses<br/>[page.tsx]"]
  node_communications["Messages and announcements"]
end

subgraph group_platform["Firebase platform"]
  node_firebase_client["Firebase client setup<br/>[index.ts]"]
  node_auth_gate["Authentication and profile gate"]
  node_firebase_provider["Firebase context<br/>[provider.tsx]"]
  node_firestore_hooks["Firestore data hooks<br/>[use-collection.tsx]"]
  node_async_updates["Nonblocking updates"]
  node_error_handling["Firebase error handling<br/>[error-emitter.ts]"]
  node_firebase_store[("Firestore")]
end

subgraph group_insights["Insights and learning"]
  node_dashboard["Dashboard<br/>[main-dashboard.tsx]"]
  node_anomaly_ui["Anomaly detector"]
  node_anomaly_flow["Attendance anomaly analysis"]
  node_genkit["Genkit runtime<br/>[genkit.ts]"]
end

node_user(("School user"))

node_user -.->|"opens screens"| node_routes
node_routes -.->|"uses shell"| node_shell
node_routes -.->|"renders controls"| node_ui
node_routes -.->|"routes to"| node_student_records
node_routes -.->|"routes to"| node_people_records
node_routes -.->|"routes to"| node_school_operations
node_routes -.->|"routes to"| node_attendance
node_routes -.->|"routes to"| node_timetable
node_routes -.->|"routes to"| node_assessment
node_routes -.->|"routes to"| node_results
node_routes -.->|"routes to"| node_lms
node_routes -.->|"routes to"| node_finance
node_routes -.->|"routes to"| node_accounts
node_routes -.->|"routes to"| node_communications
node_routes -.->|"routes to"| node_dashboard
node_auth_gate -->|"initializes services"| node_firebase_client
node_auth_gate -->|"provides context"| node_firebase_provider
node_auth_gate -->|"creates profile"| node_async_updates
node_auth_gate -->|"reads and watches profile"| node_firebase_store
node_timetable -->|"loads data hooks"| node_firebase_client
node_firestore_hooks -->|"emits errors"| node_error_handling
node_async_updates -->|"reports errors"| node_error_handling
node_anomaly_ui -->|"requests analysis"| node_anomaly_flow
node_anomaly_flow -->|"uses runtime"| node_genkit
node_anomaly_ui -->|"uses Firebase"| node_firebase_client
node_assessment -->|"uses Firebase"| node_firebase_client
node_results -->|"uses Firebase"| node_firebase_client
node_accounts -->|"uses Firebase"| node_firebase_client
node_attendance -->|"uses Firebase"| node_firebase_client
node_timetable -.->|"reads collections"| node_firestore_hooks

click node_routes "https://github.com/testsamp0606/campushub/tree/main/src/app"
click node_shell "https://github.com/testsamp0606/campushub/tree/main/src/components/layout"
click node_ui "https://github.com/testsamp0606/campushub/tree/main/src/components/ui"
click node_student_records "https://github.com/testsamp0606/campushub/tree/main/src/app/students"
click node_people_records "https://github.com/testsamp0606/campushub/tree/main/src/app/teachers"
click node_school_operations "https://github.com/testsamp0606/campushub/tree/main/src/app/transport"
click node_attendance "https://github.com/testsamp0606/campushub/blob/main/src/app/attendance/page.tsx"
click node_timetable "https://github.com/testsamp0606/campushub/blob/main/src/app/calendar/page.tsx"
click node_assessment "https://github.com/testsamp0606/campushub/tree/main/src/app/examinations"
click node_results "https://github.com/testsamp0606/campushub/tree/main/src/app/results"
click node_lms "https://github.com/testsamp0606/campushub/tree/main/src/app/lms"
click node_finance "https://github.com/testsamp0606/campushub/tree/main/src/app/fees"
click node_accounts "https://github.com/testsamp0606/campushub/blob/main/src/app/expenses/page.tsx"
click node_communications "https://github.com/testsamp0606/campushub/tree/main/src/app/messages"
click node_dashboard "https://github.com/testsamp0606/campushub/blob/main/src/app/dashboard/main-dashboard.tsx"
click node_anomaly_ui "https://github.com/testsamp0606/campushub/blob/main/src/components/dashboard/anomaly-detector.tsx"
click node_anomaly_flow "https://github.com/testsamp0606/campushub/blob/main/src/ai/flows/detect-attendance-anomalies.ts"
click node_firebase_client "https://github.com/testsamp0606/campushub/blob/main/src/firebase/index.ts"
click node_auth_gate "https://github.com/testsamp0606/campushub/blob/main/src/firebase/client-provider.tsx"
click node_firebase_provider "https://github.com/testsamp0606/campushub/blob/main/src/firebase/provider.tsx"
click node_firestore_hooks "https://github.com/testsamp0606/campushub/blob/main/src/firebase/firestore/use-collection.tsx"
click node_async_updates "https://github.com/testsamp0606/campushub/blob/main/src/firebase/non-blocking-updates.tsx"
click node_error_handling "https://github.com/testsamp0606/campushub/blob/main/src/firebase/error-emitter.ts"
click node_genkit "https://github.com/testsamp0606/campushub/blob/main/src/ai/genkit.ts"

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_routes,node_shell,node_ui,node_user toneBlue
class node_attendance,node_timetable,node_assessment,node_results,node_lms toneAmber
class node_student_records,node_people_records,node_school_operations,node_finance,node_accounts,node_communications toneMint
class node_firebase_client,node_auth_gate,node_firebase_provider,node_firestore_hooks,node_async_updates,node_error_handling,node_firebase_store toneRose
class node_dashboard,node_anomaly_ui,node_anomaly_flow,node_genkit toneIndigo
```

## Components

### App experience

- [App routes](https://github.com/testsamp0606/campushub/tree/main/src/app): `src/app`
- [Navigation shell](https://github.com/testsamp0606/campushub/tree/main/src/components/layout): `src/components/layout`
- [UI components](https://github.com/testsamp0606/campushub/tree/main/src/components/ui): `src/components/ui`

### Academic operations

- [Attendance](https://github.com/testsamp0606/campushub/blob/main/src/app/attendance/page.tsx): `src/app/attendance/page.tsx`
- [Calendar and timetable](https://github.com/testsamp0606/campushub/blob/main/src/app/calendar/page.tsx): `src/app/calendar/page.tsx`
- [Assessments and exams](https://github.com/testsamp0606/campushub/tree/main/src/app/examinations): `src/app/examinations`
- [Results and reports](https://github.com/testsamp0606/campushub/tree/main/src/app/results): `src/app/results`
- [Learning management](https://github.com/testsamp0606/campushub/tree/main/src/app/lms): `src/app/lms`

### School administration

- [Student records](https://github.com/testsamp0606/campushub/tree/main/src/app/students): `src/app/students`
- [People and classes](https://github.com/testsamp0606/campushub/tree/main/src/app/teachers): `src/app/teachers`
- [School operations](https://github.com/testsamp0606/campushub/tree/main/src/app/transport): `src/app/transport`
- [Fees and payments](https://github.com/testsamp0606/campushub/tree/main/src/app/fees): `src/app/fees`
- [Accounts and expenses](https://github.com/testsamp0606/campushub/blob/main/src/app/expenses/page.tsx): `src/app/expenses/page.tsx`
- [Messages and announcements](https://github.com/testsamp0606/campushub/tree/main/src/app/messages): `src/app/messages`

### Firebase platform

- [Firebase client setup](https://github.com/testsamp0606/campushub/blob/main/src/firebase/index.ts): `src/firebase/index.ts`
- [Authentication and profile gate](https://github.com/testsamp0606/campushub/blob/main/src/firebase/client-provider.tsx): `src/firebase/client-provider.tsx`
- [Firebase context](https://github.com/testsamp0606/campushub/blob/main/src/firebase/provider.tsx): `src/firebase/provider.tsx`
- [Firestore data hooks](https://github.com/testsamp0606/campushub/blob/main/src/firebase/firestore/use-collection.tsx): `src/firebase/firestore/use-collection.tsx`
- [Nonblocking updates](https://github.com/testsamp0606/campushub/blob/main/src/firebase/non-blocking-updates.tsx): `src/firebase/non-blocking-updates.tsx`
- [Firebase error handling](https://github.com/testsamp0606/campushub/blob/main/src/firebase/error-emitter.ts): `src/firebase/error-emitter.ts`
- **Firestore**

### Insights and learning

- [Dashboard](https://github.com/testsamp0606/campushub/blob/main/src/app/dashboard/main-dashboard.tsx): `src/app/dashboard/main-dashboard.tsx`
- [Anomaly detector](https://github.com/testsamp0606/campushub/blob/main/src/components/dashboard/anomaly-detector.tsx): `src/components/dashboard/anomaly-detector.tsx`
- [Attendance anomaly analysis](https://github.com/testsamp0606/campushub/blob/main/src/ai/flows/detect-attendance-anomalies.ts): `src/ai/flows/detect-attendance-anomalies.ts`
- [Genkit runtime](https://github.com/testsamp0606/campushub/blob/main/src/ai/genkit.ts): `src/ai/genkit.ts`

### Other components

- **School user**

## Connections

- School user → App routes: opens screens
- App routes → Navigation shell: uses shell
- App routes → UI components: renders controls (evidence: `src/app/calendar/page.tsx`)
- App routes → Student records: routes to
- App routes → People and classes: routes to
- App routes → School operations: routes to
- App routes → Attendance: routes to
- App routes → Calendar and timetable: routes to
- App routes → Assessments and exams: routes to (evidence: `src/app/examinations/page.tsx`)
- App routes → Results and reports: routes to (evidence: `src/app/results/page.tsx`)
- App routes → Learning management: routes to
- App routes → Fees and payments: routes to
- App routes → Accounts and expenses: routes to
- App routes → Messages and announcements: routes to
- App routes → Dashboard: routes to
- Authentication and profile gate → Firebase client setup: initializes services (evidence: `src/firebase/client-provider.tsx`)
- Authentication and profile gate → Firebase context: provides context (evidence: `src/firebase/client-provider.tsx`)
- Authentication and profile gate → Nonblocking updates: creates profile (evidence: `src/firebase/client-provider.tsx`)
- Authentication and profile gate → Firestore: reads and watches profile (evidence: `src/firebase/client-provider.tsx`)
- Calendar and timetable → Firebase client setup: loads data hooks (evidence: `src/app/calendar/page.tsx`)
- Firestore data hooks → Firebase error handling: emits errors (evidence: `src/firebase/firestore/use-collection.tsx`)
- Nonblocking updates → Firebase error handling: reports errors (evidence: `src/firebase/non-blocking-updates.tsx`)
- Anomaly detector → Attendance anomaly analysis: requests analysis (evidence: `src/components/dashboard/anomaly-detector.tsx`)
- Attendance anomaly analysis → Genkit runtime: uses runtime (evidence: `src/ai/flows/detect-attendance-anomalies.ts`)
- Anomaly detector → Firebase client setup: uses Firebase (evidence: `src/components/dashboard/anomaly-detector.tsx`)
- Assessments and exams → Firebase client setup: uses Firebase (evidence: `src/app/examinations/page.tsx`)
- Results and reports → Firebase client setup: uses Firebase (evidence: `src/app/results/page.tsx`)
- Accounts and expenses → Firebase client setup: uses Firebase (evidence: `src/app/expenses/page.tsx`)
- Attendance → Firebase client setup: uses Firebase (evidence: `src/app/attendance/page.tsx`)
- Calendar and timetable → Firestore data hooks: reads collections
