Campus Connect
Campus delivery platform that batches orders into scheduled vendor runs
- Role
- Team lead, 5 engineers
- When
- 2025 - 2026
Overview
Our hostels sit about 100 m uphill from the market, so vendors had to climb once for every order. Campus Connect groups orders into time slots so a vendor makes one trip for many orders, with OTP-verified delivery.
The constraint
Vendors won't make a 100 m climb for a single order, and students won't wait an unknown amount of time for one.
What I built
- 01
Order processing locks the rows it touches inside a PostgreSQL transaction, products in a fixed order to avoid deadlocks, so concurrent checkouts can't oversell stock or double-book a batch.
- 02
A 29-table PostgreSQL schema with targeted indexes keeps common lookups under 50 ms.
- 03
Email and Google sign-in, role-based access for students, vendors and admins, and audit logs for every admin action.
- 04
Slow work (closing batches at their cutoff, notifications, audit logs) runs in BullMQ workers. Live notifications go over Server-Sent Events, and Prometheus and Grafana handle monitoring and alerts.
- 05
The app, worker and migrations ship as separate Docker images; one command brings up the full stack.
Request path
- Next.js
- Nginx
- PostgreSQL (row locks)
- BullMQ workers
- Redis
- SSE
From the code
const productIds = [ ...new Set(cart.items.map((item) => item.product_id)),].sort();await tx.$queryRaw` SELECT id FROM "Product" WHERE id = ANY(${productIds}::text[]) ORDER BY id FOR UPDATE`;Outcome
Stays correct under up to 500 orders a minute, with common lookups under 50 ms. Production-ready, with launch pending vendor onboarding.
- Next.js
- TypeScript
- PostgreSQL
- Redis
- BullMQ
- Docker
- Prometheus
- Grafana
Next project
Alumni Network
Alumni platform for NIT Arunachal Pradesh: directory, mentorship, jobs and events