Anon ERP NL2SQL Assistant is a fully anonymous, ERP-agnostic template that converts natural language questions into safe, read-only SQL queries for ERP reporting systems.
This repository is designed as a production-ready foundation, not a demo:
- No company name
- No ERP product name
- No real table/column names
- No IPs, credentials, or private endpoints
All real-world details are injected only via configuration files.
- Clean, modular architecture
- Provider-agnostic LLM integration (OpenAI & Gemini)
- SQL safety layer (SELECT-only, allowlist-based)
- Easy to extend with caching, UI, or analytics layers
- Ask questions without writing SQL
- Control which ERP tables and columns are accessible
- Prevent destructive queries by design
- Use ERP terminology instead of technical SQL syntax
- 🔍 Database schema introspection (allowlist-based)
- 🧠 Natural Language → SQL (NL2SQL)
- 🔐 SQL security guard:
- SELECT only
- No INSERT / UPDATE / DELETE / DROP / ALTER
- No multi-statement queries
- 🔁 Single interface for OpenAI GPT and Google Gemini
- 🧾 Detailed usage logging (anonymous)
- 🏢 ERP-agnostic (works with any SQL-based ERP)
User Question (Natural Language)
↓
Role & Permission Context
↓
Allowed ERP Schema (Allowlist)
↓
Prompt Construction
↓
LLM (OpenAI or Gemini)
↓
SQL Safety Guard
↓
(Optional) Database Execution
↓
Result + Logs
- LLM never sees database names or credentials
- Only explicitly allowed tables/columns are exposed
- All generated SQL is validated before execution
- Read-only reporting use case by design
app/
├─ main.py # Application entry point
├─ api/ # REST endpoints (/ask, /health)
├─ nl2sql/ # NL → SQL pipeline
├─ llm/ # OpenAI & Gemini adapters
├─ db/ # Database connection & execution
├─ schema/ # Schema introspection
├─ security/ # SQL guard & policies
└─ core/ # Config, logging, shared utilities
policies/
└─ allowlist.json # ERP table/column permissions
python -m venv .venv
pip install -r requirements.txt
cp .env.example .env
python -m app.mainYou must edit:
OPENAI_API_KEYorGEMINI_API_KEYDB_DIALECT(mssql / postgres / mysql)DB_DSNor connection parameters
ERP consultants define:
- Which tables are visible
- Which columns are allowed
- Optional column aliases (business-friendly names)
LLM cannot access anything outside this file.
Developers may fine-tune:
app/nl2sql/prompt_builder.py- Add ERP-specific terminology
- Add KPI examples
Extend:
security/roles.pyto create roles like:- finance
- sales
- warehouse
- management
- Add Excel / PDF export
- Add dashboard UI (React, Dash, etc.)
- Add query history page
- Authentication via ERP user tables
- Query caching
- Column masking for sensitive data
- Multi-company / multi-year routing
- Audit dashboard
Anon ERP NL2SQL Assistant, ERP sistemleri üzerinde doğal dille SQL raporu oluşturmak için tasarlanmış, tamamen anonim ve ERP-bağımsız bir altyapıdır.
Bu repo:
- Şirket adı içermez
- ERP ürünü içermez
- Gerçek tablo / kolon içermez
- IP, şifre, kullanıcı bilgisi barındırmaz
- Modüler mimari
- OpenAI & Gemini tek altyapı
- SQL güvenlik katmanı
- Kurumsal entegrasyona uygun
- SQL yazmadan rapor
- Kontrollü tablo erişimi
- Veri silme riski olmadan analiz
- Doğal dil → SQL
- Sadece SELECT sorguları
- Çoklu SQL engeli
- ERP-bağımsız yapı
- Güvenli loglama
- API key girilecek
- DB bağlantısı yazılacak
ERP danışmanı:
- Hangi tablolar?
- Hangi kolonlar?
- Hangi iş terimleri?
- ERP terimleri
- KPI tanımları
- Tarih, para birimi kuralları
- Finans / Satış / Depo
- Yönetici rolleri
- Excel
- Dashboard
Bu repo:
- Kurumsal ERP NL2SQL projeleri için
- Güvenli, anonim, sürdürülebilir
- Gerçek hayata uygun bir çekirdek mimaridir.