# dayoawe1/sales-forecasting-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/dayoawe1/sales-forecasting-assistant
- Repository: https://github.com/dayoawe1/sales-forecasting-assistant

## Overview

This repository delivers a weekly sales-forecasting pipeline and a question-answering assistant over its forecasts. Airflow schedules raw-data loading, Snowflake staging, feature creation, model quality evaluation, forecasting, and assistant-index refresh. Users then query forecasts through an LLM that can run guarded read-only SQL or retrieve generated summaries. The graph preserves the documented backtest/model-comparison capability, but its implementation is not shown in the sampled sources. Edges are limited to documented workflow and visible calls; unsampled staging SQL details are not inferred.

Main entry points: [`dags/sales_forecasting_dag.py`](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/dags/sales_forecasting_dag.py) (Weekly Airflow DAG), [`src/rag/index.py`](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/index.py) (Summary embedding and search), [`src/rag/assistant.py`](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/assistant.py) (Question-answering agent), [`src/transform/run_staging.py`](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/transform/run_staging.py) (Staging runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Forecast workflow"]
  node_airflow["Weekly Airflow DAG"]
end

subgraph group_data["Data preparation"]
  node_raw_loader["Raw CSV loader<br/>[load_raw.py]"]
  node_staging_runner["Staging runner<br/>[run_staging.py]"]
  node_staging_sql["Staging transforms<br/>[03_staging.sql]"]
  node_feature_builder["Feature builder<br/>[build_features.py]"]
end

subgraph group_models["Forecast modeling"]
  node_model_pipeline["Model evaluation and forecasts<br/>[train_forecast.py]"]
  node_model_backtests["Model backtest comparisons<br/>[03_models.ipynb]"]
end

subgraph group_assistant["Insights assistant"]
  node_summary_builder["Forecast summaries<br/>[summaries.py]"]
  node_rag_index["Summary embedding and search<br/>[index.py]"]
  node_assistant["Question-answering agent<br/>[assistant.py]"]
  node_assistant_evaluation["Assistant evaluation"]
  node_rag_files[("Local vector and document files")]
end

node_user(("Business user"))
node_snowflake[("Snowflake")]
node_openai["OpenAI API"]

node_airflow -->|"schedules loading"| node_raw_loader
node_airflow -->|"schedules staging"| node_staging_runner
node_airflow -->|"schedules features"| node_feature_builder
node_airflow -->|"schedules evaluation"| node_model_pipeline
node_airflow -->|"schedules forecast"| node_model_pipeline
node_airflow -->|"schedules refresh"| node_rag_index
node_raw_loader -->|"writes raw tables"| node_snowflake
node_staging_runner -->|"executes SQL"| node_staging_sql
node_staging_runner -->|"runs statements"| node_snowflake
node_feature_builder -->|"reads staging; writes features"| node_snowflake
node_model_pipeline -->|"reads features; writes results"| node_snowflake
node_model_backtests -.->|"records comparisons"| node_snowflake
node_summary_builder -->|"reads and writes summaries"| node_snowflake
node_rag_index -->|"builds summaries"| node_summary_builder
node_rag_index -->|"reads summaries"| node_snowflake
node_rag_index -->|"requests embeddings"| node_openai
node_rag_index -->|"stores vectors and docs"| node_rag_files
node_assistant -->|"requests responses"| node_openai
node_assistant -->|"runs guarded SQL"| node_snowflake
node_assistant -->|"searches summaries"| node_rag_index
node_user -->|"asks questions"| node_assistant
node_assistant_evaluation -->|"evaluates answers"| node_assistant
node_assistant_evaluation -->|"queries ground truth"| node_snowflake

click node_airflow "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/dags/sales_forecasting_dag.py"
click node_raw_loader "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/ingest/load_raw.py"
click node_staging_runner "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/transform/run_staging.py"
click node_staging_sql "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/sql/03_staging.sql"
click node_feature_builder "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/features/build_features.py"
click node_model_pipeline "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/models/train_forecast.py"
click node_model_backtests "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/notebooks/03_models.ipynb"
click node_summary_builder "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/summaries.py"
click node_rag_index "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/index.py"
click node_assistant "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/assistant.py"
click node_assistant_evaluation "https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/evaluate_assistant.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_airflow,node_user toneBlue
class node_raw_loader,node_staging_runner,node_staging_sql,node_feature_builder,node_snowflake toneAmber
class node_model_pipeline,node_model_backtests,node_openai toneMint
class node_summary_builder,node_rag_index,node_assistant,node_assistant_evaluation,node_rag_files toneRose
```

## Components

### Forecast workflow

- [Weekly Airflow DAG](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/dags/sales_forecasting_dag.py): `dags/sales_forecasting_dag.py`

### Data preparation

- [Raw CSV loader](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/ingest/load_raw.py): `src/ingest/load_raw.py`
- [Staging runner](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/transform/run_staging.py): `src/transform/run_staging.py`
- [Staging transforms](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/sql/03_staging.sql): `sql/03_staging.sql`
- [Feature builder](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/features/build_features.py): `src/features/build_features.py`

### Forecast modeling

- [Model evaluation and forecasts](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/models/train_forecast.py): `src/models/train_forecast.py`
- [Model backtest comparisons](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/notebooks/03_models.ipynb): `notebooks/03_models.ipynb`

### Insights assistant

- [Forecast summaries](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/summaries.py): `src/rag/summaries.py`
- [Summary embedding and search](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/index.py): `src/rag/index.py`
- [Question-answering agent](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/assistant.py): `src/rag/assistant.py`
- [Assistant evaluation](https://github.com/dayoawe1/sales-forecasting-assistant/blob/main/src/rag/evaluate_assistant.py): `src/rag/evaluate_assistant.py`
- **Local vector and document files**

### Other components

- **Business user**
- **Snowflake**
- **OpenAI API**

## Connections

- Weekly Airflow DAG → Raw CSV loader: schedules loading (evidence: `dags/sales_forecasting_dag.py`)
- Weekly Airflow DAG → Staging runner: schedules staging (evidence: `dags/sales_forecasting_dag.py`)
- Weekly Airflow DAG → Feature builder: schedules features (evidence: `dags/sales_forecasting_dag.py`)
- Weekly Airflow DAG → Model evaluation and forecasts: schedules evaluation (evidence: `dags/sales_forecasting_dag.py`)
- Weekly Airflow DAG → Model evaluation and forecasts: schedules forecast (evidence: `dags/sales_forecasting_dag.py`)
- Weekly Airflow DAG → Summary embedding and search: schedules refresh (evidence: `dags/sales_forecasting_dag.py`)
- Raw CSV loader → Snowflake: writes raw tables (evidence: `src/ingest/load_raw.py`)
- Staging runner → Staging transforms: executes SQL (evidence: `src/transform/run_staging.py`)
- Staging runner → Snowflake: runs statements (evidence: `src/transform/run_staging.py`)
- Feature builder → Snowflake: reads staging; writes features (evidence: `src/features/build_features.py`)
- Model evaluation and forecasts → Snowflake: reads features; writes results (evidence: `src/models/train_forecast.py`)
- Model backtest comparisons → Snowflake: records comparisons
- Forecast summaries → Snowflake: reads and writes summaries (evidence: `src/rag/summaries.py`)
- Summary embedding and search → Forecast summaries: builds summaries (evidence: `src/rag/index.py`)
- Summary embedding and search → Snowflake: reads summaries (evidence: `src/rag/index.py`)
- Summary embedding and search → OpenAI API: requests embeddings (evidence: `src/rag/index.py`)
- Summary embedding and search → Local vector and document files: stores vectors and docs (evidence: `src/rag/index.py`)
- Question-answering agent → OpenAI API: requests responses (evidence: `src/rag/assistant.py`)
- Question-answering agent → Snowflake: runs guarded SQL (evidence: `src/rag/assistant.py`)
- Question-answering agent → Summary embedding and search: searches summaries (evidence: `src/rag/assistant.py`)
- Business user → Question-answering agent: asks questions (evidence: `README.md`)
- Assistant evaluation → Question-answering agent: evaluates answers (evidence: `src/rag/evaluate_assistant.py`)
- Assistant evaluation → Snowflake: queries ground truth (evidence: `src/rag/evaluate_assistant.py`)
