Architecture & Detailed Implementation
HostelBites is designed as a decoupled, multi-client monorepo structure communicating with a unified backend API:
- Backend Service (
backend/): Node.js and Express.js REST API providing secure JWT authentication, role-based authorization (Customer, Store, Delivery, Admin), database management, and Webhook processing. - Frontend Applications (
frontend/):- Customer App (
frontend/customer): Allows students to browse canteen menus, place orders, make online payments, and track deliveries in real-time. - Store App (
frontend/store): Enables canteen owners to manage active orders, update menu listings, and verify rider pickups. - Delivery Partner App (
frontend/delivery): Enables student riders to view available orders matching their campus and gender, navigate, and verify deliveries. - Admin Dashboard (
frontend/admin): Gives campus administrators complete control over user roles, merchant settings, and platform configuration.
- Customer App (
+---------------------------------------+
| Nginx Reverse Proxy |
+---------------------------------------+
/ | \ \
/ | \ \
(Port 5300) (Port 5302) (Port 5303) (Port 5301)
v v v v
+----------+ +-----------+ +----------+ +----------+
| Customer | | Store | | Delivery | | Admin |
| PWA | | PWA | | PWA | | Dashboard|
+----------+ +-----------+ +----------+ +----------+
\ | / /
\ | / /
+--> [Node.js / Express API] <-----+
(Port 5000 / PM2)
|
v
[MongoDB Atlas]
Key Security & Logic Implementations
- Dual OTP Handshake Verification:
- Pickup Stage: The canteen owner generates a verification OTP which must be entered by the delivery rider to authorize order pickup.
- Delivery Stage: The delivery rider generates a verification OTP which must be entered by the customer to confirm delivery.
- Security: Prevents unauthorized order pickups and fraudulent delivery claims.
- Gender-Sensitive Delivery Filters:
To respect hostel security rules, male riders are automatically filtered out from accepting deliveries bound for girls' hostels, while female riders have full access. - Razorpay Webhook Integration:
Configured secure Webhook endpoints (/api/v1/payment/webhook) with signature verification (Razorpay.validateWebhookSignature) to handle asynchronous payment success (payment.captured) and ensure orders are never processed without successful capture. - Rate Limiting & Safety:
Added API rate limiting on OTP generation and wallet withdrawal requests. Account actions are blocked after 3 consecutive invalid OTP attempts.
