# rohanpudari/smarthostel architecture

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

- Interactive diagram: https://gitdiagram.com/rohanpudari/smarthostel
- Repository: https://github.com/rohanpudari/smarthostel

## Overview

SmartHostel is a hostel-operations platform: students authenticate, view meals and mark attendance, check facility availability and book or cancel slots, and submit complaints; staff/admins manage complaints and inventory. The React pages call a JWT-enabled API client, while FastAPI routes requests into domain handlers and PostgreSQL or MongoDB-backed data. Facility capacity and inventory stock are important correctness concerns documented in the README. The graph retains the documented feature branches; unsampled route internals are represented only where the index or README supports the relationship.

Main entry points: [`backend/app/main.py`](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/App.jsx`](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/App.jsx) (App routing), [`backend/app/routers/auth.py`](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/auth.py) (Auth endpoints), [`frontend/src/api/client.js`](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/api/client.js) (JWT API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Auth state<br/>[AuthContext.jsx]"]
  node_client["JWT API client<br/>[client.js]"]
  node_mealui["Meal attendance<br/>[Meals.jsx]"]
  node_facilityui["Facility bookings<br/>[Facilities.jsx]"]
  node_complaintui["Complaints UI<br/>[Complaints.jsx]"]
  node_inventoryui["Inventory UI<br/>[Inventory.jsx]"]
end

subgraph group_api["FastAPI API"]
  node_schemas["Request schemas"]
  node_server["FastAPI application<br/>[main.py]"]
end

subgraph group_identity["Identity and access"]
  node_authroutes["Auth endpoints<br/>[auth.py]"]
  node_authguard["JWT authorization<br/>[dependencies.py]"]
  node_jwt["Token handling<br/>[jwt.py]"]
  node_security["Password security<br/>[security.py]"]
end

subgraph group_operations["Operations domains"]
  node_mealroutes["Meal attendance API<br/>[meals.py]"]
  node_facilityroutes["Facility availability<br/>[facilities.py]"]
  node_bookingroutes["Booking API<br/>[bookings.py]"]
  node_complaintroutes["Complaint API<br/>[complaints.py]"]
  node_inventoryroutes["Inventory API<br/>[inventory.py]"]
end

subgraph group_persistence["Persistence"]
  node_models["Relational models"]
  node_sqlsession["SQLAlchemy session<br/>[database.py]"]
  node_postgres[("PostgreSQL")]
  node_mongosession["MongoDB connection<br/>[mongo.py]"]
  node_mongodb[("MongoDB")]
end

node_students(("Students and staff"))

node_students -->|"use app"| node_app
node_app -->|"provides auth"| node_authui
node_app -->|"routes to"| node_mealui
node_app -->|"routes to"| node_facilityui
node_app -->|"routes to"| node_complaintui
node_app -->|"routes to"| node_inventoryui
node_authui -->|"calls API"| node_client
node_mealui -->|"calls API"| node_client
node_facilityui -->|"calls API"| node_client
node_complaintui -->|"calls API"| node_client
node_inventoryui -->|"calls API"| node_client
node_client -->|"sends REST requests"| node_server
node_server -->|"registers routes"| node_authroutes
node_server -->|"registers routes"| node_mealroutes
node_server -->|"registers routes"| node_facilityroutes
node_server -->|"registers routes"| node_bookingroutes
node_server -->|"registers routes"| node_complaintroutes
node_server -->|"registers routes"| node_inventoryroutes
node_authroutes -->|"hashes passwords"| node_security
node_authroutes -->|"issues tokens"| node_jwt
node_authguard -->|"decodes tokens"| node_jwt
node_authroutes -->|"checks identity"| node_authguard
node_mealroutes -->|"reads and writes"| node_models
node_facilityroutes -->|"reads and writes"| node_models
node_bookingroutes -->|"creates bookings"| node_models
node_inventoryroutes -->|"updates stock"| node_models
node_complaintroutes -->|"stores complaints"| node_mongodb
node_server -->|"provides connection"| node_mongosession
node_mongosession -->|"connects to"| node_mongodb
node_authroutes -->|"uses session"| node_sqlsession
node_mealroutes -->|"uses session"| node_sqlsession
node_facilityroutes -->|"uses session"| node_sqlsession
node_bookingroutes -->|"uses session"| node_sqlsession
node_inventoryroutes -->|"uses session"| node_sqlsession
node_sqlsession -->|"persists relational data"| node_postgres
node_authroutes -->|"validates payloads"| node_schemas
node_mealroutes -->|"uses schemas"| node_schemas
node_facilityroutes -->|"uses schemas"| node_schemas
node_bookingroutes -->|"uses schemas"| node_schemas
node_inventoryroutes -->|"uses schemas"| node_schemas

click node_app "https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/context/AuthContext.jsx"
click node_client "https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/api/client.js"
click node_mealui "https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Meals.jsx"
click node_facilityui "https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Facilities.jsx"
click node_complaintui "https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Complaints.jsx"
click node_inventoryui "https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Inventory.jsx"
click node_authroutes "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/auth.py"
click node_authguard "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/auth/dependencies.py"
click node_jwt "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/auth/jwt.py"
click node_security "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/auth/security.py"
click node_mealroutes "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/meals.py"
click node_facilityroutes "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/facilities.py"
click node_bookingroutes "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/bookings.py"
click node_complaintroutes "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/complaints.py"
click node_inventoryroutes "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/inventory.py"
click node_models "https://github.com/rohanpudari/smarthostel/tree/main/backend/app/models"
click node_schemas "https://github.com/rohanpudari/smarthostel/tree/main/backend/app/schemas"
click node_sqlsession "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/database.py"
click node_mongosession "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/mongo.py"
click node_server "https://github.com/rohanpudari/smarthostel/blob/main/backend/app/main.py"

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_authui,node_client,node_mealui,node_facilityui,node_complaintui,node_inventoryui toneBlue
class node_schemas,node_server toneAmber
class node_authroutes,node_authguard,node_jwt,node_security toneMint
class node_mealroutes,node_facilityroutes,node_bookingroutes,node_complaintroutes,node_inventoryroutes toneRose
class node_models,node_sqlsession,node_postgres,node_mongosession,node_mongodb,node_students toneIndigo
```

## Components

### React frontend

- [App routing](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth state](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [JWT API client](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Meal attendance](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Meals.jsx): `frontend/src/pages/Meals.jsx`
- [Facility bookings](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Facilities.jsx): `frontend/src/pages/Facilities.jsx`
- [Complaints UI](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Complaints.jsx): `frontend/src/pages/Complaints.jsx`
- [Inventory UI](https://github.com/rohanpudari/smarthostel/blob/main/frontend/src/pages/Inventory.jsx): `frontend/src/pages/Inventory.jsx`

### FastAPI API

- [Request schemas](https://github.com/rohanpudari/smarthostel/tree/main/backend/app/schemas): `backend/app/schemas`
- [FastAPI application](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/main.py): `backend/app/main.py`

### Identity and access

- [Auth endpoints](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [JWT authorization](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/auth/dependencies.py): `backend/app/auth/dependencies.py`
- [Token handling](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/auth/jwt.py): `backend/app/auth/jwt.py`
- [Password security](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/auth/security.py): `backend/app/auth/security.py`

### Operations domains

- [Meal attendance API](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/meals.py): `backend/app/routers/meals.py`
- [Facility availability](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/facilities.py): `backend/app/routers/facilities.py`
- [Booking API](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/bookings.py): `backend/app/routers/bookings.py`
- [Complaint API](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/complaints.py): `backend/app/routers/complaints.py`
- [Inventory API](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/routers/inventory.py): `backend/app/routers/inventory.py`

### Persistence

- [Relational models](https://github.com/rohanpudari/smarthostel/tree/main/backend/app/models): `backend/app/models`
- [SQLAlchemy session](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/database.py): `backend/app/database.py`
- **PostgreSQL**
- [MongoDB connection](https://github.com/rohanpudari/smarthostel/blob/main/backend/app/mongo.py): `backend/app/mongo.py`
- **MongoDB**

### Other components

- **Students and staff**

## Connections

- Students and staff → App routing: use app (evidence: `README.md`)
- App routing → Auth state: provides auth (evidence: `frontend/src/main.jsx`)
- App routing → Meal attendance: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Facility bookings: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Complaints UI: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Inventory UI: routes to (evidence: `frontend/src/App.jsx`)
- Auth state → JWT API client: calls API (evidence: `frontend/src/context/AuthContext.jsx`)
- Meal attendance → JWT API client: calls API (evidence: `frontend/src/pages/Meals.jsx`)
- Facility bookings → JWT API client: calls API (evidence: `frontend/src/pages/Facilities.jsx`)
- Complaints UI → JWT API client: calls API (evidence: `frontend/src/pages/Complaints.jsx`)
- Inventory UI → JWT API client: calls API (evidence: `frontend/src/pages/Inventory.jsx`)
- JWT API client → FastAPI application: sends REST requests (evidence: `README.md`)
- FastAPI application → Auth endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Meal attendance API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Facility availability: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Booking API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Complaint API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Inventory API: registers routes (evidence: `backend/app/main.py`)
- Auth endpoints → Password security: hashes passwords (evidence: `backend/app/routers/auth.py`)
- Auth endpoints → Token handling: issues tokens (evidence: `backend/app/routers/auth.py`)
- JWT authorization → Token handling: decodes tokens (evidence: `backend/app/auth/dependencies.py`)
- Auth endpoints → JWT authorization: checks identity (evidence: `backend/app/routers/auth.py`)
- Meal attendance API → Relational models: reads and writes (evidence: `backend/app/routers/meals.py`)
- Facility availability → Relational models: reads and writes (evidence: `backend/app/routers/facilities.py`)
- Booking API → Relational models: creates bookings (evidence: `backend/app/routers/bookings.py`)
- Inventory API → Relational models: updates stock (evidence: `backend/app/routers/inventory.py`)
- Complaint API → MongoDB: stores complaints (evidence: `README.md`)
- FastAPI application → MongoDB connection: provides connection (evidence: `backend/app/main.py`)
- MongoDB connection → MongoDB: connects to (evidence: `README.md`)
- Auth endpoints → SQLAlchemy session: uses session (evidence: `backend/app/routers/auth.py`)
- Meal attendance API → SQLAlchemy session: uses session (evidence: `backend/app/routers/meals.py`)
- Facility availability → SQLAlchemy session: uses session (evidence: `backend/app/routers/facilities.py`)
- Booking API → SQLAlchemy session: uses session (evidence: `backend/app/routers/bookings.py`)
- Inventory API → SQLAlchemy session: uses session (evidence: `backend/app/routers/inventory.py`)
- SQLAlchemy session → PostgreSQL: persists relational data (evidence: `README.md`)
- Auth endpoints → Request schemas: validates payloads (evidence: `backend/app/routers/auth.py`)
- Meal attendance API → Request schemas: uses schemas (evidence: `backend/app/routers/meals.py`)
- Facility availability → Request schemas: uses schemas (evidence: `backend/app/routers/facilities.py`)
- Booking API → Request schemas: uses schemas (evidence: `backend/app/routers/bookings.py`)
- Inventory API → Request schemas: uses schemas (evidence: `backend/app/routers/inventory.py`)
