Skip to main content

DB schema extraction to semantic layer for self-service analytics with local LLMs

Project description

Schemalytics

Semantic Layer for Self-Service Analytics

Schemalytics transforms your database into an LLM-ready semantic layer that enables self-service analytics. It analyzes your schema, generates dimensional models, and creates comprehensive metadata that LLMs can use to write accurate SQL queries—all running locally with complete privacy.

The tool generates a complete dbt project as the implementation layer, following dimensional modeling best practices with medallion architecture (Bronze → Silver → Gold).

Key features:

  • Semantic layer generation - LLM-ready metadata with metrics, relationships, and query patterns
  • Self-service analytics - Enable natural language queries against your data
  • Privacy-first - Runs on local LLMs (Ollama) by default; Anthropic supported via env var
  • Agentic pipeline - Five focused AI agents infer industry, metrics, and table roles from schema metadata alone
  • Interactive refinement - Review and refine the generated data model through natural language feedback

Quick Start

1. Install prerequisites

# Install Ollama (default provider)
curl -fsSL https://ollama.com/install.sh | sh
ollama pull gemma3-data

# Install Schemalytics
pip install schemalytics

2. Generate semantic layer + dbt project

schemalytics generate \
  -c postgresql://localhost/mydb \
  -o ./dbt_project

3. Agentic pipeline + interactive refinement

  • Agent 1 infers your industry and domain from schema metadata
  • Agent 2 suggests metrics, goals, and reporting grain
  • Agent 3 classifies each table as fact, dimension, bridge, or reference
  • You review a consolidated summary and correct anything wrong
  • Agent 4 generates a full modeling plan; you refine it with natural language ("make revenue weekly", "add customer LTV")
  • Press Enter to approve and generate the dbt project

Optional: use Anthropic instead of Ollama

SCHEMALYTICS_LLM_PROVIDER=anthropic \
ANTHROPIC_API_KEY=sk-ant-... \
schemalytics generate -c postgresql://localhost/mydb -o ./dbt_project

What You Get

  • Semantic layer (semantic_layer.yml) - Complete metadata for LLM-powered analytics
  • Bronze models - Raw data staging layer (stg_<schema>_<table>)
  • Silver models - Facts (fct_*) and dimensions (dim_*) in star schema
  • Gold models - Pre-aggregated metrics (agg_<grain>_<metric>)
  • Documentation - Auto-generated schema.yml files

CLI

# Full agentic pipeline
schemalytics generate -c postgresql://user:pass@localhost/db -o ./dbt_project

# Schema extraction only
schemalytics extract -c postgresql://user:pass@localhost/db -o schema.json

License

Apache 2.0 • Built by NiChr0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schemalytics-0.2.0.tar.gz (112.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

schemalytics-0.2.0-py3-none-any.whl (116.8 kB view details)

Uploaded Python 3

File details

Details for the file schemalytics-0.2.0.tar.gz.

File metadata

  • Download URL: schemalytics-0.2.0.tar.gz
  • Upload date:
  • Size: 112.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for schemalytics-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c237364da2a61ee5c3fbed8939370ddb1d2da41682270f4c2c8fe38cb12129de
MD5 72cccd3335169546e787d0a2626d2456
BLAKE2b-256 6058b67d576e8fd8609cb0dff77e4cbd5c3dd503e1313590680c47bee7f2807b

See more details on using hashes here.

File details

Details for the file schemalytics-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: schemalytics-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 116.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for schemalytics-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b1e2eb4212b3cacc6c2033040c186377ab04d532879717595bc6c92e858004c
MD5 00a2a45632729b7ae060b2da6dc91472
BLAKE2b-256 17f6a346c9543e8b6cd27c3ec00d396087b821e844bd995f1ce82bfa287b4fd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page