# code84/campusgo architecture

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

- Interactive diagram: https://gitdiagram.com/code84/campusgo
- Repository: https://github.com/code84/campusgo

## Overview

CampusGo is a role-based campus ride-dispatch platform. Passengers authenticate, request or schedule rides, track dispatch and ride status, pay after driver acceptance, then rate completed rides; drivers manage availability and requests, and admins verify drivers and monitor operations. The frontend routes these workflows to a FastAPI backend, with WebSockets for live events and MongoDB for persistence. The backend is represented as one service because the supplied tree contains a single implementation file; detailed backend route-to-storage internals were not sampled.

Main entry points: [`frontend/src/App.js`](https://github.com/code84/campusgo/blob/main/frontend/src/App.js) (Role Router), [`frontend/src/lib/api.js`](https://github.com/code84/campusgo/blob/main/frontend/src/lib/api.js) (API Client), [`frontend/src/lib/SocketContext.jsx`](https://github.com/code84/campusgo/blob/main/frontend/src/lib/SocketContext.jsx) (WebSocket Provider), [`frontend/src/pages/PassengerHome.jsx`](https://github.com/code84/campusgo/blob/main/frontend/src/pages/PassengerHome.jsx) (Passenger Ride Booking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and App Shell"]
  node_router["Role Router<br/>[App.js]"]
  node_login["Login and Signup<br/>[Login.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_auth["Auth State<br/>[AuthContext.jsx]"]
  node_api["API Client<br/>[api.js]"]
end

subgraph group_dispatch["Ride Dispatch"]
  node_passenger_flow["Passenger Ride Booking<br/>[PassengerHome.jsx]"]
  node_driver_dashboard["Driver Dashboard"]
  node_driver_inbox["Driver Request Inbox<br/>[DriverInbox.jsx]"]
  node_backend["FastAPI Service<br/>[server.py]"]
  node_database[("MongoDB")]
  node_payments["Razorpay Checkout<br/>[PassengerHome.jsx]"]
  node_history["Ride History<br/>[History.jsx]"]
end

subgraph group_live["Live Operations"]
  node_map["Live Map and Routes<br/>[LiveMap.jsx]"]
  node_socket["WebSocket Provider<br/>[SocketContext.jsx]"]
  node_maps_service["Map Tiles and Routing"]
  node_notifications["Notification Inbox<br/>[Notifications.jsx]"]
end

subgraph group_operations["Platform Operations"]
  node_admin_dashboard["Admin Dashboard<br/>[AdminDashboard.jsx]"]
  node_driver_analytics["Driver Analytics"]
  node_profile["Profile<br/>[Profile.jsx]"]
end

node_passenger(("Passenger"))
node_driver(("Driver"))
node_admin(("Admin"))

node_passenger -->|"opens app"| node_router
node_driver -->|"opens app"| node_router
node_admin -->|"opens app"| node_router
node_router -->|"routes to"| node_login
node_router -->|"routes to"| node_register
node_router -->|"role-routes to"| node_passenger_flow
node_router -->|"role-routes to"| node_driver_dashboard
node_router -->|"role-routes to"| node_driver_inbox
node_router -->|"role-routes to"| node_admin_dashboard
node_router -->|"routes to"| node_history
node_router -->|"routes to"| node_notifications
node_router -->|"routes to"| node_profile
node_login -->|"authenticates through"| node_auth
node_register -->|"registers through"| node_auth
node_auth -->|"sends auth requests"| node_api
node_passenger_flow -->|"requests ride APIs"| node_api
node_driver_dashboard -->|"updates ride state"| node_api
node_driver_inbox -->|"handles requests"| node_api
node_history -->|"loads history"| node_api
node_admin_dashboard -->|"loads admin data"| node_api
node_driver_analytics -->|"loads analytics"| node_api
node_notifications -->|"manages notifications"| node_api
node_profile -->|"loads profile"| node_api
node_api -->|"calls REST API"| node_backend
node_passenger_flow -->|"opens checkout"| node_payments
node_payments -->|"submits payment"| node_backend
node_backend -->|"persists platform data"| node_database
node_passenger_flow -->|"renders ride map"| node_map
node_driver_dashboard -->|"renders ride route"| node_map
node_map -->|"loads tiles and routes"| node_maps_service
node_socket -->|"builds WebSocket URL"| node_api
node_socket -->|"receives live events"| node_backend
node_passenger_flow -->|"subscribes to updates"| node_socket
node_driver_dashboard -->|"subscribes to updates"| node_socket
node_driver_inbox -->|"receives ride events"| node_socket
node_notifications -->|"receives live updates"| node_socket
node_backend -.->|"stores notifications and rides"| node_database

click node_router "https://github.com/code84/campusgo/blob/main/frontend/src/App.js"
click node_login "https://github.com/code84/campusgo/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/code84/campusgo/blob/main/frontend/src/pages/Register.jsx"
click node_auth "https://github.com/code84/campusgo/blob/main/frontend/src/lib/AuthContext.jsx"
click node_api "https://github.com/code84/campusgo/blob/main/frontend/src/lib/api.js"
click node_passenger_flow "https://github.com/code84/campusgo/blob/main/frontend/src/pages/PassengerHome.jsx"
click node_driver_dashboard "https://github.com/code84/campusgo/blob/main/frontend/src/pages/DriverDashboard.jsx"
click node_driver_inbox "https://github.com/code84/campusgo/blob/main/frontend/src/pages/DriverInbox.jsx"
click node_backend "https://github.com/code84/campusgo/blob/main/backend/server.py"
click node_payments "https://github.com/code84/campusgo/blob/main/frontend/src/pages/PassengerHome.jsx"
click node_history "https://github.com/code84/campusgo/blob/main/frontend/src/pages/History.jsx"
click node_map "https://github.com/code84/campusgo/blob/main/frontend/src/components/LiveMap.jsx"
click node_socket "https://github.com/code84/campusgo/blob/main/frontend/src/lib/SocketContext.jsx"
click node_notifications "https://github.com/code84/campusgo/blob/main/frontend/src/pages/Notifications.jsx"
click node_admin_dashboard "https://github.com/code84/campusgo/blob/main/frontend/src/pages/AdminDashboard.jsx"
click node_driver_analytics "https://github.com/code84/campusgo/blob/main/frontend/src/pages/DriverAnalytics.jsx"
click node_profile "https://github.com/code84/campusgo/blob/main/frontend/src/pages/Profile.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_router,node_login,node_register,node_auth,node_api toneBlue
class node_passenger_flow,node_driver_dashboard,node_driver_inbox,node_backend,node_database,node_payments,node_history toneAmber
class node_map,node_socket,node_maps_service,node_notifications toneMint
class node_admin_dashboard,node_driver_analytics,node_profile toneRose
class node_passenger,node_driver,node_admin toneIndigo
```

## Components

### Identity and App Shell

- [Role Router](https://github.com/code84/campusgo/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Login and Signup](https://github.com/code84/campusgo/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration](https://github.com/code84/campusgo/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Auth State](https://github.com/code84/campusgo/blob/main/frontend/src/lib/AuthContext.jsx): `frontend/src/lib/AuthContext.jsx`
- [API Client](https://github.com/code84/campusgo/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### Ride Dispatch

- [Passenger Ride Booking](https://github.com/code84/campusgo/blob/main/frontend/src/pages/PassengerHome.jsx): `frontend/src/pages/PassengerHome.jsx`
- [Driver Dashboard](https://github.com/code84/campusgo/blob/main/frontend/src/pages/DriverDashboard.jsx): `frontend/src/pages/DriverDashboard.jsx`
- [Driver Request Inbox](https://github.com/code84/campusgo/blob/main/frontend/src/pages/DriverInbox.jsx): `frontend/src/pages/DriverInbox.jsx`
- [FastAPI Service](https://github.com/code84/campusgo/blob/main/backend/server.py): `backend/server.py`
- **MongoDB**
- [Razorpay Checkout](https://github.com/code84/campusgo/blob/main/frontend/src/pages/PassengerHome.jsx): `frontend/src/pages/PassengerHome.jsx`
- [Ride History](https://github.com/code84/campusgo/blob/main/frontend/src/pages/History.jsx): `frontend/src/pages/History.jsx`

### Live Operations

- [Live Map and Routes](https://github.com/code84/campusgo/blob/main/frontend/src/components/LiveMap.jsx): `frontend/src/components/LiveMap.jsx`
- [WebSocket Provider](https://github.com/code84/campusgo/blob/main/frontend/src/lib/SocketContext.jsx): `frontend/src/lib/SocketContext.jsx`
- **Map Tiles and Routing**
- [Notification Inbox](https://github.com/code84/campusgo/blob/main/frontend/src/pages/Notifications.jsx): `frontend/src/pages/Notifications.jsx`

### Platform Operations

- [Admin Dashboard](https://github.com/code84/campusgo/blob/main/frontend/src/pages/AdminDashboard.jsx): `frontend/src/pages/AdminDashboard.jsx`
- [Driver Analytics](https://github.com/code84/campusgo/blob/main/frontend/src/pages/DriverAnalytics.jsx): `frontend/src/pages/DriverAnalytics.jsx`
- [Profile](https://github.com/code84/campusgo/blob/main/frontend/src/pages/Profile.jsx): `frontend/src/pages/Profile.jsx`

### Other components

- **Passenger**
- **Driver**
- **Admin**

## Connections

- Passenger → Role Router: opens app (evidence: `frontend/src/App.js`)
- Driver → Role Router: opens app (evidence: `frontend/src/App.js`)
- Admin → Role Router: opens app (evidence: `frontend/src/App.js`)
- Role Router → Login and Signup: routes to (evidence: `frontend/src/App.js`)
- Role Router → Registration: routes to (evidence: `frontend/src/App.js`)
- Role Router → Passenger Ride Booking: role-routes to (evidence: `frontend/src/App.js`)
- Role Router → Driver Dashboard: role-routes to (evidence: `frontend/src/App.js`)
- Role Router → Driver Request Inbox: role-routes to (evidence: `frontend/src/App.js`)
- Role Router → Admin Dashboard: role-routes to (evidence: `frontend/src/App.js`)
- Role Router → Ride History: routes to (evidence: `frontend/src/App.js`)
- Role Router → Notification Inbox: routes to (evidence: `frontend/src/App.js`)
- Role Router → Profile: routes to (evidence: `frontend/src/App.js`)
- Login and Signup → Auth State: authenticates through (evidence: `frontend/src/lib/AuthContext.jsx`)
- Registration → Auth State: registers through (evidence: `frontend/src/lib/AuthContext.jsx`)
- Auth State → API Client: sends auth requests (evidence: `frontend/src/lib/AuthContext.jsx`)
- Passenger Ride Booking → API Client: requests ride APIs (evidence: `frontend/src/pages/PassengerHome.jsx`)
- Driver Dashboard → API Client: updates ride state (evidence: `frontend/src/pages/DriverDashboard.jsx`)
- Driver Request Inbox → API Client: handles requests (evidence: `frontend/src/pages/DriverInbox.jsx`)
- Ride History → API Client: loads history (evidence: `frontend/src/pages/History.jsx`)
- Admin Dashboard → API Client: loads admin data (evidence: `frontend/src/pages/AdminDashboard.jsx`)
- Driver Analytics → API Client: loads analytics (evidence: `frontend/src/pages/DriverAnalytics.jsx`)
- Notification Inbox → API Client: manages notifications (evidence: `frontend/src/pages/Notifications.jsx`)
- Profile → API Client: loads profile (evidence: `frontend/src/pages/Profile.jsx`)
- API Client → FastAPI Service: calls REST API (evidence: `README.md`)
- Passenger Ride Booking → Razorpay Checkout: opens checkout (evidence: `README.md`)
- Razorpay Checkout → FastAPI Service: submits payment (evidence: `README.md`)
- FastAPI Service → MongoDB: persists platform data (evidence: `README.md`)
- Passenger Ride Booking → Live Map and Routes: renders ride map (evidence: `frontend/src/pages/PassengerHome.jsx`)
- Driver Dashboard → Live Map and Routes: renders ride route (evidence: `frontend/src/pages/DriverDashboard.jsx`)
- Live Map and Routes → Map Tiles and Routing: loads tiles and routes (evidence: `frontend/src/components/LiveMap.jsx`)
- WebSocket Provider → API Client: builds WebSocket URL (evidence: `frontend/src/lib/SocketContext.jsx`)
- WebSocket Provider → FastAPI Service: receives live events (evidence: `README.md`)
- Passenger Ride Booking → WebSocket Provider: subscribes to updates (evidence: `frontend/src/pages/PassengerHome.jsx`)
- Driver Dashboard → WebSocket Provider: subscribes to updates (evidence: `frontend/src/pages/DriverDashboard.jsx`)
- Driver Request Inbox → WebSocket Provider: receives ride events (evidence: `frontend/src/pages/DriverInbox.jsx`)
- Notification Inbox → WebSocket Provider: receives live updates (evidence: `frontend/src/pages/Notifications.jsx`)
- FastAPI Service → MongoDB: stores notifications and rides
