# nachiket1904/sap-copilot architecture

> Architecture diagram of the GitHub repository nachiket1904/sap-copilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nachiket1904/sap-copilot
- Repository: https://github.com/nachiket1904/sap-copilot

## Overview

SAP Copilot is an early-stage assistant intended to answer plain-English questions about SAP-style purchase orders and flag anomalies such as unusual amounts and delayed payments. The documented end-to-end workflow is CSV data → SQLite → text-to-SQL retrieval → an LLM-generated answer, with Groq or Gemini selectable as provider. In the sampled code, CSV loading and schema description are implemented, but text-to-SQL execution, answer orchestration, and a user-facing entry point are not; the workflow edges below reflect documented design where noted.

Main entry points: [`src/llm/client.py`](https://github.com/nachiket1904/sap-copilot/blob/main/src/llm/client.py) (Provider client), [`src/retrieval/text_to_sql.py`](https://github.com/nachiket1904/sap-copilot/blob/main/src/retrieval/text_to_sql.py) (Text-to-SQL), [`src/data_layer/loader.py`](https://github.com/nachiket1904/sap-copilot/blob/main/src/data_layer/loader.py) (CSV loader), [`data/mock_sap`](https://github.com/nachiket1904/sap-copilot/tree/main/data/mock_sap) (Mock SAP CSVs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Enterprise data"]
  node_csv["Mock SAP CSVs"]
  node_loader["CSV loader<br/>[loader.py]"]
  node_sqlite[("SQLite database")]
end

subgraph group_retrieval["Question retrieval"]
  node_schema["Schema description<br/>[text_to_sql.py]"]
  node_retrieval["Text-to-SQL<br/>[text_to_sql.py]"]
  node_anomalies["Anomaly questions"]
end

subgraph group_llm["LLM providers"]
  node_client["Provider client<br/>[client.py]"]
  node_groq{{"Groq"}}
  node_gemini{{"Gemini"}}
  node_answer["Natural-language answer"]
end

node_user(("Questioner"))

node_csv -->|"reads"| node_loader
node_loader -->|"loads tables"| node_sqlite
node_schema -->|"inspects schema"| node_sqlite
node_user -.->|"asks question"| node_retrieval
node_retrieval -.->|"uses schema"| node_schema
node_retrieval -.->|"requests answer"| node_client
node_client -->|"calls if selected"| node_groq
node_client -->|"calls if selected"| node_gemini
node_client -->|"returns text"| node_answer
node_user -.->|"asks about"| node_anomalies

click node_csv "https://github.com/nachiket1904/sap-copilot/tree/main/data/mock_sap"
click node_loader "https://github.com/nachiket1904/sap-copilot/blob/main/src/data_layer/loader.py"
click node_schema "https://github.com/nachiket1904/sap-copilot/blob/main/src/retrieval/text_to_sql.py"
click node_retrieval "https://github.com/nachiket1904/sap-copilot/blob/main/src/retrieval/text_to_sql.py"
click node_client "https://github.com/nachiket1904/sap-copilot/blob/main/src/llm/client.py"
click node_anomalies "https://github.com/nachiket1904/sap-copilot/tree/main/src/retrieval"

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_csv,node_loader,node_sqlite toneBlue
class node_schema,node_retrieval,node_anomalies toneAmber
class node_client,node_groq,node_gemini,node_answer toneMint
class node_user toneIndigo
```

## Components

### Enterprise data

- [Mock SAP CSVs](https://github.com/nachiket1904/sap-copilot/tree/main/data/mock_sap): `data/mock_sap`
- [CSV loader](https://github.com/nachiket1904/sap-copilot/blob/main/src/data_layer/loader.py): `src/data_layer/loader.py`
- **SQLite database**

### Question retrieval

- [Schema description](https://github.com/nachiket1904/sap-copilot/blob/main/src/retrieval/text_to_sql.py): `src/retrieval/text_to_sql.py`
- [Text-to-SQL](https://github.com/nachiket1904/sap-copilot/blob/main/src/retrieval/text_to_sql.py): `src/retrieval/text_to_sql.py`
- [Anomaly questions](https://github.com/nachiket1904/sap-copilot/tree/main/src/retrieval): `src/retrieval`

### LLM providers

- [Provider client](https://github.com/nachiket1904/sap-copilot/blob/main/src/llm/client.py): `src/llm/client.py`
- **Groq**
- **Gemini**
- **Natural-language answer**

### Other components

- **Questioner**

## Connections

- Mock SAP CSVs → CSV loader: reads
- CSV loader → SQLite database: loads tables
- Schema description → SQLite database: inspects schema
- Questioner → Text-to-SQL: asks question
- Text-to-SQL → Schema description: uses schema
- Text-to-SQL → Provider client: requests answer
- Provider client → Groq: calls if selected
- Provider client → Gemini: calls if selected
- Provider client → Natural-language answer: returns text
- Questioner → Anomaly questions: asks about
