# divit-s07/bus_fee_check architecture

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

- Interactive diagram: https://gitdiagram.com/divit-s07/bus_fee_check
- Repository: https://github.com/divit-s07/bus_fee_check

## Overview

Bus Fee Check is a local college transport-fee administration system. Admins manage students and buses, register student faces, and scan boarding passengers; the backend matches faces through the local AI service, checks fee status, records unpaid trips and repeat offenses, and pushes live events to the dashboard. Receipt OCR can update fee/student records, while reports and analytics support oversight. The README documents several capabilities whose implementation was not sampled; those branches are included at subsystem level, with uncertain internal wiring omitted.

Main entry points: [`backend/server.js`](https://github.com/divit-s07/bus_fee_check/blob/main/backend/server.js) (Express API), [`frontend/src/App.jsx`](https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/App.jsx) (React app), [`backend/models`](https://github.com/divit-s07/bus_fee_check/tree/main/backend/models) (Domain records), [`backend/controllers/face.controller.js`](https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/face.controller.js) (Scan and fee decision)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Admin application"]
  node_webapp["React app<br/>[App.jsx]"]
  node_studentsui["Student management<br/>[Students.jsx]"]
  node_facescanui["Face scan<br/>[FaceScan.jsx]"]
  node_travelui["Travel views<br/>[TravelRecords.jsx]"]
  node_unpaidui["Unpaid alerts<br/>[UnpaidTravels.jsx]"]
  node_reportsui["Reports and dashboard<br/>[Reports.jsx]"]
end

subgraph group_backend["API and domain"]
  node_api["Express API<br/>[server.js]"]
  node_auth["JWT and role checks<br/>[auth.js]"]
  node_studentops["Student and bus admin"]
  node_faceflow["Scan and fee decision<br/>[face.controller.js]"]
  node_receiptflow["Receipt OCR workflow"]
  node_ocr["Receipt extraction<br/>[receipt.service.js]"]
  node_travelops["Travel services<br/>[travel.service.js]"]
  node_reporting["Reports and analytics"]
  node_realtime["Socket events<br/>[index.js]"]
  node_faceclient["AI HTTP client<br/>[faceAI.service.js]"]
end

subgraph group_ai["Face recognition"]
  node_faceai["Local face matching<br/>[main.py]"]
end

subgraph group_data["Persistent records"]
  node_records["Domain records"]
end

node_admin(("College admin"))
node_mongodb[("MongoDB")]
node_ocrfiles["Uploaded receipts"]

node_admin -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_studentsui
node_webapp -->|"routes to"| node_facescanui
node_webapp -->|"routes to"| node_travelui
node_webapp -->|"routes to"| node_unpaidui
node_webapp -->|"routes to"| node_reportsui
node_webapp -->|"calls"| node_api
node_studentsui -->|"requests data"| node_api
node_api -.->|"verifies requests"| node_auth
node_api -->|"routes requests"| node_studentops
node_studentops -->|"reads and writes"| node_records
node_facescanui -->|"sends scan"| node_api
node_api -.->|"routes scan"| node_faceflow
node_faceflow -->|"requests match"| node_faceclient
node_faceclient -.->|"sends image"| node_faceai
node_faceai -->|"reads students"| node_mongodb
node_faceflow -->|"reads and writes"| node_records
node_faceflow -->|"emits events"| node_realtime
node_receiptflow -->|"extracts receipt"| node_ocr
node_receiptflow -->|"updates students"| node_records
node_receiptflow -->|"reads uploads"| node_ocrfiles
node_travelops -->|"reads and writes"| node_records
node_travelops -->|"emits events"| node_realtime
node_reportsui -.->|"requests summaries"| node_api
node_api -.->|"routes reports"| node_reporting
node_unpaidui -.->|"requests unpaid trips"| node_api
node_realtime -.->|"pushes updates"| node_travelui
node_records -.->|"persists in"| node_mongodb

click node_webapp "https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/App.jsx"
click node_studentsui "https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/Students.jsx"
click node_facescanui "https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/FaceScan.jsx"
click node_travelui "https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/TravelRecords.jsx"
click node_unpaidui "https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/UnpaidTravels.jsx"
click node_reportsui "https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/Reports.jsx"
click node_api "https://github.com/divit-s07/bus_fee_check/blob/main/backend/server.js"
click node_auth "https://github.com/divit-s07/bus_fee_check/blob/main/backend/middleware/auth.js"
click node_studentops "https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/student.controller.js"
click node_faceflow "https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/face.controller.js"
click node_receiptflow "https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/receipt.controller.js"
click node_ocr "https://github.com/divit-s07/bus_fee_check/blob/main/backend/services/receipt.service.js"
click node_travelops "https://github.com/divit-s07/bus_fee_check/blob/main/backend/services/travel.service.js"
click node_reporting "https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/report.controller.js"
click node_realtime "https://github.com/divit-s07/bus_fee_check/blob/main/backend/sockets/index.js"
click node_faceclient "https://github.com/divit-s07/bus_fee_check/blob/main/backend/services/faceAI.service.js"
click node_faceai "https://github.com/divit-s07/bus_fee_check/blob/main/ai-service/main.py"
click node_records "https://github.com/divit-s07/bus_fee_check/tree/main/backend/models"

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_webapp,node_studentsui,node_facescanui,node_travelui,node_unpaidui,node_reportsui toneBlue
class node_api,node_auth,node_studentops,node_faceflow,node_receiptflow,node_ocr,node_travelops,node_reporting,node_realtime,node_faceclient,node_mongodb toneAmber
class node_faceai toneMint
class node_records toneRose
class node_admin,node_ocrfiles toneIndigo
```

## Components

### Admin application

- [React app](https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Student management](https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/Students.jsx): `frontend/src/pages/Students.jsx`
- [Face scan](https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/FaceScan.jsx): `frontend/src/pages/FaceScan.jsx`
- [Travel views](https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/TravelRecords.jsx): `frontend/src/pages/TravelRecords.jsx`
- [Unpaid alerts](https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/UnpaidTravels.jsx): `frontend/src/pages/UnpaidTravels.jsx`
- [Reports and dashboard](https://github.com/divit-s07/bus_fee_check/blob/main/frontend/src/pages/Reports.jsx): `frontend/src/pages/Reports.jsx`

### API and domain

- [Express API](https://github.com/divit-s07/bus_fee_check/blob/main/backend/server.js): `backend/server.js`
- [JWT and role checks](https://github.com/divit-s07/bus_fee_check/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Student and bus admin](https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/student.controller.js): `backend/controllers/student.controller.js`
- [Scan and fee decision](https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/face.controller.js): `backend/controllers/face.controller.js`
- [Receipt OCR workflow](https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/receipt.controller.js): `backend/controllers/receipt.controller.js`
- [Receipt extraction](https://github.com/divit-s07/bus_fee_check/blob/main/backend/services/receipt.service.js): `backend/services/receipt.service.js`
- [Travel services](https://github.com/divit-s07/bus_fee_check/blob/main/backend/services/travel.service.js): `backend/services/travel.service.js`
- [Reports and analytics](https://github.com/divit-s07/bus_fee_check/blob/main/backend/controllers/report.controller.js): `backend/controllers/report.controller.js`
- [Socket events](https://github.com/divit-s07/bus_fee_check/blob/main/backend/sockets/index.js): `backend/sockets/index.js`
- [AI HTTP client](https://github.com/divit-s07/bus_fee_check/blob/main/backend/services/faceAI.service.js): `backend/services/faceAI.service.js`

### Face recognition

- [Local face matching](https://github.com/divit-s07/bus_fee_check/blob/main/ai-service/main.py): `ai-service/main.py`

### Persistent records

- [Domain records](https://github.com/divit-s07/bus_fee_check/tree/main/backend/models): `backend/models`

### Other components

- **College admin**
- **MongoDB**
- **Uploaded receipts**

## Connections

- College admin → React app: uses (evidence: `README.md`)
- React app → Student management: routes to (evidence: `frontend/src/App.jsx`)
- React app → Face scan: routes to (evidence: `frontend/src/App.jsx`)
- React app → Travel views: routes to (evidence: `frontend/src/App.jsx`)
- React app → Unpaid alerts: routes to (evidence: `frontend/src/App.jsx`)
- React app → Reports and dashboard: routes to (evidence: `frontend/src/App.jsx`)
- React app → Express API: calls (evidence: `README.md`)
- Student management → Express API: requests data (evidence: `frontend/src/pages/Students.jsx`)
- Express API → JWT and role checks: verifies requests
- Express API → Student and bus admin: routes requests (evidence: `backend/server.js`)
- Student and bus admin → Domain records: reads and writes (evidence: `backend/controllers/student.controller.js`)
- Face scan → Express API: sends scan (evidence: `README.md`)
- Express API → Scan and fee decision: routes scan
- Scan and fee decision → AI HTTP client: requests match (evidence: `backend/controllers/face.controller.js`)
- AI HTTP client → Local face matching: sends image
- Local face matching → MongoDB: reads students (evidence: `README.md`)
- Scan and fee decision → Domain records: reads and writes (evidence: `backend/controllers/face.controller.js`)
- Scan and fee decision → Socket events: emits events (evidence: `backend/controllers/face.controller.js`)
- Receipt OCR workflow → Receipt extraction: extracts receipt (evidence: `backend/controllers/receipt.controller.js`)
- Receipt OCR workflow → Domain records: updates students (evidence: `backend/controllers/receipt.controller.js`)
- Receipt OCR workflow → Uploaded receipts: reads uploads (evidence: `backend/controllers/receipt.controller.js`)
- Travel services → Domain records: reads and writes (evidence: `backend/services/travel.service.js`)
- Travel services → Socket events: emits events (evidence: `backend/services/travel.service.js`)
- Reports and dashboard → Express API: requests summaries
- Express API → Reports and analytics: routes reports
- Unpaid alerts → Express API: requests unpaid trips
- Socket events → Travel views: pushes updates
- Domain records → MongoDB: persists in
