How akibrahman/medicorx works
MedicoRx is a pharmacy storefront and management system. Customers browse medicines, manage a cart, place cash-on-delivery orders, and track orders and notifications; order creation deducts stock from earliest-expiring batches. Admins manage medicines, inventory, orders, payments, and reports. The graph follows documented route capabilities and sampled handlers; some UI-to-API links are documented rather than shown in sampled page source.
Main entry points: orders/route.js Order placement and listing · dashboard/route.js Admin dashboard API · medicines/route.js Admin medicine API · [id]/route.js Order detail and updates
Components 29
Customer commerce
- Storefront and shop
app/(customer)/shop/page.jsx - Cart state
context/CartContext.jsx - Checkout
app/(customer)/checkout/CheckoutClient.jsx - Order history and detail
app/(customer)/orders/page.jsx - Notifications
app/(customer)/notifications/page.jsx - Public medicine API
app/api/medicines/route.js - Order placement and listing
app/api/orders/route.js - Order detail and updates
app/api/orders/[id]/route.js - Notification API
app/api/notifications/route.js
Identity and access
- Login and registration
app/(auth)/login/page.jsx - Authentication handlers
app/api/auth/login/route.js - Cookie sessions
lib/session.js
Pharmacy operations
- Medicine catalog admin
app/(admin)/medicines/page.jsx - Inventory management
app/(admin)/inventory/page.jsx - Order management
app/(admin)/admin-orders/page.jsx - Dashboard and reports
app/(admin)/dashboard/page.jsx - Admin medicine API
app/api/admin/medicines/route.js - Admin dashboard API
app/api/admin/dashboard/route.js
Persistence and shared state
- MongoDB connection
lib/db.js - Medicine records
models/Medicine.js - Inventory batches
models/Inventory.js - Orders
models/Order.js - Order items
models/OrderItem.js - Transactions
models/Transaction.js - Notifications
models/Notification.js - Users
models/User.js
Other components
- Customer
- Admin
- MongoDB
Connections 40
- Customer → Storefront and shop: browses
README.md - Storefront and shop → Public medicine API: requests listings
- Public medicine API → Medicine records: aggregates
app/api/medicines/route.js - Public medicine API → Inventory batches: joins stock
app/api/medicines/route.js - Customer → Cart state: manages items
README.md - Storefront and shop → Cart state: adds medicines
app/(customer)/shop/page.jsx - Cart state → Checkout: supplies cart
app/(customer)/checkout/CheckoutClient.jsx - Customer → Checkout: places order
README.md - Checkout → Order placement and listing: submits order
README.md - Order placement and listing → Cookie sessions: checks session
app/api/orders/route.js - Order placement and listing → Orders: creates order
app/api/orders/route.js - Order placement and listing → Order items: creates items
app/api/orders/route.js - Order placement and listing → Inventory batches: deducts FIFO stock
app/api/orders/route.js - Order placement and listing → Transactions: creates transaction
app/api/orders/route.js - Order placement and listing → Notifications: creates confirmation
app/api/orders/route.js - Customer → Login and registration: signs in
README.md - Login and registration → Authentication handlers: authenticates
- Authentication handlers → Cookie sessions: sets session
- Order history and detail → Order placement and listing: lists orders
- Order history and detail → Order detail and updates: loads details
- Order detail and updates → Orders: reads and updates
app/api/orders/[id]/route.js - Order detail and updates → Order items: loads items
app/api/orders/[id]/route.js - Order detail and updates → Transactions: loads payment
app/api/orders/[id]/route.js - Notifications → Notification API: loads notifications
- Notification API → Notifications: reads notifications
app/api/notifications/route.js - Admin → Medicine catalog admin: manages catalog
README.md - Admin → Inventory management: manages stock
README.md - Admin → Order management: manages orders
README.md - Admin → Dashboard and reports: reviews metrics
README.md - Medicine catalog admin → Admin medicine API: maintains catalog
- Admin medicine API → Cookie sessions: checks role
app/api/admin/medicines/route.js - Admin medicine API → Medicine records: creates and lists
app/api/admin/medicines/route.js - Admin medicine API → Inventory batches: creates stock batch
app/api/admin/medicines/route.js - Inventory management → Admin medicine API: manages batches
- Dashboard and reports → Admin dashboard API: requests metrics
- Admin dashboard API → Cookie sessions: checks role
app/api/admin/dashboard/route.js - Admin dashboard API → Orders: calculates sales
app/api/admin/dashboard/route.js - Admin dashboard API → Medicine records: reads catalog
app/api/admin/dashboard/route.js - Admin dashboard API → Inventory batches: finds stock alerts
app/api/admin/dashboard/route.js - MongoDB connection → MongoDB: connects
lib/db.js