# haricrazy1432-bot/salesforecastautomation architecture

> Architecture diagram of the GitHub repository haricrazy1432-bot/salesforecastautomation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/haricrazy1432-bot/salesforecastautomation
- Repository: https://github.com/haricrazy1432-bot/salesforecastautomation

## Overview

SalesForecastAutomation is a Northwind sales analytics app: users ask questions in chat, receive SQL-backed results or a sales forecast, and view charts and a text summary. The frontend coordinates the workflow; the FastAPI backend exposes schema, query, sales-history, and forecast endpoints over SQLite. Forecasts aggregate monthly sales and fit a linear trend. The README provides no further capability detail, and the Groq and Chat implementations were not excerpted, so their internal behavior is not expanded here.

Main entry points: [`src/App.tsx`](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/App.tsx) (Workflow coordinator), [`backend/main.py`](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py) (Analytics API), [`backend/northwind.db`](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/northwind.db) (Northwind SQLite), [`src/components/Chat.tsx`](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/components/Chat.tsx) (Chat input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interface"]
  node_chat["Chat input<br/>[Chat.tsx]"]
  node_app["Workflow coordinator<br/>[App.tsx]"]
  node_charts["Charts<br/>[Charts.tsx]"]
  node_results["Results and summary<br/>[App.tsx]"]
end

subgraph group_query["Natural-language queries"]
  node_groq["Groq language services<br/>[groq.ts]"]
end

subgraph group_service["Analytics backend"]
  node_api["Analytics API<br/>[main.py]"]
  node_schema["Schema endpoint<br/>[main.py]"]
  node_sql["Read-only SQL endpoint<br/>[main.py]"]
  node_history["Sales history endpoint<br/>[main.py]"]
  node_aggregation["Monthly sales aggregation<br/>[main.py]"]
  node_forecast["Forecast endpoint<br/>[main.py]"]
  node_regression["Linear trend model<br/>[main.py]"]
end

subgraph group_data["Sales data"]
  node_database[("Northwind SQLite<br/>[northwind.db]")]
end

node_user(("Analyst"))

node_user -->|"asks"| node_chat
node_chat -->|"submits message"| node_app
node_app -->|"fetches schema"| node_schema
node_app -->|"generates SQL"| node_groq
node_app -->|"submits query"| node_sql
node_app -->|"requests forecast"| node_forecast
node_app -->|"describes results"| node_groq
node_app -->|"renders rows"| node_charts
node_app -->|"renders results"| node_results
node_api -->|"serves routes"| node_schema
node_api -->|"serves routes"| node_sql
node_api -->|"serves routes"| node_history
node_api -->|"serves routes"| node_forecast
node_schema -->|"reads schema"| node_database
node_sql -->|"executes query"| node_database
node_history -->|"builds history"| node_aggregation
node_forecast -->|"builds history"| node_aggregation
node_aggregation -->|"reads sales data"| node_database
node_forecast -->|"fits and predicts"| node_regression

click node_chat "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/components/Chat.tsx"
click node_app "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/App.tsx"
click node_charts "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/components/Charts.tsx"
click node_results "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/App.tsx"
click node_groq "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/lib/groq.ts"
click node_api "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py"
click node_schema "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py"
click node_sql "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py"
click node_history "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py"
click node_aggregation "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py"
click node_forecast "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py"
click node_regression "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py"
click node_database "https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/northwind.db"

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_chat,node_app,node_charts,node_results toneBlue
class node_groq toneAmber
class node_api,node_schema,node_sql,node_history,node_aggregation,node_forecast,node_regression toneMint
class node_database toneRose
class node_user toneIndigo
```

## Components

### User interface

- [Chat input](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/components/Chat.tsx): `src/components/Chat.tsx`
- [Workflow coordinator](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/App.tsx): `src/App.tsx`
- [Charts](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/components/Charts.tsx): `src/components/Charts.tsx`
- [Results and summary](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/App.tsx): `src/App.tsx`

### Natural-language queries

- [Groq language services](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/src/lib/groq.ts): `src/lib/groq.ts`

### Analytics backend

- [Analytics API](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py): `backend/main.py`
- [Schema endpoint](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py): `backend/main.py`
- [Read-only SQL endpoint](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py): `backend/main.py`
- [Sales history endpoint](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py): `backend/main.py`
- [Monthly sales aggregation](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py): `backend/main.py`
- [Forecast endpoint](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py): `backend/main.py`
- [Linear trend model](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/main.py): `backend/main.py`

### Sales data

- [Northwind SQLite](https://github.com/haricrazy1432-bot/salesforecastautomation/blob/main/backend/northwind.db): `backend/northwind.db`

### Other components

- **Analyst**

## Connections

- Analyst → Chat input: asks
- Chat input → Workflow coordinator: submits message (evidence: `src/App.tsx`)
- Workflow coordinator → Schema endpoint: fetches schema (evidence: `src/App.tsx`)
- Workflow coordinator → Groq language services: generates SQL (evidence: `src/App.tsx`)
- Workflow coordinator → Read-only SQL endpoint: submits query (evidence: `src/App.tsx`)
- Workflow coordinator → Forecast endpoint: requests forecast (evidence: `src/App.tsx`)
- Workflow coordinator → Groq language services: describes results (evidence: `src/App.tsx`)
- Workflow coordinator → Charts: renders rows (evidence: `src/App.tsx`)
- Workflow coordinator → Results and summary: renders results (evidence: `src/App.tsx`)
- Analytics API → Schema endpoint: serves routes (evidence: `backend/main.py`)
- Analytics API → Read-only SQL endpoint: serves routes (evidence: `backend/main.py`)
- Analytics API → Sales history endpoint: serves routes (evidence: `backend/main.py`)
- Analytics API → Forecast endpoint: serves routes (evidence: `backend/main.py`)
- Schema endpoint → Northwind SQLite: reads schema (evidence: `backend/main.py`)
- Read-only SQL endpoint → Northwind SQLite: executes query (evidence: `backend/main.py`)
- Sales history endpoint → Monthly sales aggregation: builds history (evidence: `backend/main.py`)
- Forecast endpoint → Monthly sales aggregation: builds history (evidence: `backend/main.py`)
- Monthly sales aggregation → Northwind SQLite: reads sales data (evidence: `backend/main.py`)
- Forecast endpoint → Linear trend model: fits and predicts (evidence: `backend/main.py`)
