Case Study
trendy
An API built with NestJS and PostgreSQL for a multi-role logistics/marketplace platform connecting customers, stores, and drivers. It covers the full order lifecycle from cart to delivery with pickup/drop-off tasks, driver assignment by zone, speed, and availability, real-time notifications, and order status tracking. It includes product catalog management, media assets, reviews, and admin analytics for orders and revenue.
- Multi-role logistics/marketplace API covering the cart-to-delivery flow.
- Driver assignment by zone/speed/availability with task-based pickup and delivery.
- Catalog + media management, Firebase push notifications, and admin analytics.
Stack: NestJS • PostgreSQL • TypeORM • JWT • Cloudinary • Firebase • Docker
Overview
This project is an API for a multi-role logistics/marketplace platform connecting customers, stores, and drivers.
It covers the full order lifecycle from cart to delivery, including pickup/delivery tasks, driver assignment by zone, speed, and availability, real-time notifications, and order status tracking.
It includes product catalog management, media assets, reviews, and admin analytics for orders and revenue.
My Role
- I designed and built the NestJS backend.
- I modeled PostgreSQL using TypeORM.
- I implemented RBAC and auth flows (JWT + Refresh Token via HTTP-only cookie + Google OAuth).
- I implemented the order lifecycle and driver tasks logic.
- I integrated Cloudinary signed uploads and Firebase push notifications.
- I prepared Docker-based staging/production setup and a health endpoint.
Stack
- NestJS (TypeScript)
- PostgreSQL
- TypeORM
- JWT + Refresh Token via HTTP-only cookie + Google OAuth
- Cloudinary signed uploads
- Firebase push notifications
- Docker (staging/production)
- Health endpoint
- External USD-rate API
API Highlights
Auth & Users
- Email signup/login, code verification, and password recovery.
- Google OAuth and Refresh Token via HTTP-only cookie.
- RBAC (admin/seller/driver/customer) with admin user activation.
Catalog
- Hierarchical categories with speedType (fast/slow) affecting delivery speed.
- Products with colors/sizes, return window, and availability.
- Media (images/video) with Cloudinary signed uploads, store logos, and driver photos.
Shopping Experience
- Cart items store a snapshot of the product at purchase time for stable pricing/data.
- Favorites.
- Separate ratings for product/seller/driver (one rating per customer per target).
Orders & Logistics
- Order creation from cart with customer profile validation; delivery speed is inferred from product categories.
- Slow orders require time windows; fast orders have no window.
- Seller-level item confirmation/rejection with a 15-minute window and auto-reject on timeout.
Order statuses
Exceptions
Driver Tasks
- Orders split into PICKUP/DELIVERY tasks.
- Assign the least-busy driver by zone, speed, and availability while preventing overlapping time windows for the same driver.
- Task status updates drive order status, with pickup and delivery confirmation via delivery code.
- Customer and seller tracking.
Notifications
- Device registration and Firebase push notifications.
- Admin broadcast messaging.
Admin Analytics
- Summaries for orders, revenue, and users.
- Top stores and drivers.
- Time-series charts for orders and revenue.
Supporting Services
- External USD-rate API.
- Health endpoint.
- Dockerized staging/production.