A production-grade, multi-role pharmacy e-commerce web application built with Next.js 16, React 19, and a unified light pharmacy design system β featuring real-time order tracking, multi-warehouse fulfillment dashboards, and role-based navigation.
- Overview
- Tech Stack
- Design System
- Application Architecture
- User Roles & Dashboard Routes
- System Workflow
- Page Reference
- Getting Started
- Environment Variables
- Project Structure
- API Integration
MediStore Frontend is a Next.js 15 App Router application that serves four distinct user roles β Customer, Seller, Admin, and Warehouse Manager β each with a fully isolated, role-specific dashboard. The app features a public-facing pharmacy storefront, AI chatbot, real-time order tracking, multi-seller cart checkout, and a complete warehouse operations suite.
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| UI Library | React 19 |
| Language | TypeScript |
| Styling | Vanilla CSS (custom design system via globals.css) |
| Animations | Framer Motion |
| Icons | React Icons (Font Awesome 6 set) |
| Notifications | Sonner (toast notifications) |
| Auth | Better Auth (session cookies, credentials: include) |
| Maps/Geo | GPS coordinate picker (custom) |
| Charts | Recharts |
| PDF Viewer | PDF.js / Cloudinary proxy |
| HTTP | Native fetch with credentials: include |
All pages share a unified Light Pharmacy Theme defined in globals.css.
| Token | Hex | Usage |
|---|---|---|
| Navy | #1B3A5C |
Primary headings, key data |
| Amber | #C2703A |
CTAs, prices, highlights |
| Steel Blue | #3A6EA5 |
Info states, links |
| Cream | #F5EDE3 |
Page backgrounds, soft containers |
| Warm Tan | #8A6650 |
Secondary text, labels |
| Border | #DDD0C4 |
Card borders, dividers |
| Green | #2E7D32 |
Success, delivered, credits |
| Sky Blue | #0EA5E9 |
Dispatch, active states |
| Purple | #7C3AED |
In-transit, packing states |
.medi-page /* Page wrapper β cream background, max-width, padding */
.medi-card /* White card β rounded-2xl, border, subtle shadow */- Stat Grid β
2Γ4metric cards at top of every dashboard page - Filter Pill Tabs β Rounded pill buttons with live counts
- Status Badges β Color-coded
px-3 py-1 rounded-fullpills - Gradient Card Headers β
linear-gradient(90deg, {color}10, #FFF) - Status Hint Bar β Thin colored bar below card header
- Expandable Rows β Framer Motion
height: 0 β autoanimations - Action Footer β Sticky bottom row with CTA buttons
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MediStore Frontend β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Public Routes β β
β β / (home) Β· /medicines Β· /blogs Β· /about Β· /auth β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Role-Based Dashboard β β
β β β β
β β /dashboard/customer/* β Customer portal β β
β β /dashboard/seller/* β Seller portal β β
β β /dashboard/admin/* β Admin control panel β β
β β /dashboard/warehouse/* β WMS operations β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Next.js API Routes (/api/*) β β
β β Proxy β Backend (localhost:4000) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Page | Route | Purpose |
|---|---|---|
| Overview | /customer (index) |
Stats: orders, wallet, wishlist |
| Orders | /customer/orders |
Order history list |
| Tracking | /customer/tracking |
Real-time multi-seller journey tracker |
| Cart | /customer/cart |
Cart management |
| Checkout | /customer/checkout |
Address, coupon, payment |
| Wallet | /customer/wallet |
Balance, transactions |
| Prescriptions | /customer/prescription |
Upload & track prescriptions |
| Wishlist | /customer/wishlist |
Saved medicines |
| Returns | /customer/returns |
Return request form & history |
| Coupons | /customer/coupons |
Available discount codes |
| Search | /customer/search |
Medicine search with filters |
| Notifications | /customer/notifications |
In-app alerts |
| Subscription | /customer/subscription |
Premium plan management |
| Support | /customer/support |
Contact form |
| Profile | /customer/profile |
Account settings |
| Page | Route | Purpose |
|---|---|---|
| Overview | /seller (index) |
Revenue, orders, stock KPIs |
| Medicines | /seller/medicines |
Medicine listing management |
| Add Medicine | /seller/addMedicine |
Upload new medicine with image |
| Edit Medicine | /seller/updateMedicine |
Edit existing listing |
| Catalog | /seller/catalog |
Full product catalog view |
| Orders | /seller/orders |
Incoming order management |
| Batches | /seller/batches |
Lot/batch tracking with expiry |
| Stock Alerts | /seller/stock-alerts |
Low-stock notifications |
| Flash Sales | /seller/flash-sale |
Time-limited discount campaigns |
| Coupons | /seller/coupons |
Seller-specific coupon codes |
| Wallet | /seller/wallet |
Earnings, withdrawal requests |
| Returns | /seller/returns |
Return requests management |
| License | /seller/license |
Pharmacy license upload & status |
| Subscription | /seller/subscription |
Seller plan management |
| Analytics | /seller/analytics |
Sales trends, revenue charts |
| Notifications | /seller/notifications |
Alerts from admin/system |
| Profile | /seller/profile |
Seller account settings |
| Page | Route | Purpose |
|---|---|---|
| Overview | /admin (index) |
Platform-wide KPIs |
| Users | /admin/users |
User management, role assignment |
| Orders | /admin/orders |
All orders across platform |
| Medicines | /admin/featured-products |
Featured product curation |
| Categories | /admin/categories |
Medicine category management |
| License | /admin/license |
Seller license review & approval |
| Prescription | /admin/prescription |
Prescription verification queue |
| Flash Sales | /admin/flash-sale |
Flash sale approval |
| Coupons | /admin/coupons |
Platform-wide coupon management |
| Banners | /admin/banners |
Homepage banner CMS |
| Blogs | /admin/blogs |
Health article CMS |
| Testimonials | /admin/testimonials |
Customer testimonial management |
| Platform Features | /admin/platform-features |
Feature highlight cards CMS |
| Warehouses | /admin/warehouses |
Warehouse creation & manager assignment |
| Returns | /admin/returns |
Return request approvals |
| Payouts | /admin/payouts |
Seller withdrawal approvals |
| Wallet | /admin/wallet |
Wallet oversight |
| Newsletter | /admin/newsletter |
Subscriber management |
| Messages | /admin/messages |
Contact form inbox |
| Support | /admin/support |
Support ticket management |
| Fraud Flags | /admin/fraud-flags |
Suspicious activity review |
| Audit Logs | /admin/audit-logs |
System audit trail |
| Settings | /admin/platform-settings |
Global platform configuration |
| Profile | /admin/profile |
Admin account settings |
| Page | Route | Purpose |
|---|---|---|
| Overview | /warehouse/overview |
Warehouse KPIs β pending, packed, dispatched counts |
| Orders | /warehouse/orders |
Incoming order queue with status breakdown |
| Routing | /warehouse/routing |
Shipment leg management β receive from sellers, route legs |
| Packing | /warehouse/packing |
Pick & pack β stage per-seller packages, create packing slip |
| Dispatch | /warehouse/dispatch |
Dispatch packed orders, confirm customer delivery |
| Fulfillment | /warehouse/fulfillment |
Delivery history archive with seller credit timeline |
| Inventory | /warehouse/inventory |
Stock levels, search, medicine tracking |
| Locations | /warehouse/locations |
Warehouse location/zone management |
| Bins | /warehouse/bins |
Storage bin allocation |
| Analytics | /warehouse/analytics |
Operational performance charts |
| Expiry | /warehouse/expiry |
Expiry date monitoring & alerts |
| Temperature | /warehouse/temperature |
Cold chain temperature logging |
| Profile | /warehouse/profile |
Warehouse manager account |
[Public Storefront]
Browse Medicines β Add to Cart β Apply Coupon
β
[Checkout]
Enter Address (GPS picker) β Select Payment Method
SSLCommerz / Wallet β Order Placed
β
[Customer Tracking: /customer/tracking]
Per-seller journey visualization:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Order Placed β Seller Processing β Seller Shipped β
β β At Origin WH β In Transit β At Dest WH β
β β Packing β Out for Delivery β Delivered β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Animated progress bar + per-milestone timestamps
[/warehouse/routing]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β SELLER_PREPARING β
β β β
β AWAITING_ORIGIN_WH βββββββββββββββββββββββββββββββ β
β β β β
β [Same WH?] ββYesβββΊ AT_DEST_WH (skip transit) β β
β βNo β β
β [Receive from Seller] β β
β β β β
β AT_ORIGIN_WH β β
β β β β
β [Dispatch to Dest WH] β β
β β β β
β IN_TRANSIT β β
β β β β
β [Confirm Arrival] β β
β β β β
β AT_DEST_WH βββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
[/warehouse/packing]
FulfillmentTask: PENDING β CONSOLIDATING
Worker clicks "Mark Received" per seller package
All packages received? β "Create Packing Slip" β PICKED
β
[/warehouse/dispatch]
PACKED β "Dispatch to Customer" β DISPATCHED
"Mark Customer Received" β DELIVERED
β Auto-credit seller wallets β
β
[/warehouse/fulfillment]
Read-only history β seller credits shown per order
Routing Page Card (sameWH = true):
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β π¬ Same Warehouse β No Transit β
β Dhaka WH Β· Seller ships β Receive β Pick & Packβ
β β
β [π Receive from Seller β Pick & Pack] β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β (one click)
Packing page shows the order immediately
- Fetches
GET /api/orders/myincludingsubOrders,shipmentLeg,fulfillmentTask - Per-seller
deriveJourney()maps live status into 9 visual timeline steps - Animated progress bar with % milestones (3% β 100%)
- Expandable per-seller panels with warehouse route summary
- Delivered orders show green "π All sellers paid" banner
- Fetches
GET /api/shipment-legs/minefor warehouse manager's legs - Detects
sameWH = originWarehouseId === destWarehouseId - Same-WH: Single action β "Receive from Seller β Pick & Pack" (amber)
- Multi-WH: Origin actions: Confirm Receipt β Dispatch; Dest actions: Confirm Arrival
- Tab filters: All / Incoming / Ready to Dispatch / In Transit / Arrived
- Fetches fulfillment tasks with status
CONSOLIDATINGorPICKED - Per-seller staging rows with individual "π₯ Mark Received" buttons
- Progress bar shows
received / totallegs - "π¦ Create Packing Slip" button unlocks when all legs are
AT_DEST_WH
- Fetches tasks with status
PACKEDorDISPATCHED - Filter pills: All / Ready / Dispatched
- "Dispatch to Customer" (sky blue) β "Mark Customer Received" (green)
- Shows all seller credits on delivery confirmation
- Read-only archive of
DELIVEREDtasks (newest first) - Stat grid: delivered count, total revenue, sellers paid, warehouses
- Expandable order tracking timeline with dot connector
- Node.js β₯ 18
- MediStore Backend running on
http://localhost:4000
# Clone the repository
git clone <repo-url>
cd mediStore_frontend
# Install dependencies
npm install
# Start development server
npm run devThe app runs on http://localhost:3000
npm run dev # Start Next.js dev server with hot reload
npm run build # Production build (TypeScript checked)
npm run start # Serve production build
npm run lint # ESLint checkCreate a .env.local file in the project root:
# Backend API base URL
NEXT_PUBLIC_API_URL=http://localhost:4000
# Better Auth
BETTER_AUTH_SECRET="same-secret-as-backend"
BETTER_AUTH_URL="http://localhost:3000"
# Next.js
NEXTAUTH_URL=http://localhost:3000Note: All API calls use relative
/api/*paths β Next.js rewrites proxy to the backend. NoNEXT_PUBLIC_API_URLneeded for browser-side calls.
mediStore_frontend/
βββ src/
β βββ app/
β β βββ (public)/ # Public storefront pages
β β β βββ page.tsx # Homepage (banners, flash sales, medicines)
β β β βββ medicines/ # Browse all medicines
β β β βββ blogs/ # Health articles
β β β βββ about/ # About page
β β β βββ auth/ # Login / Register
β β β
β β βββ dashboard/
β β β βββ page.tsx # Dashboard landing / role redirect
β β β βββ layout.tsx # Sidebar + header shell
β β β β
β β β βββ (commonRoute)/ # Shared across roles
β β β β βββ notifications/
β β β β
β β β βββ (roleBasedRoute)/
β β β βββ customer/ # 14 customer pages
β β β β βββ tracking/ # β Real-time order journey
β β β β βββ cart/
β β β β βββ checkout/
β β β β βββ ...
β β β β
β β β βββ seller/ # 17 seller pages
β β β β βββ addMedicine/
β β β β βββ flash-sale/
β β β β βββ ...
β β β β
β β β βββ admin/ # 23 admin pages
β β β β βββ license/ # β PDF viewer with Cloudinary proxy
β β β β βββ warehouses/
β β β β βββ ...
β β β β
β β β βββ warehouse/ # 13 warehouse pages
β β β βββ routing/ # β Shipment leg management
β β β βββ packing/ # β Pick & pack workflow
β β β βββ dispatch/ # β Dispatch & deliver
β β β βββ fulfillment/ # β Delivery history
β β β βββ ...
β β β
β β βββ api/ # Next.js API route handlers
β β βββ globals.css # Design system tokens + medi-page/medi-card
β β βββ layout.tsx # Root layout (Sonner, fonts)
β β βββ not-found.tsx # Custom 404
β β
β βββ components/ # Shared UI components
β βββ Sidebar/
β βββ Header/
β βββ ...
β
βββ public/ # Static assets
βββ package.json
All data fetching uses the browser's native fetch API with credentials: include to pass session cookies:
// Standard pattern used across all warehouse/customer pages
const res = await fetch("/api/fulfillment/my-queue", {
credentials: "include",
});
const data = await res.json();| Frontend Page | API Endpoint |
|---|---|
| Customer tracking | GET /api/orders/my |
| Warehouse routing | GET /api/shipment-legs/mine |
| Warehouse packing | GET /api/fulfillment/my-queue |
| Warehouse dispatch | GET /api/fulfillment/my-queue |
| Fulfillment history | GET /api/fulfillment/my-queue |
| Confirm receipt (seller) | PATCH /api/shipment-legs/:id/receive-at-origin |
| Dispatch inter-WH | PATCH /api/shipment-legs/:id/dispatch |
| Confirm dest arrival | PATCH /api/shipment-legs/:id/receive-at-dest |
| Mark item received | PATCH /api/fulfillment/:id/receive-item |
| Create packing slip | PATCH /api/fulfillment/:id/pack |
| Dispatch to customer | PATCH /api/fulfillment/:id/dispatch |
| Mark delivered | PATCH /api/fulfillment/:id/deliver |
The project uses a custom CSS design system (medi-page, medi-card) via globals.css to maintain full control over the pharmacy-themed aesthetics including warm cream backgrounds, navy headings, and amber CTAs β without the overhead of purging or configuration.
All card expansions, page transitions, and status animations use Framer Motion for smooth height: 0 β auto animations that maintain layout stability without JavaScript hacks.
Better Auth sessions are stored in HTTP-only cookies. All API calls use credentials: include to send these cookies. No JWT tokens are stored in localStorage.
The frontend detects originWarehouseId === destWarehouseId per shipment leg and renders a simplified "one-click receive" UI, bypassing the multi-step routing flow entirely.
MIT Β© MediStore Team