You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A production-grade, multi-role pharmacy e-commerce backend built with Node.js, Express, Prisma ORM, and PostgreSQL — featuring a fully integrated multi-warehouse fulfillment system.
MediStore is a full-featured online pharmacy platform that supports multi-seller listings, prescription management, flash sales, wallet payments, and a sophisticated multi-warehouse fulfillment pipeline. Orders placed by customers are intelligently routed through the nearest warehouse using GPS-based geo-resolution, consolidated from multiple sellers, packed, and dispatched for delivery.
Customer selects medicines → Cart → Checkout
→ Nearest destination warehouse resolved via GPS / district name
→ Per-seller sub-orders created
→ Per-seller shipment legs created (originWH = seller's nearest WH, destWH = customer's nearest WH)
→ Wallet / SSLCommerz payment processed
2. Same-Warehouse (Fast Path)
originWH === destWH
→ Leg status: AWAITING_ORIGIN_WH
→ Warehouse receives from seller → status: AT_DEST_WH (direct skip)
→ FulfillmentTask created immediately
→ Proceeds to Pick & Pack
3. Multi-Warehouse (Transit Path)
originWH ≠ destWH
→ Leg: AWAITING_ORIGIN_WH → AT_ORIGIN_WH → IN_TRANSIT → AT_DEST_WH
→ FulfillmentTask created when first leg arrives
→ Workers stage packages as each seller's leg arrives
Warehouse Fulfillment Workflow
┌──────────────────────────────────────────────────────────────────────┐
│ Warehouse Fulfillment Pipeline │
│ │
│ [/routing] │
│ Seller ships ──► Confirm Receipt (origin WH) │
│ │ │
│ Same WH? ──Yes──► AT_DEST_WH (skip transit) │
│ │No │
│ Dispatch to dest WH │
│ │ │
│ Confirm Arrival at dest WH │
│ │ │
│ AT_DEST_WH + FulfillmentTask created │
│ │
│ [/packing] │
│ Mark each seller's package RECEIVED (per leg) │
│ All legs received? ──► Create Packing Slip (PICKED) │
│ │ │
│ [/dispatch] │
│ PACKED ──► Dispatch to Customer (DISPATCHED) │
│ ──► Customer Receives → DELIVERED │
│ │ │
│ Auto-credit each seller wallet │
│ │
│ [/fulfillment] (history archive) │
│ Read-only log of all DELIVERED orders + timeline │
└──────────────────────────────────────────────────────────────────────┘
# Clone the repository
git clone <repo-url>cd mediStore_backend
# Install dependencies
npm install
# Generate Prisma client
npx prisma generate
# Push schema to database
npx prisma db push
# Start development server
npm run dev
Development Scripts
npm run dev # Start with ts-node-dev (hot reload)
npm run build # Compile TypeScript to dist/
npm run start # Run compiled output
npm run seed # Seed initial data
Utility Scripts
# Clear all transactional data (keep users + medicines)
npx ts-node clear-orders.ts
# Count records per model
npx ts-node count.ts