# harishanandh/campushub architecture

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

- Interactive diagram: https://gitdiagram.com/harishanandh/campushub
- Repository: https://github.com/harishanandh/campushub

## Overview

CampusHub combines student community management with a separate campus-safety planning area. Students enter through the React app, authenticate, and use protected pages for clubs, discussions, events, polls, profiles, and dashboard summaries; those features use the frontend API service to reach FastAPI, which accesses PostgreSQL through SQLAlchemy. The safety branch includes a local crowd-route simulation. README documents additional platform capabilities, but most page and backend implementation excerpts were not sampled, so only documented or directly evidenced connections are shown.

Main entry points: [`frontend/src/App.jsx`](https://github.com/harishanandh/campushub/blob/main/frontend/src/App.jsx) (App routes), [`frontend/src/services/api.js`](https://github.com/harishanandh/campushub/blob/main/frontend/src/services/api.js) (REST API client), [`frontend/src/pages/safety/CrowdFlow.jsx`](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/safety/CrowdFlow.jsx) (CrowdFlow page), [`backend/main.py`](https://github.com/harishanandh/campushub/blob/main/backend/main.py) (FastAPI endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Student platform"]
  node_app["App routes<br/>[App.jsx]"]
  node_auth["Login and registration<br/>[Login.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_clubs["Clubs and details<br/>[Clubs.jsx]"]
  node_discussions["Discussions<br/>[Discussions.jsx]"]
  node_events["Events<br/>[Events.jsx]"]
  node_polls["Polls and voting<br/>[Polls.jsx]"]
  node_profile["Profile<br/>[Profile.jsx]"]
  node_api["REST API client<br/>[api.js]"]
end

subgraph group_backend["API and persistence"]
  node_backend["FastAPI endpoints<br/>[main.py]"]
  node_models["SQLAlchemy models<br/>[models.py]"]
  node_dbsession["Database sessions<br/>[database.py]"]
end

subgraph group_safety["Safety planning"]
  node_campusshield["CampusShield<br/>[CampusShield.jsx]"]
  node_crowdflow["CrowdFlow page<br/>[CrowdFlow.jsx]"]
  node_crowdform["Scenario inputs<br/>[CrowdInputForm.jsx]"]
  node_routesim["Route simulation<br/>[routeSimulation.js]"]
  node_crowdresults["Simulation results"]
  node_safetyreport["Safety reports"]
  node_safetyapi["Safety API client<br/>[safetyApi.js]"]
  node_crowdapi["Crowd API client<br/>[crowdApi.js]"]
end

subgraph group_external["External services"]
  node_postgres[("PostgreSQL")]
end

node_student(("Student"))

node_student -->|"uses"| node_app
node_app -->|"routes to"| node_auth
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_clubs
node_app -->|"routes to"| node_discussions
node_app -->|"routes to"| node_events
node_app -->|"routes to"| node_polls
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_campusshield
node_app -->|"routes to"| node_crowdflow
node_auth -->|"requests auth"| node_api
node_dashboard -->|"requests data"| node_api
node_clubs -->|"requests club data"| node_api
node_discussions -->|"requests posts"| node_api
node_events -->|"requests events"| node_api
node_polls -->|"requests polls"| node_api
node_profile -->|"requests account data"| node_api
node_api -->|"sends REST requests"| node_backend
node_backend -->|"queries and updates"| node_models
node_backend -->|"uses sessions"| node_dbsession
node_dbsession -->|"connects to"| node_postgres
node_crowdflow -->|"renders"| node_crowdform
node_crowdform -->|"submits scenario"| node_crowdflow
node_crowdflow -->|"simulates route"| node_routesim
node_crowdflow -->|"passes results"| node_crowdresults

click node_app "https://github.com/harishanandh/campushub/blob/main/frontend/src/App.jsx"
click node_auth "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Login.jsx"
click node_dashboard "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Dashboard.jsx"
click node_clubs "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Clubs.jsx"
click node_discussions "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Discussions.jsx"
click node_events "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Events.jsx"
click node_polls "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Polls.jsx"
click node_profile "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Profile.jsx"
click node_api "https://github.com/harishanandh/campushub/blob/main/frontend/src/services/api.js"
click node_backend "https://github.com/harishanandh/campushub/blob/main/backend/main.py"
click node_models "https://github.com/harishanandh/campushub/blob/main/backend/models.py"
click node_dbsession "https://github.com/harishanandh/campushub/blob/main/backend/database.py"
click node_campusshield "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/safety/CampusShield.jsx"
click node_crowdflow "https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/safety/CrowdFlow.jsx"
click node_crowdform "https://github.com/harishanandh/campushub/blob/main/frontend/src/components/safety/CrowdInputForm.jsx"
click node_routesim "https://github.com/harishanandh/campushub/blob/main/frontend/src/services/safety/routeSimulation.js"
click node_crowdresults "https://github.com/harishanandh/campushub/blob/main/frontend/src/components/safety/CrowdSimulation.jsx"
click node_safetyreport "https://github.com/harishanandh/campushub/blob/main/frontend/src/components/safety/SafetyReportForm.jsx"
click node_safetyapi "https://github.com/harishanandh/campushub/blob/main/frontend/src/services/safety/safetyApi.js"
click node_crowdapi "https://github.com/harishanandh/campushub/blob/main/frontend/src/services/safety/crowdApi.js"

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_app,node_auth,node_dashboard,node_clubs,node_discussions,node_events,node_polls,node_profile,node_api toneBlue
class node_backend,node_models,node_dbsession toneAmber
class node_campusshield,node_crowdflow,node_crowdform,node_routesim,node_crowdresults,node_safetyreport,node_safetyapi,node_crowdapi toneMint
class node_postgres toneRose
class node_student toneIndigo
```

## Components

### Student platform

- [App routes](https://github.com/harishanandh/campushub/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and registration](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Dashboard](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Clubs and details](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Clubs.jsx): `frontend/src/pages/Clubs.jsx`
- [Discussions](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Discussions.jsx): `frontend/src/pages/Discussions.jsx`
- [Events](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Events.jsx): `frontend/src/pages/Events.jsx`
- [Polls and voting](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Polls.jsx): `frontend/src/pages/Polls.jsx`
- [Profile](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/Profile.jsx): `frontend/src/pages/Profile.jsx`
- [REST API client](https://github.com/harishanandh/campushub/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and persistence

- [FastAPI endpoints](https://github.com/harishanandh/campushub/blob/main/backend/main.py): `backend/main.py`
- [SQLAlchemy models](https://github.com/harishanandh/campushub/blob/main/backend/models.py): `backend/models.py`
- [Database sessions](https://github.com/harishanandh/campushub/blob/main/backend/database.py): `backend/database.py`

### Safety planning

- [CampusShield](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/safety/CampusShield.jsx): `frontend/src/pages/safety/CampusShield.jsx`
- [CrowdFlow page](https://github.com/harishanandh/campushub/blob/main/frontend/src/pages/safety/CrowdFlow.jsx): `frontend/src/pages/safety/CrowdFlow.jsx`
- [Scenario inputs](https://github.com/harishanandh/campushub/blob/main/frontend/src/components/safety/CrowdInputForm.jsx): `frontend/src/components/safety/CrowdInputForm.jsx`
- [Route simulation](https://github.com/harishanandh/campushub/blob/main/frontend/src/services/safety/routeSimulation.js): `frontend/src/services/safety/routeSimulation.js`
- [Simulation results](https://github.com/harishanandh/campushub/blob/main/frontend/src/components/safety/CrowdSimulation.jsx): `frontend/src/components/safety/CrowdSimulation.jsx`
- [Safety reports](https://github.com/harishanandh/campushub/blob/main/frontend/src/components/safety/SafetyReportForm.jsx): `frontend/src/components/safety/SafetyReportForm.jsx`
- [Safety API client](https://github.com/harishanandh/campushub/blob/main/frontend/src/services/safety/safetyApi.js): `frontend/src/services/safety/safetyApi.js`
- [Crowd API client](https://github.com/harishanandh/campushub/blob/main/frontend/src/services/safety/crowdApi.js): `frontend/src/services/safety/crowdApi.js`

### External services

- **PostgreSQL**

### Other components

- **Student**

## Connections

- Student → App routes: uses
- App routes → Login and registration: routes to
- App routes → Dashboard: routes to
- App routes → Clubs and details: routes to
- App routes → Discussions: routes to
- App routes → Events: routes to
- App routes → Polls and voting: routes to
- App routes → Profile: routes to
- App routes → CampusShield: routes to
- App routes → CrowdFlow page: routes to
- Login and registration → REST API client: requests auth
- Dashboard → REST API client: requests data
- Clubs and details → REST API client: requests club data
- Discussions → REST API client: requests posts
- Events → REST API client: requests events
- Polls and voting → REST API client: requests polls
- Profile → REST API client: requests account data
- REST API client → FastAPI endpoints: sends REST requests
- FastAPI endpoints → SQLAlchemy models: queries and updates
- FastAPI endpoints → Database sessions: uses sessions
- Database sessions → PostgreSQL: connects to
- CrowdFlow page → Scenario inputs: renders
- Scenario inputs → CrowdFlow page: submits scenario
- CrowdFlow page → Route simulation: simulates route
- CrowdFlow page → Simulation results: passes results
