# keertan06/sales-forcasting-ml architecture

> Architecture diagram of the GitHub repository keertan06/sales-forcasting-ml, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/keertan06/sales-forcasting-ml
- Repository: https://github.com/keertan06/sales-forcasting-ml

## Overview

This Flask application serves retail sales predictions and an interactive analytics dashboard. The main path loads the trained model, feature schema, and retail dataset; dashboard routes derive KPIs and Plotly views, while POST /predict aligns submitted customer and product fields to the saved schema before returning a prediction. The separate model script documents dataset feature engineering, training, evaluation, and artifact creation. Dashboard and prediction details are grounded in app.py and the README; unsampled templates and artifact internals limit evidence about browser-side wiring.

Main entry points: [`app.py`](https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py) (Flask App), [`data/retail_sales_dataset.csv`](https://github.com/keertan06/sales-forcasting-ml/blob/main/data/retail_sales_dataset.csv) (Retail Dataset), [`static/style.css`](https://github.com/keertan06/sales-forcasting-ml/blob/main/static/style.css) (Dashboard Styling), [`model.py`](https://github.com/keertan06/sales-forcasting-ml/blob/main/model.py) (Model Training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Sales Data"]
  node_dataset[("Retail Dataset")]
end

subgraph group_ml["Model Lifecycle"]
  node_clean["Feature Preparation<br/>[model.py]"]
  node_trainer["Model Training<br/>[model.py]"]
  node_model["Trained Regressor<br/>[sales_model.pkl]"]
  node_schema["Feature Schema<br/>[model_features.pkl]"]
  node_visualize["Standalone Visualizations<br/>[visualize.py]"]
end

subgraph group_web["Flask Application"]
  node_webapp["Flask App<br/>[app.py]"]
  node_prediction["Sales Prediction<br/>[app.py]"]
  node_kpis["Business KPIs<br/>[app.py]"]
  node_plots["Analytics Plotting<br/>[app.py]"]
end

subgraph group_views["Dashboard Views"]
  node_home["Overview Page<br/>[index.html]"]
  node_trends["Trends Page<br/>[trends.html]"]
  node_categories["Categories Page<br/>[categories.html]"]
  node_performance["Performance Page<br/>[performance.html]"]
  node_style["Dashboard Styling<br/>[style.css]"]
end

node_visitor(("Dashboard User"))

node_dataset -->|"provides rows"| node_clean
node_dataset -->|"loads"| node_webapp
node_dataset -->|"loads"| node_visualize
node_dataset -->|"loads"| node_trainer
node_clean -->|"prepares features"| node_trainer
node_trainer -->|"saves model"| node_model
node_trainer -->|"saves schema"| node_schema
node_visitor -->|"requests pages"| node_webapp
node_webapp -->|"loads model"| node_model
node_webapp -->|"loads schema"| node_schema
node_webapp -->|"routes request"| node_prediction
node_prediction -->|"predicts with"| node_model
node_prediction -->|"aligns features"| node_schema
node_prediction -->|"returns prediction"| node_visitor
node_webapp -->|"computes"| node_kpis
node_webapp -->|"builds charts"| node_plots
node_webapp -->|"renders"| node_home
node_webapp -->|"renders"| node_trends
node_webapp -->|"renders"| node_categories
node_webapp -->|"renders"| node_performance
node_kpis -->|"supplies metrics"| node_home
node_kpis -->|"supplies metrics"| node_trends
node_kpis -->|"supplies metrics"| node_categories
node_kpis -->|"supplies metrics"| node_performance
node_plots -->|"supplies trend"| node_trends
node_plots -->|"supplies revenue charts"| node_categories
node_plots -->|"supplies comparison"| node_performance
node_visitor -->|"submits details"| node_prediction
node_style -.->|"styles"| node_home
node_style -.->|"styles"| node_trends
node_style -.->|"styles"| node_categories
node_style -.->|"styles"| node_performance

click node_dataset "https://github.com/keertan06/sales-forcasting-ml/blob/main/data/retail_sales_dataset.csv"
click node_clean "https://github.com/keertan06/sales-forcasting-ml/blob/main/model.py"
click node_trainer "https://github.com/keertan06/sales-forcasting-ml/blob/main/model.py"
click node_model "https://github.com/keertan06/sales-forcasting-ml/blob/main/sales_model.pkl"
click node_schema "https://github.com/keertan06/sales-forcasting-ml/blob/main/model_features.pkl"
click node_webapp "https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py"
click node_prediction "https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py"
click node_kpis "https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py"
click node_plots "https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py"
click node_home "https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/index.html"
click node_trends "https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/trends.html"
click node_categories "https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/categories.html"
click node_performance "https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/performance.html"
click node_style "https://github.com/keertan06/sales-forcasting-ml/blob/main/static/style.css"
click node_visualize "https://github.com/keertan06/sales-forcasting-ml/blob/main/visualize.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dataset,node_visitor toneBlue
class node_clean,node_trainer,node_model,node_schema,node_visualize toneAmber
class node_webapp,node_prediction,node_kpis,node_plots toneMint
class node_home,node_trends,node_categories,node_performance,node_style toneRose
```

## Components

### Sales Data

- [Retail Dataset](https://github.com/keertan06/sales-forcasting-ml/blob/main/data/retail_sales_dataset.csv): `data/retail_sales_dataset.csv`

### Model Lifecycle

- [Feature Preparation](https://github.com/keertan06/sales-forcasting-ml/blob/main/model.py): `model.py`
- [Model Training](https://github.com/keertan06/sales-forcasting-ml/blob/main/model.py): `model.py`
- [Trained Regressor](https://github.com/keertan06/sales-forcasting-ml/blob/main/sales_model.pkl): `sales_model.pkl`
- [Feature Schema](https://github.com/keertan06/sales-forcasting-ml/blob/main/model_features.pkl): `model_features.pkl`
- [Standalone Visualizations](https://github.com/keertan06/sales-forcasting-ml/blob/main/visualize.py): `visualize.py`

### Flask Application

- [Flask App](https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py): `app.py`
- [Sales Prediction](https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py): `app.py`
- [Business KPIs](https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py): `app.py`
- [Analytics Plotting](https://github.com/keertan06/sales-forcasting-ml/blob/main/app.py): `app.py`

### Dashboard Views

- [Overview Page](https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/index.html): `templates/index.html`
- [Trends Page](https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/trends.html): `templates/trends.html`
- [Categories Page](https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/categories.html): `templates/categories.html`
- [Performance Page](https://github.com/keertan06/sales-forcasting-ml/blob/main/templates/performance.html): `templates/performance.html`
- [Dashboard Styling](https://github.com/keertan06/sales-forcasting-ml/blob/main/static/style.css): `static/style.css`

### Other components

- **Dashboard User**

## Connections

- Retail Dataset → Feature Preparation: provides rows (evidence: `README.md`)
- Retail Dataset → Flask App: loads (evidence: `app.py`)
- Retail Dataset → Standalone Visualizations: loads (evidence: `visualize.py`)
- Retail Dataset → Model Training: loads (evidence: `model.py`)
- Feature Preparation → Model Training: prepares features (evidence: `model.py`)
- Model Training → Trained Regressor: saves model (evidence: `model.py`)
- Model Training → Feature Schema: saves schema (evidence: `model.py`)
- Dashboard User → Flask App: requests pages (evidence: `README.md`)
- Flask App → Trained Regressor: loads model (evidence: `app.py`)
- Flask App → Feature Schema: loads schema (evidence: `app.py`)
- Flask App → Sales Prediction: routes request (evidence: `app.py`)
- Sales Prediction → Trained Regressor: predicts with (evidence: `app.py`)
- Sales Prediction → Feature Schema: aligns features (evidence: `app.py`)
- Sales Prediction → Dashboard User: returns prediction (evidence: `app.py`)
- Flask App → Business KPIs: computes (evidence: `app.py`)
- Flask App → Analytics Plotting: builds charts (evidence: `app.py`)
- Flask App → Overview Page: renders (evidence: `app.py`)
- Flask App → Trends Page: renders (evidence: `app.py`)
- Flask App → Categories Page: renders (evidence: `app.py`)
- Flask App → Performance Page: renders (evidence: `app.py`)
- Business KPIs → Overview Page: supplies metrics (evidence: `app.py`)
- Business KPIs → Trends Page: supplies metrics (evidence: `app.py`)
- Business KPIs → Categories Page: supplies metrics (evidence: `app.py`)
- Business KPIs → Performance Page: supplies metrics (evidence: `app.py`)
- Analytics Plotting → Trends Page: supplies trend (evidence: `app.py`)
- Analytics Plotting → Categories Page: supplies revenue charts (evidence: `app.py`)
- Analytics Plotting → Performance Page: supplies comparison (evidence: `app.py`)
- Dashboard User → Sales Prediction: submits details (evidence: `README.md`)
- Dashboard Styling → Overview Page: styles
- Dashboard Styling → Trends Page: styles
- Dashboard Styling → Categories Page: styles
- Dashboard Styling → Performance Page: styles
