# pranavv-07/nlp-to-sql-generator architecture

> Architecture diagram of the GitHub repository pranavv-07/nlp-to-sql-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pranavv-07/nlp-to-sql-generator
- Repository: https://github.com/pranavv-07/nlp-to-sql-generator

## Overview

Restaurant Intelligence is an offline Flask application for asking plain-English questions of a restaurant SQLite database. The main workflow runs through the Flask app, which orchestrates tokenisation, POS tagging, lemmatisation, entity and intent recognition, schema mapping, SQL generation, validation, and execution; results can then be displayed as tables, KPI cards, or charts. The README also documents a dashboard and visual NLP pipeline, while the tree includes history and database pages. UI wiring and those page behaviors are only partly evidenced by the supplied excerpts, so those links are documented at a high level.

Main entry points: [`app.py`](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/app.py) (Flask app), [`restaurant.db`](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/restaurant.db) (Restaurant database), [`static/js/app.js`](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/static/js/app.js) (Browser interactions), [`database.py`](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/database.py) (SQLite access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_flask["Flask app<br/>[app.py]"]
  node_pages["Web pages"]
  node_browser["Browser interactions<br/>[app.js]"]
  node_charts["Charts<br/>[charts.js]"]
end

subgraph group_nlp["Language pipeline"]
  node_tokenizer["Tokeniser<br/>[tokenizer.py]"]
  node_pos["POS tagger<br/>[pos_tagger.py]"]
  node_lemma["Lemmatizer<br/>[lemmatizer.py]"]
  node_entities["Entity recogniser"]
  node_intent["Intent classifier<br/>[intent.py]"]
  node_mapping["Schema mapping<br/>[schema_mapper.py]"]
end

subgraph group_query["Query processing"]
  node_generator["SQL generator<br/>[sql_generator.py]"]
  node_validator["SQL validator<br/>[validator.py]"]
end

subgraph group_data["Restaurant data"]
  node_dbaccess["SQLite access<br/>[database.py]"]
  node_store[("Restaurant database<br/>[restaurant.db]")]
  node_seeder["Demo data seeder<br/>[seed_database.py]"]
end

node_user(("Restaurant user"))

node_user -.->|"opens pages"| node_pages
node_user -.->|"asks query"| node_flask
node_flask -->|"tokenises"| node_tokenizer
node_flask -->|"tags tokens"| node_pos
node_flask -->|"lemmatises"| node_lemma
node_flask -->|"recognises entities"| node_entities
node_flask -->|"classifies intent"| node_intent
node_flask -->|"maps schema"| node_mapping
node_flask -->|"generates SQL"| node_generator
node_flask -->|"validates SQL"| node_validator
node_flask -->|"executes query"| node_dbaccess
node_dbaccess -->|"reads and writes"| node_store
node_seeder -->|"seeds data"| node_store
node_flask -.->|"returns results"| node_browser
node_browser -.->|"renders charts"| node_charts
node_flask -->|"queries dashboard"| node_store

click node_flask "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/app.py"
click node_pages "https://github.com/pranavv-07/nlp-to-sql-generator/tree/main/templates"
click node_browser "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/static/js/app.js"
click node_charts "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/static/js/charts.js"
click node_tokenizer "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/tokenizer.py"
click node_pos "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/pos_tagger.py"
click node_lemma "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/lemmatizer.py"
click node_entities "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/entity_recognizer.py"
click node_intent "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/intent.py"
click node_mapping "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/schema_mapper.py"
click node_generator "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/sql_generator.py"
click node_validator "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/validator.py"
click node_dbaccess "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/database.py"
click node_store "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/restaurant.db"
click node_seeder "https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/seed_database.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_flask,node_pages,node_browser,node_charts,node_user toneBlue
class node_tokenizer,node_pos,node_lemma,node_entities,node_intent,node_mapping toneAmber
class node_generator,node_validator toneMint
class node_dbaccess,node_store,node_seeder toneRose
```

## Components

### Web experience

- [Flask app](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/app.py): `app.py`
- [Web pages](https://github.com/pranavv-07/nlp-to-sql-generator/tree/main/templates): `templates`
- [Browser interactions](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/static/js/app.js): `static/js/app.js`
- [Charts](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/static/js/charts.js): `static/js/charts.js`

### Language pipeline

- [Tokeniser](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/tokenizer.py): `nlp/tokenizer.py`
- [POS tagger](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/pos_tagger.py): `nlp/pos_tagger.py`
- [Lemmatizer](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/lemmatizer.py): `nlp/lemmatizer.py`
- [Entity recogniser](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/entity_recognizer.py): `nlp/entity_recognizer.py`
- [Intent classifier](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/intent.py): `nlp/intent.py`
- [Schema mapping](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/schema_mapper.py): `nlp/schema_mapper.py`

### Query processing

- [SQL generator](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/sql_generator.py): `nlp/sql_generator.py`
- [SQL validator](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/nlp/validator.py): `nlp/validator.py`

### Restaurant data

- [SQLite access](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/database.py): `database.py`
- [Restaurant database](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/restaurant.db): `restaurant.db`
- [Demo data seeder](https://github.com/pranavv-07/nlp-to-sql-generator/blob/main/seed_database.py): `seed_database.py`

### Other components

- **Restaurant user**

## Connections

- Restaurant user → Web pages: opens pages (evidence: `README.md`)
- Restaurant user → Flask app: asks query (evidence: `README.md`)
- Flask app → Tokeniser: tokenises (evidence: `app.py`)
- Flask app → POS tagger: tags tokens (evidence: `app.py`)
- Flask app → Lemmatizer: lemmatises (evidence: `README.md`)
- Flask app → Entity recogniser: recognises entities (evidence: `README.md`)
- Flask app → Intent classifier: classifies intent (evidence: `README.md`)
- Flask app → Schema mapping: maps schema (evidence: `app.py`)
- Flask app → SQL generator: generates SQL (evidence: `app.py`)
- Flask app → SQL validator: validates SQL (evidence: `app.py`)
- Flask app → SQLite access: executes query (evidence: `app.py`)
- SQLite access → Restaurant database: reads and writes (evidence: `database.py`)
- Demo data seeder → Restaurant database: seeds data (evidence: `seed_database.py`)
- Flask app → Browser interactions: returns results (evidence: `README.md`)
- Browser interactions → Charts: renders charts (evidence: `README.md`)
- Flask app → Restaurant database: queries dashboard (evidence: `app.py`)
