How ngonguyenthanhdam/smart-retail-mvp works
RetailSense AI is a small-chain retail operations app with a Next.js interface, NestJS business API, PostgreSQL persistence, and a separate experimental forecasting service. The main workflow is staff or managers using the frontend to record and review store operations; the backend applies business rules and stores results. Managers can also review forecast-driven replenishment recommendations and create purchase drafts. The README documents imports, alerts, reporting, and administration, but several of their internal links are not shown in the sampled source; those branches are represented without speculative call chains.
Main entry points: api.ts API client · features.py Feature engineering · forecast-data.service.ts Forecast data and history · replenishment.service.ts Replenishment decisions
Components 25
Web application
- Retail screens
frontend/src/components - Login and session
frontend/src/components/auth-provider.tsx - API client
frontend/src/lib/api.ts - Forecast screens
frontend/src/components/forecasts-page.tsx
Retail operations
- Authentication
backend/src/auth/auth.service.ts - Role and store scope
backend/src/auth/location-scope.ts - Product catalog
backend/src/products/products.service.ts - Store administration
backend/src/locations/locations.service.ts - Purchases and receiving
backend/src/purchases/purchases.service.ts - Sales and lot use
backend/src/sales/sales.service.ts - Inventory and lots
backend/src/inventory/inventory.service.ts - Operating expenses
backend/src/expenses/expenses.service.ts - Data imports
backend/src/imports/imports.service.ts - Reports and alerts
backend/src/reports/reports.service.ts
Forecasting and replenishment
- Forecast data and history
backend/src/forecasts/forecast-data.service.ts - Prediction client
backend/src/forecasts/prediction-client.ts - Replenishment decisions
backend/src/replenishment/replenishment.service.ts
Prediction service
- Prediction API
ml-service/app.py - History preparation
ml-service/src/forecasting.py - Feature engineering
ml-service/src/features.py - Preprocessing
ml-service/src/preprocessing.py - Quantity model
ml-service/src/quantity_model.py - Training datasets
ml-service/src/dataset.py
Other components
- Store user
- PostgreSQL
Connections 36
- Store user → Retail screens: uses
- Store user → Login and session: signs in
- Login and session → API client: requests API
- Retail screens → API client: loads and submits
- API client → Authentication: calls backend
- API client → Product catalog: calls backend
- API client → Purchases and receiving: calls backend
- API client → Sales and lot use: calls backend
- API client → Inventory and lots: calls backend
- API client → Data imports: calls backend
- API client → Forecast data and history: calls backend
- API client → Replenishment decisions: calls backend
- API client → Reports and alerts: calls backend
- API client → Operating expenses: calls backend
- API client → Store administration: calls backend
- Authentication → PostgreSQL: reads accounts
backend/src/auth/auth.service.ts - Role and store scope → Product catalog: limits access
- Purchases and receiving → PostgreSQL: stores purchase data
- Sales and lot use → PostgreSQL: stores sales data
- Inventory and lots → PostgreSQL: reads stock
- Operating expenses → PostgreSQL: stores expenses
- Data imports → PostgreSQL: imports records
- Reports and alerts → PostgreSQL: reads operations
- Forecast screens → API client: requests forecasts
- Forecast data and history → PostgreSQL: reads sales history
backend/src/forecasts/forecast-data.service.ts - Forecast data and history → Prediction client: requests predictions
backend/src/forecasts/forecast-data.controller.ts - Prediction client → Prediction API: sends forecast request
- Prediction API → History preparation: builds history panel
ml-service/app.py - Prediction API → Quantity model: loads quantity model
ml-service/app.py - History preparation → Feature engineering: builds features
ml-service/src/forecasting.py - Feature engineering → Preprocessing: uses preprocessing
ml-service/src/features.py - Quantity model → Feature engineering: uses features
ml-service/src/quantity_model.py - Quantity model → History preparation: uses forecasting
ml-service/src/quantity_model.py - Training datasets → Feature engineering: training data
- Replenishment decisions → PostgreSQL: stores reviewed drafts
- Replenishment decisions → Purchases and receiving: creates purchase draft