# crypto-darth/campusshuttle-pro-bennettuniversity architecture

> Architecture diagram of the GitHub repository crypto-darth/campusshuttle-pro-bennettuniversity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crypto-darth/campusshuttle-pro-bennettuniversity
- Repository: https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity

## Overview

##### Project type and purpose
- This is a cross‑platform mobile application built with Expo (React Native) that provides two distinct user experiences—one for school bus drivers and one for students.
- The driver side allows bus drivers to see routes, student lists, and attendance. The student side allows students (or parents) to track the bus, view schedules, trigger SOS alerts, and mark attendance.

##### File structure
- Top‑level “app” directory uses Expo’s file‑based routing. Under it:
- `_layout.tsx` – Root layout and navigation wrapper.
- `index.tsx` – Home or role‐selection screen.
- `driver/index.tsx` + `driver/components/...` – Entire driver UI module.
- `student/index.tsx` + `student/components/...` – Entire student UI module.
- `services/` contains business‑logic modules that wrap Firebase calls (attendanceService, busService, routeService, shuttleService) and utilities (dateUtils).
- `firebase.js` + `services/firebaseConfig.js` handle Firebase initialization and config.
- `scripts/` contains Node scripts for initializing and seeding the database.
- `assets/`, `styles/` hold fonts, images, and styling files.

##### README
- Confirms it’s created by `create-expo-app` and uses Expo Router.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile App"
        subgraph "Routing Layer"
            RouterLayout["_layout.tsx"]:::frontend
            RouterIndex["index.tsx"]:::frontend
        end
        subgraph "Driver UI Module"
            D_Index["driver/index.tsx"]:::frontend
            D_BusInfoBar["BusInfoBar.tsx"]:::frontend
            D_DriverHeader["DriverHeader.tsx"]:::frontend
            D_DriverMap["DriverMap.tsx"]:::frontend
            D_RouteDetails["RouteDetails.tsx"]:::frontend
            D_StudentsList["StudentsList.tsx"]:::frontend
            D_TabSelector["TabSelector.tsx"]:::frontend
        end
        subgraph "Student UI Module"
            S_Index["student/index.tsx"]:::frontend
            S_AttModal["AttendanceModal.tsx"]:::frontend
            S_BottomNav["BottomNavigation.tsx"]:::frontend
            S_BusInfoCard["BusInfoCard.tsx"]:::frontend
            S_ProfileView["ProfileView.tsx"]:::frontend
            S_QuickActions["QuickActions.tsx"]:::frontend
            S_SOSModal["SOSModal.tsx"]:::frontend
            S_ScheduleView["ScheduleView.tsx"]:::frontend
            S_StudentHeader["StudentHeader.tsx"]:::frontend
            S_StudentMap["StudentMap.tsx"]:::frontend
            S_StudentSwitcher["StudentSwitcher.tsx"]:::frontend
            S_TrackingView["TrackingView.tsx"]:::frontend
        end
    end

    subgraph "Service Layer"
        ServicesIndex["services/index.js"]:::service
        AttendanceService["attendanceService.js"]:::service
        BusService["busService.js"]:::service
        RouteService["routeService.js"]:::service
        ShuttleService["shuttleService.js"]:::service
        DateUtils["dateUtils.js"]:::service
        FirebaseConfig["firebaseConfig.js"]:::service
    end

    DataModels["models/dataModels.js"]:::service

    subgraph "Firebase Backend"
        Auth["Authentication"]:::backend
        Firestore["Database (Firestore)"]:::backend
        CloudFunctions["Cloud Functions"]:::backend
    end

    subgraph "Scripts"
        InitDb["initDb.js"]:::service
        SetupDb["setupDatabase.js"]:::service
    end

    ExternalMap["External Map API"]:::external

    %% Routing to UI
    RouterIndex -->|"navigates to"| D_Index
    RouterIndex -->|"navigates to"| S_Index

    %% UI to Services
    D_Index -->|"calls services"| ServicesIndex
    S_Index -->|"calls services"| ServicesIndex

    %% Service imports
    ServicesIndex -->|"imports"| AttendanceService
    ServicesIndex -->|"imports"| BusService
    ServicesIndex -->|"imports"| RouteService
    ServicesIndex -->|"imports"| ShuttleService

    %% Services to utils
    AttendanceService -->|"uses"| DateUtils
    BusService -->|"uses"| DateUtils
    RouteService -->|"uses"| DateUtils
    ShuttleService -->|"uses"| DateUtils

    %% Services to Firebase config
    AttendanceService -->|"uses"| FirebaseConfig
    BusService -->|"uses"| FirebaseConfig
    RouteService -->|"uses"| FirebaseConfig
    ShuttleService -->|"uses"| FirebaseConfig

    %% Config to Firebase backend
    FirebaseConfig -->|"initializes auth"| Auth
    FirebaseConfig -->|"connects to db"| Firestore
    FirebaseConfig -->|"deploys functions"| CloudFunctions

    %% Data models usage
    AttendanceService -->|"shapes data"| DataModels
    BusService -->|"shapes data"| DataModels
    RouteService -->|"shapes data"| DataModels
    ShuttleService -->|"shapes data"| DataModels

    %% Map interactions
    D_DriverMap -->|"fetch/renders map"| ExternalMap
    S_StudentMap -->|"fetch/renders map"| ExternalMap

    %% Scripts interactions
    InitDb -->|"seeds data"| Firestore
    SetupDb -->|"initializes"| Firestore

    %% Click Events
    click RouterLayout "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/_layout.tsx"
    click RouterIndex "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/index.tsx"

    click D_Index "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/driver/index.tsx"
    click D_BusInfoBar "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/driver/components/BusInfoBar.tsx"
    click D_DriverHeader "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/driver/components/DriverHeader.tsx"
    click D_DriverMap "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/driver/components/DriverMap.tsx"
    click D_RouteDetails "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/driver/components/RouteDetails.tsx"
    click D_StudentsList "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/driver/components/StudentsList.tsx"
    click D_TabSelector "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/driver/components/TabSelector.tsx"

    click S_Index "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/index.tsx"
    click S_AttModal "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/AttendanceModal.tsx"
    click S_BottomNav "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/BottomNavigation.tsx"
    click S_BusInfoCard "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/BusInfoCard.tsx"
    click S_ProfileView "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/ProfileView.tsx"
    click S_QuickActions "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/QuickActions.tsx"
    click S_SOSModal "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/SOSModal.tsx"
    click S_ScheduleView "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/ScheduleView.tsx"
    click S_StudentHeader "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/StudentHeader.tsx"
    click S_StudentMap "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/StudentMap.tsx"
    click S_StudentSwitcher "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/StudentSwitcher.tsx"
    click S_TrackingView "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/app/student/components/TrackingView.tsx"

    click AttendanceService "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/services/attendanceService.js"
    click BusService "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/services/busService.js"
    click RouteService "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/services/routeService.js"
    click ShuttleService "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/services/shuttleService.js"
    click ServicesIndex "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/services/index.js"
    click DateUtils "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/services/utils/dateUtils.js"

    click FirebaseConfig "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/services/firebaseConfig.js"
    click DataModels "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/models/dataModels.js"

    click InitDb "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/scripts/initDb.js"
    click SetupDb "https://github.com/crypto-darth/campusshuttle-pro-bennettuniversity/blob/main/scripts/setupDatabase.js"

    classDef frontend fill:#D0E6FF,stroke:#1E6F9F,color:#000
    classDef service fill:#DFFFE0,stroke:#4F8F02,color:#000
    classDef backend fill:#FFE6C0,stroke:#C67200,color:#000
    classDef external fill:#E0E0E0,stroke:#999,color:#000
```
