KPIAssembler
KPIAssembler discovers application schemas, proposes business metrics, and certifies generated SQL before a number is trusted.
The LLM proposes. Deterministic code certifies.
A separate Python implementation lives at kpi-assembler-python.
Install (Rails)
# Gemfile
gem "kpi_assembler", "~> 0.5"bundle install
bin/rails generate kpi_assembler:install# config/routes.rb
mount KPIAssembler::Engine => "/kpi-assembler"Then:
- Edit
config/initializers/kpi_assembler.rb(database pool, tenant, auth). - Set
GEMINI_API_KEYandKPI_LLM_PROVIDER=geminiin the host.env, or use Ollama /KPI_USE_LLM=false. - Restart the app and open
/kpi-assembler.
Full walkthrough, env vars, and troubleshooting: Setup guide.
Rails engine details: docs/rails-engine.md. Standalone Rack/CLI/API: docs/integration.md.
What it does
- Discover — introspect tables, columns, and foreign keys
- Propose — Gemini, Ollama, or schema heuristics draft KPI SQL
- Accept — you choose which candidates to certify
- Certify — read-only SELECT, join safety, tenant scope, planner, sample run
- Publish — certified pack as JSON (and HTML from the CLI)
Rejected candidates never reach certification. Draft means a selected KPI failed a certification check.
Requirements
- Ruby >= 3.0
- Rails 7 for the engine
- Read-only database access (replica or reporting user)
License
MIT