Skip to content

Commit 96ef0bf

Browse files
authored
Merge pull request #20 from nadeem4/feature/demo-env-setup
Feature/demo env setup
2 parents 678a0f2 + 6dc7a55 commit 96ef0bf

19 files changed

Lines changed: 975 additions & 163 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ chroma_db
2222
logs
2323

2424
site
25+
26+
data
27+
28+
last_reasoning.json

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@ Detailed documentation is available in the `docs/` directory.
2727

2828
---
2929

30-
## 🚀 Quick Start
30+
## 🚀 Try it Now (Demo)
31+
32+
The fastest way to experience the platform is the interactive demo. This sets up a "Manufacturing" environment with 4 SQLite databases and sample data.
33+
34+
```bash
35+
# 1. Setup Demo Environment
36+
nl2sql setup --demo
37+
38+
# 2. Run a Query
39+
nl2sql --env demo run "Show me broken machines in Austin"
40+
```
41+
42+
---
43+
44+
## 🛠️ Installation & Setup
3145

3246
### 1. Installation
3347

@@ -42,15 +56,15 @@ pip install -e packages/cli # Installs 'nl2sql' command
4256
# pip install -e packages/adapters/postgres
4357
```
4458

45-
### 2. Setup
59+
### 2. Setup (Production)
4660

47-
Run the interactive wizard to configure your database and LLM:
61+
Run the interactive wizard to configure your own database connections (Postgres, MySQL, etc.) and LLM:
4862

4963
```bash
5064
nl2sql setup
5165
```
5266

53-
*This will create your configuration files and index your schema.*
67+
*This will inspect your schema and index it into the vector store.*
5468

5569
### 3. Usage
5670

@@ -60,11 +74,13 @@ nl2sql setup
6074
nl2sql run "Show me the top 5 users by sales"
6175
```
6276

63-
**Other Commands**
77+
**Common Commands**
6478

65-
* `nl2sql doctor` - Diagnose environment issues.
79+
* `nl2sql index` - Re-index schemas and examples.
6680
* `nl2sql list-adapters` - Show installed database adapters.
67-
* `nl2sql benchmark` - Run evaluation suite.
81+
* `nl2sql doctor` - Diagnose environment issues.
82+
83+
> See [**CLI Reference**](docs/guides/cli_reference.md) for full documentation on flags like `--env` and `--role`.
6884
6985
---
7086

configs/datasources.demo.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
datasources:
2+
- id: manufacturing_ref
3+
connection:
4+
type: sqlite
5+
database: data\demo_lite\manufacturing_ref.db
6+
description: Master Data (Factories)
7+
- id: manufacturing_ops
8+
connection:
9+
type: sqlite
10+
database: data\demo_lite\manufacturing_ops.db
11+
description: Operational Data (Employees, Machines)
12+
- id: manufacturing_supply
13+
connection:
14+
type: sqlite
15+
database: data\demo_lite\manufacturing_supply.db
16+
description: Supply Chain (Inventory)
17+
- id: manufacturing_history
18+
connection:
19+
type: sqlite
20+
database: data\demo_lite\manufacturing_history.db
21+
description: Historical Data (Sales)

configs/policies.demo.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"admin": {
3+
"description": "Demo Admin",
4+
"role": "admin",
5+
"allowed_datasources": [
6+
"*"
7+
],
8+
"allowed_tables": [
9+
"*"
10+
]
11+
}
12+
}

configs/sample_questions.demo.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
manufacturing_ref:
2+
- List all factories in the US
3+
- Show me the capacity of Berlin Plant
4+
- What shifts are available?
5+
- List all machine types produced by TechCorp
6+
manufacturing_ops:
7+
- Show me active employees in the Austin Gigafactory
8+
- Which machines have error logs in the last 7 days?
9+
- Who is the operator for machine 5?
10+
- Count the number of active machines per factory
11+
- List maintenance logs for Vibration sensor alerts
12+
manufacturing_supply:
13+
- Total sales amount for 'Industrial Controller'
14+
- Find suppliers for high value components
15+
- Check inventory levels for 'Bolt M5' in Berlin
16+
- List products with base cost greater than 500
17+
- Show me suppliers from Germany
18+
manufacturing_history:
19+
- Show total sales orders in Q4
20+
- Calculate average production output per run
21+
- Summarize sales by customer for last year
22+
- List the top 5 largest orders

docs/guides/cli_reference.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# CLI Reference
2+
3+
The `nl2sql` Command Line Interface (CLI) is the primary way to interact with the platform.
4+
5+
## Global Options
6+
7+
These flags apply to all commands and must be specified **before** the subcommand.
8+
9+
* `--env`, `-e TEXT`: Environment name (e.g. `dev`, `demo`, `prod`). Isolates configurations and vector stores. Defaults to `default` (Production).
10+
11+
Example:
12+
13+
```bash
14+
# Uses configs/datasources.yaml
15+
nl2sql run "query"
16+
17+
# Uses configs/datasources.demo.yaml
18+
nl2sql --env demo run "query"
19+
```
20+
21+
## Commands
22+
23+
### `setup`
24+
25+
Interactive wizard to initialize the platform.
26+
27+
```bash
28+
nl2sql setup [OPTIONS]
29+
```
30+
31+
**Options:**
32+
33+
* `--demo`: **Quickstart Mode**. Automatically generates a "Manufacturing" demo environment with 4 SQLite databases and sample questions.
34+
* `--docker`: Used with `--demo` to generate a `docker-compose.yml` for full-fidelity testing (Postgres/MySQL) instead of SQLite.
35+
36+
### Example: Try it Now
37+
38+
```bash
39+
nl2sql setup --demo
40+
```
41+
42+
### `index`
43+
44+
Indexes database schemas and examples into the vector store for retrieval.
45+
46+
```bash
47+
nl2sql index [OPTIONS]
48+
```
49+
50+
**Features:**
51+
52+
* **Schema Indexing**: Introspects tables, columns, foreign keys, and comments.
53+
* **Example Indexing**: Indexes sample questions for few-shot routing.
54+
* **Granular Feedback**: Displays a checklist of indexed items per datasource.
55+
* **Summary Table**: Shows total tables, columns, and examples indexed.
56+
57+
**Options:**
58+
59+
* `--config PATH`: Path to datasource config.
60+
* `--vector-store PATH`: Path to vector store directory.
61+
62+
**Example:**
63+
64+
```bash
65+
nl2sql --env demo index
66+
```
67+
68+
### `run`
69+
70+
Executes a natural language query against the configured datasources.
71+
72+
```bash
73+
nl2sql run [QUERY] [OPTIONS]
74+
```
75+
76+
**Arguments:**
77+
78+
* `QUERY`: The natural language question (e.g. "Show me active users").
79+
80+
**Options:**
81+
82+
* `--role TEXT`: The RBAC role to assume (e.g. `admin`, `analyst`). Defaults to `admin`.
83+
* `--no-exec`: Plan and Validate only, do not execute SQL.
84+
* `--verbose`, `-v`: Show detailed reasoning traces and intermediate node outputs.
85+
* `--show-perf`: Display timing metrics.
86+
87+
**Example:**
88+
89+
```bash
90+
nl2sql run "Who bought the Bolt M5?" --role sales_analyst --verbose
91+
```
92+
93+
### `policy`
94+
95+
Manage RBAC policies.
96+
97+
* `validate`: Validates syntax and integrity of `policies.json`.
98+
99+
```bash
100+
nl2sql policy validate
101+
```
102+
103+
### `doctor`
104+
105+
Diagnoses environment issues (Python version, missing adapters, connectivity).
106+
107+
```bash
108+
nl2sql doctor
109+
```
110+
111+
### `benchmark`
112+
113+
Runs the evaluation suite against a "Golden Dataset".
114+
115+
```bash
116+
nl2sql benchmark --dataset configs/benchmark.yaml
117+
```

docs/guides/getting_started.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ The system will:
5252
2. Route it to the correct database.
5353
3. Generate and Validate SQL.
5454
4. Execute and display the results.
55+
56+
## Next Steps
57+
58+
Explore the full capabilities of the CLI:
59+
60+
* [CLI Reference](cli_reference.md) - Learn about `--env`, `--role`, and `index` options.
61+
* [Configuration](configuration.md) - Connect to your own databases.

0 commit comments

Comments
 (0)