# dharmadpi/functionaltestcasegenerator architecture

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

- Interactive diagram: https://gitdiagram.com/dharmadpi/functionaltestcasegenerator
- Repository: https://github.com/dharmadpi/functionaltestcasegenerator

## Overview

Functional Spec SQL Generator turns an uploaded or command-line XLSX functional specification into SQL test queries and a downloadable TXT file. The main flow parses table and column metadata, identifies fact/dimension structures and relationships, then generates queries; users can run this through either a CLI or one of two Streamlit interfaces. The chatbot adds conversational prompts, previews, and session state. The core source is partially excerpted, so internal query-generation details are represented only at the documented and visible level.

Main entry points: [`spec_agent.py`](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py) (SQL Generator), [`app.py`](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/app.py) (CLI Runner), [`streamlit_app.py`](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_app.py) (Web Generator), [`streamlit_chatbot.py`](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_chatbot.py) (Chat Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI Runner<br/>[app.py]"]
  node_web["Web Generator<br/>[streamlit_app.py]"]
  node_chat["Chat Interface"]
end

subgraph group_engine["Specification Engine"]
  node_metadata["Metadata Parser<br/>[spec_agent.py]"]
  node_schema["Table Modeling<br/>[spec_agent.py]"]
  node_relations["Key Relations<br/>[spec_agent.py]"]
  node_generator["SQL Generator<br/>[spec_agent.py]"]
end

subgraph group_delivery["Query Delivery"]
  node_cli_output["TXT Writer<br/>[app.py]"]
  node_web_output["Query Download<br/>[streamlit_app.py]"]
  node_chat_output["Preview and Download"]
end

node_user(("User"))
node_xlsx["XLSX Spec"]

node_user -->|"runs command"| node_cli
node_user -->|"uploads spec"| node_web
node_user -->|"uploads and prompts"| node_chat
node_xlsx -->|"provides input"| node_cli
node_xlsx -->|"provides input"| node_web
node_xlsx -->|"provides input"| node_chat
node_cli -->|"calls generator"| node_generator
node_web -->|"calls generator"| node_generator
node_chat -->|"calls generator"| node_generator
node_generator -->|"loads specification"| node_metadata
node_metadata -->|"extracts metadata"| node_schema
node_schema -->|"infers joins"| node_relations
node_generator -->|"uses relationships"| node_relations
node_generator -->|"returns queries"| node_cli_output
node_generator -->|"returns queries"| node_web_output
node_generator -->|"returns queries"| node_chat_output
node_cli_output -->|"saves TXT"| node_user
node_web_output -->|"downloads TXT"| node_user
node_chat_output -->|"previews or downloads"| node_user

click node_cli "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/app.py"
click node_web "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_app.py"
click node_chat "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_chatbot.py"
click node_metadata "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py"
click node_schema "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py"
click node_relations "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py"
click node_generator "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py"
click node_cli_output "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/app.py"
click node_web_output "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_app.py"
click node_chat_output "https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_chatbot.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_cli,node_web,node_chat,node_user toneBlue
class node_metadata,node_schema,node_relations,node_generator toneAmber
class node_cli_output,node_web_output,node_chat_output toneMint
class node_xlsx toneIndigo
```

## Components

### User Interfaces

- [CLI Runner](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/app.py): `app.py`
- [Web Generator](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_app.py): `streamlit_app.py`
- [Chat Interface](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_chatbot.py): `streamlit_chatbot.py`

### Specification Engine

- [Metadata Parser](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py): `spec_agent.py`
- [Table Modeling](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py): `spec_agent.py`
- [Key Relations](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py): `spec_agent.py`
- [SQL Generator](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/spec_agent.py): `spec_agent.py`

### Query Delivery

- [TXT Writer](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/app.py): `app.py`
- [Query Download](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_app.py): `streamlit_app.py`
- [Preview and Download](https://github.com/dharmadpi/functionaltestcasegenerator/blob/master/streamlit_chatbot.py): `streamlit_chatbot.py`

### Other components

- **User**
- **XLSX Spec**

## Connections

- User → CLI Runner: runs command (evidence: `README.md`)
- User → Web Generator: uploads spec (evidence: `README.md`)
- User → Chat Interface: uploads and prompts (evidence: `README.md`)
- XLSX Spec → CLI Runner: provides input (evidence: `README.md`)
- XLSX Spec → Web Generator: provides input (evidence: `README.md`)
- XLSX Spec → Chat Interface: provides input (evidence: `README.md`)
- CLI Runner → SQL Generator: calls generator (evidence: `app.py`)
- Web Generator → SQL Generator: calls generator (evidence: `streamlit_app.py`)
- Chat Interface → SQL Generator: calls generator (evidence: `streamlit_chatbot.py`)
- SQL Generator → Metadata Parser: loads specification (evidence: `README.md`)
- Metadata Parser → Table Modeling: extracts metadata (evidence: `spec_agent.py`)
- Table Modeling → Key Relations: infers joins (evidence: `spec_agent.py`)
- SQL Generator → Key Relations: uses relationships (evidence: `spec_agent.py`)
- SQL Generator → TXT Writer: returns queries (evidence: `app.py`)
- SQL Generator → Query Download: returns queries (evidence: `streamlit_app.py`)
- SQL Generator → Preview and Download: returns queries (evidence: `streamlit_chatbot.py`)
- TXT Writer → User: saves TXT (evidence: `README.md`)
- Query Download → User: downloads TXT (evidence: `README.md`)
- Preview and Download → User: previews or downloads (evidence: `README.md`)
