A full-stack, production-grade online pharmacy platform built with modern system design principles.
🌐 Live Demo • 📖 API Documentation • 🏗️ Architecture
Important
Demo Note: The production environment is connected to a live staging API. Some transaction features (like real-time delivery tracking) may be simulated for demonstration purposes.
Traditional pharmacy ecosystems often suffer from fragmented inventory, a lack of real-time visibility, and clunky digital experiences that fail both the seller and the customer.
MediStore was engineered to solve these core problems by providing a unified, scalable, and role-driven marketplace. We bridge the gap between healthcare providers and consumers through:
- Real-time Inventory Sync: Eliminating "Out of Stock" surprises during checkout.
- Role-Based Workflows: Tailored interfaces for Customers, Sellers, and Administrators.
- Production-Grade Security: Ensuring patient and transaction data remains encrypted and valid.
MediStore is more than just a storefront; it is a comprehensive healthcare management system designed for three distinct user segments:
- Customers: A premium B2C experience for browsing, comparing, and securely purchasing medicines.
- Sellers: A robust B2B dashboard for inventory management, order fulfillment, and sales analytics.
- Administrators: A governance layer to manage users, verify medicines, and oversee platform health.
The project focuses on Engineering Excellence and Scalable Architecture:
- Multi-Role Architecture: Strict separation of concerns for different user types.
- Stateless API Design: The frontend communicates with a decoupled backend, ensuring the system is ready for horizontal scaling.
- Optimistic UI Logic: Enhanced UX using Zustand for state management, making the interface feel instantaneous during inventory and cart actions.
- Strict API Boundary Enforcement: Every request passes through a centralized validation layer.
| Feature | Customer | Seller | Admin |
|---|---|---|---|
| Browse & Search | ✅ | ✅ | ✅ |
| Inventory Management | ❌ | ✅ | ✅ |
| Order Processing | ❌ | ✅ | ✅ |
| User Governance | ❌ | ❌ | ✅ |
| Profile & History | ✅ | ✅ | ✅ |
MediStore follows a Modern Client-Server decoupling pattern:
graph TD
User["User Browser (Next.js 15)"]
Proxy["Auth Proxy / Middleware"]
API["Express API Gateway"]
DB[(PostgreSQL)]
User -- "1. HTTP Request (Auth Token)" --> Proxy
Proxy -- "2. Validated Request" --> API
API -- "3. Logic & DB Query" --> DB
DB -- "4. Data Payload" --> API
API -- "5. JSON Response" --> User
Our interaction layer is built for speed and transparency. Below is an example of our core authentication flow.
Request:
{
"email": "user@example.com",
"password": "••••••••"
}Response:
| Status | Meaning | Description |
|---|---|---|
200 OK |
সফল লগইন | Session token issued via HTTP-only cookie. |
401 Unauthorized |
ভুল credentials | Invalid email or password provided. |
422 Unprocessable |
Validation Error | Provided data failed Zod schema check. |
- Next.js Server Components (RSC): Drastically reduced client-side JavaScript bundle size.
- Route-Based Code Splitting: Loading only the necessary code for the active route.
- Zustand State Isolation: Preventing unnecessary re-renders in complex UI components (e.g., Dashboards).
- Planned Upgrade: Integration of TanStack Query for advanced caching and background synchronization.
MediStore is designed to grow from MVP to Enterprise:
- Separation of Concerns: Frontend and API layers are completely decoupled.
- Stateless Design: Allows for horizontal scaling of the API layer behind a load balancer.
- Cachable Assets: Edge-ready deployment via Vercel for high-speed content delivery.
- Microservices Ready: Core business logic (Order, Auth, Inventory) is architecturally grouped for potential future extraction.
- HTTP-Only Cookies: Protecting sessions against XSS attacks.
- CSRF Protection: Enforced via SameSite policies and strict origin checking.
- RBAC (Role-Based Access Control): Middleware-level guarding for
/adminand/sellerroutes. - Input Sanitization: Multi-layered validation using Zod to prevent injection attacks.
- Type-Safe APIs: Full TypeScript integration across the boundary ensures zero "undefined" errors.
- Modular Folder Structure: Feature-based organization for high maintainability.
- Reusable UI Primitives: Component library powered by shadcn/ui and Lucide Icons.
- Clean Codebase: ESLint and TypeScript strict mode enforced for consistency.
- Frontend: Vercel (Edge-optimized Next.js Hosting)
- Backend API: Node.js/Express (API Layer)
- Database: PostgreSQL (Relational persistence)
Environment Separation:
Development: Local environment with strict mock capability.Production: High-availability cluster on Vercel and Managed DB.
| Feature | Traditional Pharmacy | MediStore |
|---|---|---|
| Inventory | Manual / Laggy | Real-time Sync |
| Accessibility | Physical / Limited | 24/7 Global Access |
| User Roles | Restricted | Customer / Seller / Admin |
| Security | Paper-based | Encryption & RBAC |
The centralized landing page for the marketplace.
Explore: Real-time filtering and category-based medicine discovery.
Govern: Administrative control panel for user and category management.
Manage: Seller-centric interface for inventory and stock tracking.
Secure Access: Unified login and registration system with role selection.
Order: Streamlined cart and checkout experience with persistent storage.
Responsive: Pixel-perfect layout across desktop, tablet, and mobile.
Insights: Data-driven seller dashboard for tracking sales and growth.
- Node.js (v20.0.0 or higher)
- pnpm (v10.0.0 or higher)
git clone https://github.com/ArnabSaga/Assignment-4-MediStore-Frontend.git
cd MediStore-Frontendpnpm installCreate a .env.local file in the root directory:
NEXT_PUBLIC_API_URL=/api/v1
NEXT_PUBLIC_FRONTEND_URL=http://localhost:3000
BACKEND_URL=http://localhost:5000Authentication is exposed through the frontend origin at /api/auth/* by a
Next.js beforeFiles rewrite to the backend. Browser code should call
same-origin /api/auth/* and /api/v1/* paths, not backend-direct auth URLs.
pnpm dev| Variable | Description | Example |
|---|---|---|
BACKEND_URL |
Server-only backend origin used by Next.js rewrites and API proxies | https://api.medistore.com |
NEXT_PUBLIC_API_URL |
Public API base path | /api/v1 |
NEXT_PUBLIC_FRONTEND_URL |
Public frontend origin used for server-side callback URL construction | https://medistore.example.com |
src/
┣ app/ # App Router (Pages, Layouts, Route Groups)
┃ ┣ (auth)/ # Authentication flows
┃ ┣ (protected)/ # Admin and Seller dashboards
┃ ┗ (public)/ # Storefront, Shop, and Marketing
┣ components/ # Feature-scoped UI components
┃ ┣ auth/ # Authentication UI
┃ ┣ dashboard/ # Management interfaces
┃ ┗ ui/ # shadcn/ui shared primitives
┣ lib/ # API Clients, Zustand Stores, & Utils
┣ hooks/ # Custom React Hooks
┣ providers/ # Context Providers (Theme, Auth)
┗ types/ # Global TypeScript Definitions- Stripe Integration: Online payments and automated billing.
- Real-time Tracking: Live order delivery status via WebSockets.
- AI Recommendations: Personalized medicine suggestions based on history.
- Prescription Hub: Encrypted upload and verification portal.
- Mobile App: Cross-platform React Native companion app.
If this project inspired you or helped your workflow, please consider:
- Starring the repository 🌟
- Forking it to build your own version 🍴
- Sharing feedback or opening a PR 🧠
Let’s build the future of digital healthcare together.
Made with ❤️ by ArnabSaga