How ph-tejas/backend works
This is a blood-donation platform backend: hospitals create requests, the service finds nearby compatible donors, notifies them in real time, and records donor responses or completed donations. Authentication supports both donors and hospitals; separate APIs manage profiles, availability, hospital listings, and emergency requests. MongoDB models hold users, hospitals, and requests, while startup connects the database and seeds sample accounts. The README is empty; relationships below are limited to the sampled source and SOURCE INDEX references.
Main entry points: server.js HTTP and sockets · bloodRequests.js Request matching and response · auth.js Token authentication · User.js Donor records
Components 14
API and startup
- HTTP and sockets
server.js - Database connection
config/database.js - Sample data seeding
start-with-data.js
Identity and profiles
- Registration and login
routes/auth.js - Token authentication
middleware/auth.js - Donor profiles
routes/users.js - Hospital profiles and directory
routes/hospitals.js
Donation workflows
- Request matching and response
routes/bloodRequests.js
Persistence
- Donor records
models/User.js - Hospital records
models/Hospital.js - Blood request records
models/BloodRequest.js
Other components
- Donor
- Hospital
- MongoDB
Connections 25
- Donor → HTTP and sockets: uses API
- Hospital → HTTP and sockets: uses API
- HTTP and sockets → Database connection: connects database
server.js - HTTP and sockets → Registration and login: mounts routes
server.js - HTTP and sockets → Donor profiles: mounts routes
server.js - HTTP and sockets → Hospital profiles and directory: mounts routes
server.js - HTTP and sockets → Request matching and response: mounts routes
server.js - HTTP and sockets → Sample data seeding: seeds data
server.js - Database connection → MongoDB: connects to
config/database.js - Sample data seeding → Donor records: creates records
start-with-data.js - Sample data seeding → Hospital records: creates records
start-with-data.js - Registration and login → Donor records: reads and writes
routes/auth.js - Registration and login → Hospital records: reads and writes
routes/auth.js - Registration and login → Token authentication: checks identity
routes/auth.js - Token authentication → Donor records: looks up donor
middleware/auth.js - Token authentication → Hospital records: looks up hospital
middleware/auth.js - Donor profiles → Token authentication: protects routes
routes/users.js - Donor profiles → Donor records: reads and updates
routes/users.js - Hospital profiles and directory → Token authentication: protects routes
routes/hospitals.js - Hospital profiles and directory → Hospital records: reads and updates
routes/hospitals.js - Request matching and response → Token authentication: protects routes
routes/bloodRequests.js - Request matching and response → Blood request records: creates and updates
routes/bloodRequests.js - Request matching and response → Donor records: matches donors
routes/bloodRequests.js - Request matching and response → Hospital records: loads hospital
routes/bloodRequests.js - Request matching and response → HTTP and sockets: emits notifications
routes/bloodRequests.js