How ozols-s/smart_restock_engine works
Smart Restock Engine is a Flask inventory and restocking application. Its principal workflow serves dashboard requests, gathers sales, stock, and order data, calculates forecasts and recommended replenishment, and returns results to users. Separate routes and services cover products, orders, suppliers, and analytics. The README documents PostgreSQL and ClickHouse as data stores. Several route and service relationships are supported only by the source index; unsampled implementation details are not inferred.
Main entry points: connection.py Database connections · order_service.py Order service · main.py Flask application · dashboard_service.py Dashboard service
Components 25
Application and routes
- Flask application
main.py - Product routes
backend/routes/products_routes.py - Order routes
backend/routes/orders_routes.py - Supplier routes
backend/routes/suppliers_routes.py - Dashboard routes
backend/routes/dashboard_routes.py - Analytics routes
backend/routes/analytics_routes.py
Inventory and decisions
- Product service
backend/services/product_service.py - Order service
backend/services/order_service.py - Supplier service
backend/services/supplier_service.py - Dashboard service
backend/services/dashboard_service.py
Analytics and forecasting
- Forecast service
backend/services/forecast_service.py - Order recommender
backend/ml/order_recommender.py - Product analytics
backend/ml/product_analytics.py - Analytics service
backend/services/analytics_service.py - Cache decorator
backend/cache/cache_decorator.py
Persistence and configuration
- CRUD repositories
backend/repositories/crud_repositories.py - Sales repository
backend/repositories/sales_repository.py - Stock repository
backend/repositories/stock_repository.py - Analytics repository
backend/repositories/analytics_repository.py - Database connections
backend/db/connection.py - ORM models
backend/db/models.py - Application settings
backend/config/settings.py
Other components
- Dashboard user
- PostgreSQL
- ClickHouse
Connections 33
- Dashboard user → Flask application: requests pages
main.py - Flask application → Dashboard routes: registers routes
main.py - Flask application → Product routes: registers routes
main.py - Flask application → Order routes: registers routes
main.py - Flask application → Supplier routes: registers routes
main.py - Flask application → Analytics routes: registers routes
main.py - Dashboard routes → Dashboard service: requests data
backend/routes/dashboard_routes.py - Product routes → Product service: requests products
backend/routes/products_routes.py - Supplier routes → Supplier service: requests suppliers
backend/routes/suppliers_routes.py - Order routes → Order service: uses service
backend/routes/orders_routes.py - Analytics routes → Analytics service: uses service
backend/routes/analytics_routes.py - Dashboard service → Sales repository: reads sales
backend/services/dashboard_service.py - Dashboard service → Stock repository: reads stock
backend/services/dashboard_service.py - Dashboard service → CRUD repositories: reads orders
backend/services/dashboard_service.py - Dashboard service → Order service: calculates recommendations
backend/services/dashboard_service.py - Dashboard service → Cache decorator: caches summary
backend/services/dashboard_service.py - Order service → Sales repository: reads sales
backend/services/order_service.py - Order service → Stock repository: reads stock
backend/services/order_service.py - Order service → CRUD repositories: reads orders
backend/services/order_service.py - Order service → Forecast service: requests forecast
backend/services/order_service.py - Order service → Order recommender: calculates reorder
backend/services/order_service.py - Analytics service → Sales repository: reads sales
backend/services/analytics_service.py - Analytics service → Product analytics: uses analytics
backend/services/analytics_service.py - Analytics service → Cache decorator: caches results
backend/services/analytics_service.py - Sales repository → Database connections: queries through
backend/repositories/sales_repository.py - Stock repository → Database connections: queries through
backend/repositories/stock_repository.py - Analytics repository → Database connections: uses connection
backend/repositories/analytics_repository.py - CRUD repositories → Database connections: uses connection
backend/repositories/crud_repositories.py - CRUD repositories → ORM models: uses models
backend/repositories/crud_repositories.py - Database connections → Application settings: loads settings
backend/db/connection.py - Database connections → PostgreSQL: initializes ORM
backend/db/connection.py - Database connections → ClickHouse: creates client
backend/db/connection.py - ORM models → Database connections: binds ORM
backend/db/models.py