How sheronjay/supply-chain-management-sys works
Purpose and Top-Level Entry Points
Supply Chain Management System is a React/Vite single-page application backed by an Express API and MySQL. It supports supply-chain operations across orders, stores, drivers, train schedules, users, reports, alerts, and role-specific dashboards. Runtime entry points are frontend/src/main.jsx, frontend/src/App.jsx, backend/src/index.js, and backend/src/app.js.
Client Application and Navigation
The frontend is a Vite React SPA. frontend/src/App.jsx defines application composition/routing, while frontend/src/context/AuthContext.jsx provides shared authentication state. Role-aware navigation and access boundaries are implemented through frontend/src/components/ProtectedRoute/ProtectedRoute.jsx, frontend/src/components/EmployeeRedirect/EmployeeRedirect.jsx, and frontend/src/components/DashboardLayout/DashboardLayout.jsx.
API Boundary and Request Pipeline
Express is the server-side boundary between the SPA and persisted operational data. backend/src/app.js configures the application and route mounting; backend/src/index.js starts the HTTP process. API endpoints are grouped by domain, including backend/src/routes/auth.routes.js, backend/src/routes/order.routes.js, and backend/src/routes/storeManager.routes.js. Middleware enforces authentication, validation, and centralized failures through backend/middleware/auth.middleware.js, backend/middleware/validation.middleware.js, and backend/middleware/errorHandler.js.
Domain Controllers and Services
Controllers translate HTTP requests into domain actions; services contain the operational/data-access layer. Major domains include authentication/users (backend/src/controllers/auth.controller.js, backend/services/auth.service.js, backend/services/users.service.js), orders (backend/src/controllers/order.controller.js, backend/services/order.service.js, backend/models/order.model.js), and fulfillment/store operations (backend/src/controllers/storeManager.controller.js, backend/src/controllers/mainStores.controller.js, backend/services/storeManager.service.js). Additional workflow domains cover drivers, locations, alerts, reports, and train schedules.
Operational Workflows
Order fulfillment spans customer/user order views, main-store pending-order processing, store manager assignment/inventory views, and driver assignments. Relevant UI stages are frontend/src/pages/Orders/Orders.jsx, frontend/src/pages/MainStores/MainStores.jsx, and frontend/src/pages/StoreManager/StoreManager.jsx; supporting server domains include backend/services/order.service.js, backend/services/driver.service.js, and backend/services/location.service.js. Train scheduling and alerts are separate operational capabilities exposed by frontend/src/pages/TrainSchedule/TrainSchedule.jsx, backend/services/trainSchedule.service.js, and backend/services/alert.service.js.
Frontend Data Consumption and Presentation
Frontend service modules form the client API boundary, separating pages/components from HTTP calls: frontend/src/services/api.js, frontend/src/services/authService.js, and frontend/src/services/storeManagerService.js. Dashboard and reporting aggregate operational data for visualization and exports/actions through frontend/src/pages/Dashboard/Dashboard.jsx, frontend/src/pages/ReportOverview/ReportOverview.jsx, and frontend/src/services/reportService.js.
Infrastructure and Delivery
MySQL is the durable system of record, initialized from docker/init.sql and connected by backend/src/db/pool.js. docker-compose.yml runs MySQL on host port 3307 and Adminer on port 8080. Development runs Express (default 3000) and Vite (default 5173), with frontend API proxying. Containerization is defined in backend/Dockerfile and frontend/Dockerfile; CI/build and deployment workflows reside in .github/workflows/build.yml and .github/workflows/deploy.yml.
Main entry points: order.routes.js Domain routes · pool.js MySQL · App.jsx App routing · app.js Express app
Components 19
React SPA
- Vite entry
frontend/src/main.jsx - App routing
frontend/src/App.jsx - Auth state
frontend/src/context/AuthContext.jsx - Role access · Protected routes, employee redirects, and dashboard layout.
frontend/src/components/ProtectedRoute/ProtectedRoute.jsx - Client API services · Shared API, auth, store-manager, and report requests.
frontend/src/services/api.js - Fulfillment UI · Orders, main stores, and store manager workflows.
frontend/src/pages/Orders/Orders.jsx - Dashboard & reports
frontend/src/pages/Dashboard/Dashboard.jsx
Express API
- HTTP server
backend/src/index.js - Express app · Configures middleware and mounts domain routes.
backend/src/app.js - Auth, validation & errors · Authentication, request validation, and centralized failure handling.
backend/middleware/auth.middleware.js - Domain routes · Auth, order, and store-manager endpoint groups.
backend/src/routes/order.routes.js
Operational Domains
- Auth & users · Identity and user operations.
backend/src/controllers/auth.controller.js - Order management · Order lifecycle and persistence.
backend/src/controllers/order.controller.js - Store fulfillment · Pending orders, assignments, and inventory views.
backend/src/controllers/storeManager.controller.js - Drivers & locations · Driver assignments and location operations.
backend/services/driver.service.js - Schedules & alerts · Train scheduling and operational alerts.
backend/services/trainSchedule.service.js - Reports
frontend/src/services/reportService.js
Data & Delivery
- MySQL · Initialized from docker/init.sql.
backend/src/db/pool.js - Containers & CI/CD · Compose runs MySQL/Adminer; workflows build and deploy.
docker-compose.yml
Connections 24
- Vite entry → App routing: renders
- App routing → Auth state: uses
- App routing → Role access: applies
- Role access → Fulfillment UI: permits by role
- App routing → Dashboard & reports: routes to
- Fulfillment UI → Client API services: requests through
- Dashboard & reports → Client API services: requests through
- Client API services → Express app: HTTP API
- HTTP server → Express app: starts
- Express app → Auth, validation & errors: enforces
- Express app → Domain routes: mounts
- Domain routes → Auth & users: dispatches
- Domain routes → Order management: dispatches
- Domain routes → Store fulfillment: dispatches
- Order management → Drivers & locations: assigns fulfillment
- Store fulfillment → Drivers & locations: uses assignments
- Domain routes → Schedules & alerts: dispatches
- Domain routes → Reports: serves report data
- Auth & users → MySQL: reads and writes
- Order management → MySQL: persists
- Store fulfillment → MySQL: reads and writes
- Drivers & locations → MySQL: reads and writes
- Schedules & alerts → MySQL: persists
- Containers & CI/CD → MySQL: provisions