InsightOS: Local-First Spreadsheet-to-SQLite App, Read-Only SQL Workbench, Positive/Negative SVG Charts and Schema-Only Local/Cloud AI
Spreadsheet-to-SQLite 3-Layer Read-Only Lock SQL Workbench Double-Checked NL-to-SQL Ollama + Schema-Only Cloud AI SVG/PNG Charts & Reports
Flagship Local-First Data App • Verified NL-to-SQL • SQL Workbench (:8113)

InsightOS: Local-First Spreadsheet-to-SQLite App, SQL Workbench & Verified Local/Cloud AI

Summary

InsightOS (Port 8113, standalone cross-platform app with MIT license) turns messy .xlsx, .xlsm, .xls, .ods, .csv, and .tsv workbooks into a private, editable SQLite database application with zero preloaded data, zero graphics-card requirements, and zero silent drops. Every workbook starts clean—streaming large sheets into normalized tables, deduplicating re-imported sheets, unifying multi-year tabs, and exposing a review screen where every type inference, skipped summary row, and table link can be inspected or customized via a manual + Add link… builder. Pair it with the built-in read-only SQL Workbench, live filtered column summaries (Sum · Avg · Min–Max), positive/negative SVG & PNG charts, snapshots/undo, scheduled PDF/Excel reports, and verified double-checked NL-to-SQL backed by Local Ollama by default or opt-in schema-only Cloud AI (OpenAI, Google Gemini, Anthropic Claude, or any OpenAI-compatible API).

Key Capabilities

  • Zero-Silent-Drop Spreadsheet Ingestion & Manual Table Links: Imports .xlsx (row-streaming), .xlsm, .xls, .ods, .csv, and .tsv files into SQLite—separating stacked tables on one sheet, preventing double-counting on re-imports, grouping yearly tabs into unified logical views, deduplicating people across sheets/years, and allowing custom cross-table joins via + Add link… preserved across schema refreshes.
  • 3-Layer Read-Only SQLite Sandbox & Direct SQL Workbench: Both user queries in SQL Workbench (POST /api/ws/{ws}/sql) and AI-generated queries run behind three independent locks—a read-only SQLite connection, a database-level authorizer blocking writes and internal bookkeeping tables, and a single-SELECT AST parser with row and timeout caps. Click Edit SQL on any AI answer or Overview card to inspect, modify, re-run, pin, or export immediately.
  • Local Ollama Default + Optional Schema-Only Cloud AI: Runs 100% offline with local Ollama (qwen2.5-coder:7b) and background warm-up progress ETA, or connects optionally to OpenAI, Google Gemini, Anthropic Claude, or any OpenAI-compatible endpoint (pure stdlib HTTP, 0600 local key storage, masked API responses). Cloud providers receive only table/column schemas, pick-list values, notes, and your question—never raw table rows or PII.
  • Deterministic Query Checks, Double-Check Mode & Human-in-the-Loop Learning: Every AI-generated query passes deterministic non-LLM verification (filter-value existence, case auto-repair, year discipline, join inflation/drop measurement, missing-concept refusal, and unreadable-cell disclosure) with up to 3 automatic repair rounds plus independent double-check cross-validation. Supports clarifying questions, glossary notes, verdict learning, searchable/paginated Ask history, and per-answer deletion.
  • Live Filtered Column Summaries, Negative-Value Charts & Full Export Pipeline: Browse and edit records with typo-catching pick-list forms, live Sum / Avg / Min–Max summaries over filtered rows, full audit log with 1-click Undo, and automatic pre-import snapshots. Pin any query or answer to a configurable Overview supporting positive, negative, and mixed-sign bar/line charts with SVG & PNG downloads, CSV/Excel exports, portable .zip workspace bundles, and scheduled PDF/Excel reports across 3 themes (Classic, Midnight, Executive).
  • Automated Data-Quality Diagnostics & Verified Test Suite: Runs pure-data anomaly scans (outliers, negative money, impossible dates, malformed emails, orphaned IDs) without an LLM. Verified end-to-end with 184 passing unit & API tests, 38/38 ingestion & data-integrity checks, 108/108 chart geometry checks, and 7 Node/jsdom UI journeys (62/62 steps, 0 page errors).

Tech Stack

  • Backend & Storage Engine: Python 3.10+, FastAPI, Uvicorn, SQLite3 (WAL + read-only authorizer sandbox), streaming openpyxl/xlrd/.ods/CSV parser (ingest.py, model.py, store.py, crud.py, reimport.py, snapshots.py)
  • Verified NL-to-SQL & Multi-Provider Gateway: 3-layer SQL sandbox (guard.py), deterministic non-LLM query verifier (sqlcheck.py), double-checked query planner & clarifying disambiguation (nlq.py, knowledge.py), stdlib-HTTP Ollama + OpenAI/Gemini/Claude/OpenAI-compatible client (llm.py, appsettings.py)
  • Analytics, Charting & Reporting: Pure Vanilla ES6 Frontend (17 modular JS files including sql.js, ai_settings.js, charts.js, setup.js, data.js, ask.js, overview.js), custom zero-baseline SVG/PNG chart renderer, anomaly scanner (quality.py), Excel/PDF/ZIP bundle exporter & scheduled report engine (exporter.py, reports.py)
  • Verification Harness: 184 pytest unit & live-HTTP API tests, 38-check self-test suite (selftest.py), 108-case chart geometry validator, and 7 Node/jsdom front-end journeys (62 steps)

Theory & Architecture

Most “chat with your spreadsheet” tools fail in practice for three reasons: they upload raw private rows to external APIs, let LLMs hallucinate column values or silently inflate totals via bad joins, and lock analysts out of inspecting or fixing the underlying SQL. InsightOS separates probabilistic query drafting from deterministic data execution. Spreadsheets are promoted into a real local SQLite schema with full provenance; the model sees only schema metadata and pick-lists; every generated query is validated by deterministic rules and optional second-draft double-checking inside a 3-layer read-only SQLite lock; and analysts can jump straight from any AI answer into the read-only SQL Workbench with one click—keeping data private, auditable, and 100% usable even with zero AI configured.