How mohitt-0805/surplus-to-shelter works
FoodRescue connects surplus-food donors, shelters, and couriers through role-based portals, geospatial offer matching, and live dispatch. The main flow is donor posting → shelter offer and decision → courier assignment → delivery and impact reporting. The graph includes auth, persistence, and public impact alongside the three user portals. Some portal and route implementations are unsampled; those branches are shown at their documented or exact tree paths, and only evidenced relationships are linked.
Main entry points: server.js HTTP and socket server · matching.js Spatial matching · App.jsx Role routing · db.js PostgreSQL and PostGIS
Components 20
Web portals
- Donor portal
frontend/src/pages/DonorDashboard.jsx - Shelter portal
frontend/src/pages/RecipientDashboard.jsx - Courier portal
frontend/src/pages/DriverDashboard.jsx - Impact portal
frontend/src/pages/ImpactDashboard.jsx - Login
frontend/src/pages/Login.jsx - Role routing
frontend/src/App.jsx - API client
frontend/src/api.js - Live client
frontend/src/socket.js
API and identity
- HTTP and socket server
backend/server.js - Authentication routes
backend/routes/auth.js - Token and role checks
backend/middleware/auth.js - Donation routes
backend/routes/donations.js - Recipient routes
backend/routes/recipients.js - Driver routes
backend/routes/drivers.js - Impact routes
backend/routes/impact.js
Matching and dispatch
- Spatial matching
backend/services/matching.js - Courier dispatch
backend/services/dispatch.js - Live notifications
backend/services/notifications.js
Persistence and impact
- PostgreSQL and PostGIS
backend/db.js
Other components
- Portal users
Connections 40
- Portal users → Role routing: uses portals
frontend/src/App.jsx - Role routing → Login: routes to
frontend/src/App.jsx - Role routing → Donor portal: routes to
frontend/src/App.jsx - Role routing → Shelter portal: routes to
frontend/src/App.jsx - Role routing → Courier portal: routes to
frontend/src/App.jsx - Role routing → Impact portal: routes to
frontend/src/App.jsx - Login → API client: requests
frontend/src/pages/Login.jsx - Donor portal → API client: requests
frontend/src/pages/DonorDashboard.jsx - Shelter portal → API client: requests
frontend/src/pages/RecipientDashboard.jsx - Courier portal → API client: requests
frontend/src/pages/DriverDashboard.jsx - Impact portal → API client: requests
frontend/src/pages/ImpactDashboard.jsx - Donor portal → Live client: uses live events
frontend/src/pages/DonorDashboard.jsx - Shelter portal → Live client: uses live events
frontend/src/pages/RecipientDashboard.jsx - Courier portal → Live client: uses live events
frontend/src/pages/DriverDashboard.jsx - Impact portal → Live client: uses live events
frontend/src/pages/ImpactDashboard.jsx - API client → HTTP and socket server: HTTP requests
- Live client → HTTP and socket server: opens socket
- HTTP and socket server → Authentication routes: mounts
backend/server.js - HTTP and socket server → Impact routes: mounts
backend/server.js - HTTP and socket server → Donation routes: mounts
backend/server.js - HTTP and socket server → Recipient routes: mounts
backend/server.js - HTTP and socket server → Driver routes: mounts
backend/server.js - HTTP and socket server → Spatial matching: starts timeout cascade
backend/server.js - HTTP and socket server → Spatial matching: sets socket
backend/server.js - HTTP and socket server → Courier dispatch: sets socket
backend/server.js - Authentication routes → PostgreSQL and PostGIS: reads and writes
backend/routes/auth.js - Authentication routes → Token and role checks: uses secret
backend/routes/auth.js - Donation routes → PostgreSQL and PostGIS: reads and writes
backend/routes/donations.js - Donation routes → Spatial matching: invokes matching
backend/routes/donations.js - Recipient routes → PostgreSQL and PostGIS: reads and writes
backend/routes/recipients.js - Recipient routes → Spatial matching: invokes matching
backend/routes/recipients.js - Driver routes → PostgreSQL and PostGIS: reads and writes
backend/routes/drivers.js - Driver routes → Courier dispatch: invokes dispatch
backend/routes/drivers.js - Impact routes → PostgreSQL and PostGIS: reads metrics
backend/routes/impact.js - Spatial matching → PostgreSQL and PostGIS: reads and updates
backend/services/matching.js - Spatial matching → Live notifications: notifies recipient
backend/services/matching.js - Spatial matching → Courier dispatch: assigns after acceptance
backend/services/matching.js - Courier dispatch → PostgreSQL and PostGIS: assigns and records
backend/services/dispatch.js - Courier dispatch → Live notifications: notifies driver
backend/services/dispatch.js - Courier dispatch → Impact routes: feeds delivery metrics