# shubankar-sridhar/mlproject architecture

> Architecture diagram of the GitHub repository shubankar-sridhar/mlproject, 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/shubankar-sridhar/mlproject
- Repository: https://github.com/shubankar-sridhar/mlproject

## Overview

This is an enterprise natural-language-to-SQL application: users submit questions, the backend generates and validates SQL, executes it, and can return chart specifications for the results. The repository also exposes model management and training endpoints. The sampled route and inference code show the query orchestration; visualization internals and training implementation are present in the tree but were not sampled, so their internal connections are not inferred.

Main entry points: [`src/pipeline2/api/routes.py`](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/routes.py) (API routes), [`frontend/src/App.jsx`](https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/App.jsx) (Query and results UI), [`frontend/src/components/ResultsView.jsx`](https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/ResultsView.jsx) (Results view), [`src/pipeline2/api/dependencies.py`](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/dependencies.py) (Schema and rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Query interface"]
  node_ui["Query and results UI<br/>[App.jsx]"]
  node_query_input["Query input<br/>[QueryInput.jsx]"]
  node_results_view["Results view<br/>[ResultsView.jsx]"]
  node_chart_renderer["Chart renderer<br/>[ChartRenderer.jsx]"]
  node_data_table["Data table<br/>[DataTable.jsx]"]
end

subgraph group_api["API and access"]
  node_api_routes["API routes<br/>[routes.py]"]
  node_access_dependencies["Auth and rate limits<br/>[dependencies.py]"]
  node_health["Health checks<br/>[health.py]"]
  node_model_manager["Model manager<br/>[dependencies.py]"]
  node_model_registry["Model registry<br/>[metadata.json]"]
  node_training["Training job"]
  node_database_manager["Schema and rules<br/>[dependencies.py]"]
  node_schema_config["Database schema<br/>[schema.json]"]
  node_rules_config["Business rules"]
end

subgraph group_generation["SQL generation"]
  node_llama_engine["Llama inference<br/>[llama_engine.py]"]
  node_prompt_builder["Prompt builder<br/>[prompt_builder.py]"]
  node_output_parser["Structured output parser"]
end

subgraph group_execution["SQL execution"]
  node_sql_validator["SQL validator<br/>[validator.py]"]
  node_sql_parser["SQL parser<br/>[parser.py]"]
  node_sql_executor["SQL executor<br/>[executor.py]"]
end

subgraph group_visualization["Visualization"]
  node_profiler["Result profiler<br/>[profiler.py]"]
  node_role_detector["Role detector<br/>[role_detector.py]"]
  node_candidate_generator["Chart candidates"]
  node_chart_scorer["Candidate scorer<br/>[scorer.py]"]
  node_vega_generator["Vega-Lite generator<br/>[vega_generator.py]"]
end

node_user(("User"))
node_redis[("Rate-limit Redis")]
node_database[("Query database")]

node_user -->|"enters query"| node_query_input
node_query_input -->|"submits"| node_ui
node_ui -.->|"sends query"| node_api_routes
node_api_routes -->|"checks access"| node_access_dependencies
node_access_dependencies -.->|"checks limits"| node_redis
node_api_routes -->|"routes health"| node_health
node_api_routes -->|"loads model"| node_model_manager
node_model_manager -->|"reads metadata"| node_model_registry
node_api_routes -->|"starts job"| node_training
node_api_routes -->|"gets schema"| node_database_manager
node_database_manager -->|"loads schema"| node_schema_config
node_database_manager -->|"loads rules"| node_rules_config
node_api_routes -->|"generates SQL"| node_llama_engine
node_llama_engine -->|"builds prompt"| node_prompt_builder
node_llama_engine -->|"parses output"| node_output_parser
node_api_routes -->|"validates SQL"| node_sql_validator
node_sql_validator -->|"parses SQL"| node_sql_parser
node_api_routes -->|"executes SQL"| node_sql_executor
node_sql_executor -.->|"queries"| node_database
node_api_routes -->|"generates chart spec"| node_vega_generator
node_ui -->|"renders results"| node_results_view
node_results_view -->|"renders chart"| node_chart_renderer
node_results_view -->|"renders table"| node_data_table

click node_ui "https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/App.jsx"
click node_query_input "https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/QueryInput.jsx"
click node_results_view "https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/ResultsView.jsx"
click node_chart_renderer "https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/ChartRenderer.jsx"
click node_data_table "https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/DataTable.jsx"
click node_api_routes "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/routes.py"
click node_access_dependencies "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/dependencies.py"
click node_health "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/health.py"
click node_model_manager "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/dependencies.py"
click node_model_registry "https://github.com/shubankar-sridhar/mlproject/blob/main/models/registry/models/qwenModel/metadata.json"
click node_training "https://github.com/shubankar-sridhar/mlproject/tree/main/src/pipeline2"
click node_database_manager "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/dependencies.py"
click node_schema_config "https://github.com/shubankar-sridhar/mlproject/blob/main/configs/schema.json"
click node_rules_config "https://github.com/shubankar-sridhar/mlproject/blob/main/configs/business_rules.json"
click node_llama_engine "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/inference/llama_engine.py"
click node_prompt_builder "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/inference/prompt_builder.py"
click node_output_parser "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/inference/structured_output.py"
click node_sql_validator "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/sql/validator.py"
click node_sql_parser "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/sql/parser.py"
click node_sql_executor "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/sql/executor.py"
click node_profiler "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/profiler.py"
click node_role_detector "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/role_detector.py"
click node_candidate_generator "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/candidate_generator.py"
click node_chart_scorer "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/scorer.py"
click node_vega_generator "https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/vega_generator.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_ui,node_query_input,node_results_view,node_chart_renderer,node_data_table,node_user toneBlue
class node_api_routes,node_access_dependencies,node_health,node_model_manager,node_model_registry,node_training,node_database_manager,node_schema_config,node_rules_config,node_redis,node_database toneAmber
class node_llama_engine,node_prompt_builder,node_output_parser toneMint
class node_sql_validator,node_sql_parser,node_sql_executor toneRose
class node_profiler,node_role_detector,node_candidate_generator,node_chart_scorer,node_vega_generator toneIndigo
```

## Components

### Query interface

- [Query and results UI](https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Query input](https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/QueryInput.jsx): `frontend/src/components/QueryInput.jsx`
- [Results view](https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/ResultsView.jsx): `frontend/src/components/ResultsView.jsx`
- [Chart renderer](https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/ChartRenderer.jsx): `frontend/src/components/ChartRenderer.jsx`
- [Data table](https://github.com/shubankar-sridhar/mlproject/blob/main/frontend/src/components/DataTable.jsx): `frontend/src/components/DataTable.jsx`

### API and access

- [API routes](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/routes.py): `src/pipeline2/api/routes.py`
- [Auth and rate limits](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/dependencies.py): `src/pipeline2/api/dependencies.py`
- [Health checks](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/health.py): `src/pipeline2/api/health.py`
- [Model manager](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/dependencies.py): `src/pipeline2/api/dependencies.py`
- [Model registry](https://github.com/shubankar-sridhar/mlproject/blob/main/models/registry/models/qwenModel/metadata.json): `models/registry/models/qwenModel/metadata.json`
- [Training job](https://github.com/shubankar-sridhar/mlproject/tree/main/src/pipeline2): `src/pipeline2`
- [Schema and rules](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/api/dependencies.py): `src/pipeline2/api/dependencies.py`
- [Database schema](https://github.com/shubankar-sridhar/mlproject/blob/main/configs/schema.json): `configs/schema.json`
- [Business rules](https://github.com/shubankar-sridhar/mlproject/blob/main/configs/business_rules.json): `configs/business_rules.json`

### SQL generation

- [Llama inference](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/inference/llama_engine.py): `src/pipeline2/inference/llama_engine.py`
- [Prompt builder](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/inference/prompt_builder.py): `src/pipeline2/inference/prompt_builder.py`
- [Structured output parser](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/inference/structured_output.py): `src/pipeline2/inference/structured_output.py`

### SQL execution

- [SQL validator](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/sql/validator.py): `src/pipeline2/sql/validator.py`
- [SQL parser](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/sql/parser.py): `src/pipeline2/sql/parser.py`
- [SQL executor](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/sql/executor.py): `src/pipeline2/sql/executor.py`

### Visualization

- [Result profiler](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/profiler.py): `src/pipeline2/visualization/profiler.py`
- [Role detector](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/role_detector.py): `src/pipeline2/visualization/role_detector.py`
- [Chart candidates](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/candidate_generator.py): `src/pipeline2/visualization/candidate_generator.py`
- [Candidate scorer](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/scorer.py): `src/pipeline2/visualization/scorer.py`
- [Vega-Lite generator](https://github.com/shubankar-sridhar/mlproject/blob/main/src/pipeline2/visualization/vega_generator.py): `src/pipeline2/visualization/vega_generator.py`

### Other components

- **User**
- **Rate-limit Redis**
- **Query database**

## Connections

- User → Query input: enters query (evidence: `frontend/src/components/QueryInput.jsx`)
- Query input → Query and results UI: submits (evidence: `frontend/src/App.jsx`)
- Query and results UI → API routes: sends query
- API routes → Auth and rate limits: checks access (evidence: `src/pipeline2/api/routes.py`)
- Auth and rate limits → Rate-limit Redis: checks limits
- API routes → Health checks: routes health (evidence: `src/pipeline2/api/routes.py`)
- API routes → Model manager: loads model (evidence: `src/pipeline2/api/routes.py`)
- Model manager → Model registry: reads metadata (evidence: `src/pipeline2/api/dependencies.py`)
- API routes → Training job: starts job (evidence: `src/pipeline2/api/routes.py`)
- API routes → Schema and rules: gets schema (evidence: `src/pipeline2/api/routes.py`)
- Schema and rules → Database schema: loads schema (evidence: `src/pipeline2/api/dependencies.py`)
- Schema and rules → Business rules: loads rules (evidence: `src/pipeline2/api/dependencies.py`)
- API routes → Llama inference: generates SQL (evidence: `src/pipeline2/api/routes.py`)
- Llama inference → Prompt builder: builds prompt (evidence: `src/pipeline2/inference/llama_engine.py`)
- Llama inference → Structured output parser: parses output (evidence: `src/pipeline2/inference/llama_engine.py`)
- API routes → SQL validator: validates SQL (evidence: `src/pipeline2/api/routes.py`)
- SQL validator → SQL parser: parses SQL (evidence: `src/pipeline2/sql/validator.py`)
- API routes → SQL executor: executes SQL (evidence: `src/pipeline2/api/routes.py`)
- SQL executor → Query database: queries
- API routes → Vega-Lite generator: generates chart spec (evidence: `src/pipeline2/api/routes.py`)
- Query and results UI → Results view: renders results (evidence: `frontend/src/App.jsx`)
- Results view → Chart renderer: renders chart (evidence: `frontend/src/components/ResultsView.jsx`)
- Results view → Data table: renders table (evidence: `frontend/src/components/ResultsView.jsx`)
