How ryfless/sparetrack works
SpareTrack is a multi-branch spare-parts inventory system. A user enters through the React application, authenticates, and uses its operational pages; frontend API services send requests to Express, whose routes and controllers delegate inventory, transactions, reporting, and restock work to services backed by Supabase. In parallel, the ML service builds demand features from Supabase data, trains XGBoost, and serves forecasts used for restock recommendations. The README documents additional product capabilities; only relationships visible in excerpts or the README are drawn, so some subsystem connections remain unverified.
Main entry points: supabase.js Supabase client · api.py Forecast API · main.py ML runtime · App.tsx React application
Components 23
Web application
- React application
frontend/src/app/App.tsx - Auth pages
frontend/src/app/pages/auth - Operational pages
frontend/src/app/pages/app - API client
frontend/src/app/services/client.ts
REST backend
- Express API
backend/src/app.js - API routes
backend/src/routes/index.js - Auth controller
backend/src/controllers/authController.js - Auth service
backend/src/services/authService.js - Inventory controller
backend/src/controllers/inventoryController.js - Restock controller
backend/src/controllers/restockController.js - Supabase client
backend/src/config/supabase.js
Inventory operations
- Inventory service
backend/src/services/inventoryService.js - Restock and PO service
backend/src/services/restockService.js - Reports service
backend/src/services/reportsService.js - Transaction services
backend/src/services/transactionsService.js - Notifications
backend/src/services/notificationService.js
Demand forecasting
- Demand data features
inventory_ml/models/data.py - XGBoost model
inventory_ml/models/xgboost.py - Forecast API
inventory_ml/api.py - ML runtime
inventory_ml/main.py - ML dashboard
inventory_ml/dashboard/app.js
Other components
- Store user
- Supabase database
Connections 32
- Store user → React application: uses
- React application → Auth pages: presents
frontend/src/app/App.tsx - React application → Operational pages: routes to
frontend/src/app/App.tsx - Auth pages → API client: requests
- Operational pages → API client: requests
- React application → API client: updates theme
frontend/src/app/App.tsx - API client → Express API: REST requests
- Express API → API routes: mounts
backend/src/app.js - API routes → Auth controller: routes auth
- API routes → Inventory controller: routes inventory
- API routes → Restock controller: routes restock
- Express API → Auth controller: handles profile
backend/src/app.js - Auth controller → Auth service: delegates auth
backend/src/controllers/authController.js - Auth service → Supabase client: reads and writes
backend/src/services/authService.js - Inventory controller → Inventory service: delegates inventory
backend/src/controllers/inventoryController.js - Restock controller → Restock and PO service: delegates restock
backend/src/controllers/restockController.js - Inventory service → Supabase client: reads and writes
backend/src/services/inventoryService.js - Restock and PO service → Supabase client: reads and writes
backend/src/services/restockService.js - Inventory service → Notifications: triggers
backend/src/services/inventoryService.js - Restock and PO service → Notifications: triggers
backend/src/services/restockService.js - Reports service → Supabase client: queries data
backend/src/services/reportsService.js - Transaction services → Supabase client: persists records
- Supabase client → Supabase database: accesses
backend/src/config/supabase.js - ML runtime → Demand data features: fetches features
inventory_ml/main.py - ML runtime → XGBoost model: trains model
inventory_ml/main.py - ML runtime → Forecast API: starts service
inventory_ml/main.py - Demand data features → Supabase database: loads history
inventory_ml/models/data.py - Forecast API → Demand data features: builds forecasts
inventory_ml/api.py - Forecast API → XGBoost model: predicts demand
inventory_ml/api.py - Forecast API → Supabase database: stores forecasts
- ML runtime → ML dashboard: serves dashboard
- Forecast API → Restock and PO service: forecast integration