# bakedpotato52/class_scheduler architecture

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

- Interactive diagram: https://gitdiagram.com/bakedpotato52/class_scheduler
- Repository: https://github.com/bakedpotato52/class_scheduler

## Overview

##### Project Type and Purpose
- Class Scheduler is a full-stack web application built with Next.js (“app” directory, page.tsx files, API routes under app/api).
- Purpose: Enable educational institutions to manage class schedules, room assignments, teacher allocations, conflict detection, calendar exports, and reporting.

##### File Structure Analysis
- Top-level “app” directory follows Next.js 13’s App Router model.
- app/layout.tsx & app/page.tsx – root layout and home page.
- app/(dashboard) – nested layouts for Dashboard; further subdivided into admin, teacher, and student sections, each with its own layout.tsx and page.tsx.
- app/api/delete/route.ts – serverless endpoint for schedule deletion.
- app/auth – login/register pages, each with layout and page.
- “components” directory contains reusable UI components and providers (auth-provider, notification-provider, theme-provider).
- “hooks” for React hooks (use-auth, use-toast, use-mobile).
- “lib” for utility modules and service connectors (Firebase, Cloudinary, notifications, utils).
- Config and deployment files: next.config.mjs, tailwind.config.ts, postcss.config.mjs, tsconfig.json.
- Public assets: PWA manifest.json, Firebase messaging service worker, static files.

##### README & Tech Stack Insights
- Next.js + React for frontend & serverless functions.
- Firebase (Auth, Firestore/Realtime DB, Messaging) for authentication, data storage, and push notifications.
- Cloudinary for image uploads (via lib/cloudinary.ts).
- Tailwind CSS for styling and UI.
- PWA support via public/manifest.json and firebase-messaging-sw.js.

##### Main Components and Their Interactions
a. Frontend/UI Layer
- Next.js pages/components render the dashboard, auth pages, and shared UI (buttons, tables, modals).
- Providers (AuthProvider, NotificationProvider, ThemeProvider) wrap the app for global state and context.
b. Server/API Layer
- Next.js Serverless Functions (app/api routes) expose endpoints (e.g., DELETE /api/delete).
- Business logic libraries (lib/utils, lib/notifications) invoked by both client and server routes.
c. Data & External Services
- Firebase
– Authentication (signup, login)
– Database (schedules, rooms, users, notifications)
– Messaging (push notifications via service worker)
- Cloudinary
– Asset uploads for profile pictures etc.
- Calendar Integration
– Export logic likely handled in lib/utils or server functions.

##### Architectural Patterns & Principles
- Layered architecture: UI → API → Business logic → Data/External services.
- Separation of concerns:
- Next.js App Router organizes pages/layouts per user role (admin, teacher, student).
- “components”, “hooks”, and “lib” isolate UI, reusable logic, and service connectors.
- Context Providers for cross-cutting concerns (auth, notifications, theme).
- Utility-first styling with Tailwind.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client UI Layer
    subgraph "Client UI Layer"
        direction TB
        NextRoot["Next.js Root Layout & Home"]:::client
        subgraph "Dashboard - Admin"
            direction TB
            AdminLayout["Admin Layout"]:::client
            AdminOverview["Admin Overview"]:::client
            AdminAnalytics["Analytics"]:::client
            AdminClasses["Classes"]:::client
            AdminNotifications["Notifications"]:::client
            AdminProfile["Profile"]:::client
            AdminSchedule["Schedule"]:::client
            AdminSettings["Settings"]:::client
            AdminStudents["Students"]:::client
            AdminTeachers["Teachers"]:::client
        end
        subgraph "Dashboard - Teacher"
            direction TB
            TeacherLayout["Teacher Layout"]:::client
            TeacherOverview["Teacher Overview"]:::client
            TeacherClasses["Classes"]:::client
            TeacherNotifications["Notifications"]:::client
            TeacherProfile["Profile"]:::client
            TeacherSchedule["Schedule"]:::client
            TeacherSettings["Settings"]:::client
            TeacherStudents["Students"]:::client
        end
        subgraph "Dashboard - Student"
            direction TB
            StudentLayout["Student Layout"]:::client
            StudentOverview["Student Overview"]:::client
            StudentClasses["Classes"]:::client
            StudentNotifications["Notifications"]:::client
            StudentProfile["Profile"]:::client
            StudentSchedule["Schedule"]:::client
            StudentSettings["Settings"]:::client
        end
        subgraph "Auth Pages"
            direction TB
            LoginLayout["Login Layout"]:::client
            LoginPage["Login Page"]:::client
            RegisterLayout["Register Layout"]:::client
            RegisterPage["Register Page"]:::client
        end
        subgraph "Providers & Hooks"
            direction TB
            AuthProvider["AuthProvider"]:::utils
            NotificationProvider["NotificationProvider"]:::utils
            ThemeProvider["ThemeProvider"]:::utils
            UseAuth["useAuth Hook"]:::utils
            UseToast["useToast Hook"]:::utils
            UseMobile["useMobile Hook"]:::utils
        end
        subgraph "UI Components"
            direction TB
            UIWidgets["UI Widgets (buttons, tables, modals)"]:::client
        end
    end

    %% Business Logic Tier
    subgraph "Business Logic & Utils"
        direction TB
        FirebaseClient["lib/firebase.ts"]:::utils
        FirebaseAdmin["lib/firebase-admin.ts"]:::utils
        CloudinaryLib["lib/cloudinary.ts"]:::utils
        NotificationsLib["lib/notifications.ts"]:::utils
        UtilsLib["lib/utils.ts"]:::utils
        MenuConfig["lib/menu-items.ts"]:::utils
    end

    %% Server/API Layer
    subgraph "Server/API Layer"
        direction TB
        DeleteAPI["DELETE /api/delete"]:::api
    end

    %% External Services Tier
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::services
        FirebaseDB["Firebase Database"]:::services
        FirebaseMsg["Firebase Messaging"]:::services
        CloudinaryServ["Cloudinary"]:::services
    end

    %% Connections
    UserBrowser("User Browser"):::external
    UserBrowser -->|"HTTP/SSR"| NextRoot
    NextRoot -->|"Client Routing"| AdminLayout
    NextRoot -->|"Client Routing"| TeacherLayout
    NextRoot -->|"Client Routing"| StudentLayout
    NextRoot -->|"Client Routing"| LoginLayout
    NextRoot -->|"Client Routing"| RegisterLayout

    NextRoot -->|"Context Wrap"| AuthProvider
    AuthProvider --> NotificationProvider
    NotificationProvider --> ThemeProvider

    UIWidgets --> NextRoot

    NextRoot -->|"calls API"| DeleteAPI
    AdminOverview --> DeleteAPI
    TeacherOverview --> DeleteAPI
    StudentOverview --> DeleteAPI

    NextRoot -->|"Firebase SDK"| FirebaseClient
    NextRoot -->|"Cloudinary API"| CloudinaryLib
    DeleteAPI -->|"Admin SDK"| FirebaseAdmin
    UtilsLib --> FirebaseAdmin
    UtilsLib --> FirebaseClient

    FirebaseClient -->|"SDK calls"| FirebaseAuth
    FirebaseClient --> FirebaseDB
    FirebaseClient --> FirebaseMsg
    FirebaseAdmin --> FirebaseDB

    CloudinaryLib -->|"API calls"| CloudinaryServ

    FirebaseMsg -->|"push"| UseMobile

    %% Click Events
    click NextRoot "https://github.com/bakedpotato52/class_scheduler/blob/main/app/layout.tsx"
    click NextRoot "https://github.com/bakedpotato52/class_scheduler/blob/main/app/page.tsx"
    click AdminLayout "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/layout.tsx"
    click AdminOverview "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/page.tsx"
    click AdminAnalytics "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/analytics/page.tsx"
    click AdminClasses "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/classes/page.tsx"
    click AdminNotifications "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/notifications/page.tsx"
    click AdminProfile "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/profile/page.tsx"
    click AdminSchedule "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/schedule/page.tsx"
    click AdminSettings "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/settings/page.tsx"
    click AdminStudents "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/students/page.tsx"
    click AdminTeachers "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/admin/teachers/page.tsx"

    click TeacherLayout "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/layout.tsx"
    click TeacherOverview "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/page.tsx"
    click TeacherClasses "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/classes/page.tsx"
    click TeacherNotifications "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/notifications/page.tsx"
    click TeacherProfile "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/profile/page.tsx"
    click TeacherSchedule "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/schedule/page.tsx"
    click TeacherSettings "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/settings/page.tsx"
    click TeacherStudents "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/teacher/students/page.tsx"

    click StudentLayout "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/student/layout.tsx"
    click StudentOverview "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/student/page.tsx"
    click StudentClasses "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/student/classes/page.tsx"
    click StudentNotifications "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/student/notifications/page.tsx"
    click StudentProfile "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/student/profile/page.tsx"
    click StudentSchedule "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/student/schedule/page.tsx"
    click StudentSettings "https://github.com/bakedpotato52/class_scheduler/blob/main/app/(dashboard)/student/settings/page.tsx"

    click LoginLayout "https://github.com/bakedpotato52/class_scheduler/blob/main/app/auth/login/layout.tsx"
    click LoginPage "https://github.com/bakedpotato52/class_scheduler/blob/main/app/auth/login/page.tsx"
    click RegisterLayout "https://github.com/bakedpotato52/class_scheduler/blob/main/app/auth/register/layout.tsx"
    click RegisterPage "https://github.com/bakedpotato52/class_scheduler/blob/main/app/auth/register/page.tsx"

    click DeleteAPI "https://github.com/bakedpotato52/class_scheduler/blob/main/app/api/delete/route.ts"

    click AuthProvider "https://github.com/bakedpotato52/class_scheduler/blob/main/components/auth-provider.tsx"
    click NotificationProvider "https://github.com/bakedpotato52/class_scheduler/blob/main/components/notification-provider.tsx"
    click ThemeProvider "https://github.com/bakedpotato52/class_scheduler/blob/main/components/theme-provider.tsx"

    click UseAuth "https://github.com/bakedpotato52/class_scheduler/blob/main/hooks/use-auth.ts"
    click UseToast "https://github.com/bakedpotato52/class_scheduler/blob/main/hooks/use-toast.ts"
    click UseMobile "https://github.com/bakedpotato52/class_scheduler/blob/main/hooks/use-mobile.tsx"

    click FirebaseClient "https://github.com/bakedpotato52/class_scheduler/blob/main/lib/firebase.ts"
    click FirebaseAdmin "https://github.com/bakedpotato52/class_scheduler/blob/main/lib/firebase-admin.ts"
    click CloudinaryLib "https://github.com/bakedpotato52/class_scheduler/blob/main/lib/cloudinary.ts"
    click NotificationsLib "https://github.com/bakedpotato52/class_scheduler/blob/main/lib/notifications.ts"
    click UtilsLib "https://github.com/bakedpotato52/class_scheduler/blob/main/lib/utils.ts"
    click MenuConfig "https://github.com/bakedpotato52/class_scheduler/blob/main/lib/menu-items.ts"

    click UIWidgets "https://github.com/bakedpotato52/class_scheduler/tree/main/components/ui"

    %% Styles
    classDef client fill:#cce5ff,stroke:#000,color:#000
    classDef api fill:#d4edda,stroke:#000,color:#000
    classDef services fill:#fff3cd,stroke:#000,color:#000
    classDef utils fill:#e2e3e5,stroke:#000,color:#000
    classDef external fill:#f8d7da,stroke:#000,color:#000
```
