Running a small shop often means guessing: “Do I order more milk or coffee this week?” We wanted to give small business owners the kind of data-driven inventory tools big retailers use, but in a lightweight, affordable way. The goal was simple: turn messy sales history into clear decisions about what to buy, when, and how much.

What we built SmartStock is an AI-powered inventory prediction system for small businesses. It lets shop owners:

Track products, stock levels, prices, and suppliers. Record daily sales per product. See demand forecasts for the next 7 and 30 days. Get low-stock alerts and smart reorder suggestions. Explore a live dashboard with: Sales vs forecast chart Top-selling products (by units and revenue) Stock coverage table with risk levels Revenue KPIs (today, last 7 days, last 30 days) A core metric we use is days of cover:

[ \text{Days of cover} = \frac{\text{current stock}}{\text{average daily demand}} ]

We then classify products as “OK”, “Warning”, or “Critical” based on how that compares to their supplier lead time.

How we built it We built SmartStock using:

Backend: Python + Flask Data & ML: Pandas, NumPy, scikit-learn, SQLite Frontend: HTML, Bootstrap, Chart.js Data layer

A simple SQLite database stores: products (name, category, current stock, reorder point, lead time, price, supplier) sales (product, date, quantity) On first run, we auto-generate ~120 days of realistic demo data so the dashboard is immediately alive. Forecasting & logic

We aggregate daily sales per product using Pandas. For the main chart, we fit a Linear Regression model (scikit-learn) on the time index to forecast the next 7 days. For near-term and monthly KPIs, we use rolling 7- and 30-day windows to estimate total demand. We compute: Average daily demand per product. Demand over supplier lead time. Suggested reorder quantities to cover a target window (e.g. (\max(14, 2 \times \text{lead_time})) days). UI & insights

A Flask template renders the dashboard with Bootstrap styling and Chart.js visualizations. The page fetches /api/dashboard-data periodically to stay in sync with the latest sales. Clicking a bar in the “Top products” chart automatically drills down the main “Sales vs Forecast” chart to that product, making the dashboard feel interactive and exploratory. What we learned Small, well-chosen metrics beat complex models for a first MVP. Days of cover, lead time, and rolling averages already give actionable insights for small shops. Good UX matters as much as the model. Shop owners don’t care that we use linear regression—they care that the dashboard clearly says “you’ll run out of milk in 3 days.” Data realism is critical for demos. We learned how to synthesize believable sales patterns (weekends vs weekdays, seasonality, noise) so the app feels real even without a live store attached. Bridging business language and math. Translating questions like “Will I run out before my next delivery?” into formulas and thresholds was a valuable exercise in applied analytics. Challenges we faced Designing forecasting that’s simple but trustworthy. We had to balance hackathon time constraints with the need for something better than a naive average. Linear regression on time, combined with rolling windows, gave a good middle ground. Keeping the dashboard truly dynamic. Early on, the UI looked nice but stayed static because the API responses weren’t JSON-serializable (NumPy and Pandas types). We debugged and sanitized all values into plain Python types so charts and KPIs update correctly. Schema evolution without migrations. As we added fields like category, price, and supplier, we needed the app to upgrade existing SQLite databases in place. We handled this carefully with conditional ALTER TABLE calls. Making insights understandable. It took iteration to present concepts like forecasted demand, risk levels, and reorder quantities in a way that a non-technical shop owner can quickly grasp. What’s next In future versions, we’d like to:

Experiment with more advanced time-series models (ARIMA, Prophet) for seasonal demand. Add a mobile-friendly interface and barcode scanning for faster stock updates. Integrate suppliers to auto-generate purchase orders based on SmartStock’s recommendations. Support multi-store analytics so small chains can see which locations are over- or under-stocked.

Share this project:

Updates