LeanUI Docs
← Open LeanUI Studio GitHub

Connect Real Data, APIs & Relational Tables#

LeanUI lets you connect live external APIs, realtime cloud collections, MS Access–style relational tables with Foreign Keys, and local CSV/JSON files directly to your UI — while formally verifying endpoints, primary keys, foreign key references, and query pipelines.


Choosing a Data Source Provider#

Add a Data Source (datasource) node to your graph and pick any of the 9 built-in providers in the Property Inspector:

CategoryProviderBest For
Live Web APIshacker_news, rest, graphql, websocketFetching live JSON APIs, public feeds, GraphQL endpoints, and streaming updates.
Realtime Syncfirebase_rtdb, firestoreLive multi-tab synced documents (via Firebase REST or built-in local BroadcastChannel realtime emulator + security rules).
Relational Tablesms_access, sql_dbLocal relational databases with Autonumber primary keys, verified Foreign Keys, lookup dropdown Auto-Forms, and SQL JOINs.
Local Fileslocal_fileLetting users upload/import and export .csv, .tsv, .json, or .ndjson files right in the browser.
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Live Annotated AccessOrderDatabase Graph — Relational Tables, Foreign Key Verification & JOIN Query Pipeline Live Annotated AccessOrderDatabase Graph — Relational Tables, Foreign Key Verification & JOIN Query Pipeline
Live Annotated AccessOrderDatabase Graph — Relational Tables, Foreign Key Verification & JOIN Query Pipeline

Walkthrough 1: Connect a Live REST / Hacker News API#

Try the ready-made preset: Select Hacker News Reader (Live API) in the topbar Preset dropdown to see this complete pipeline live.

  1. Add a Data Source (StoriesSource):
    • Set provider: hacker_news (or rest with your API URL, e.g., https://api.example.com/items).
    • Define the record schema fields (e.g., id, title, score, by, url).
  2. Add a reactive search State (searchText) and an Input control wired to searchText.value.
  3. Add a Data Query (FilteredStories):
    • Wire StoriesSource.rows → FilteredStories.source.
    • Wire searchText.val → FilteredStories.filterVal.
    • Set searchField: title, orderBy: score, orderDir: desc, limit: 20.
  4. Display the results:
    • Add a Table or List node and wire FilteredStories.rows → Table.rows.
    • Optionally add a Stat tile wired to FilteredStories.count or a Chart wired to FilteredStories.rows!
  5. Add a Refresh Button:
    • Wire RefreshBtn.onClick → StoriesSource.refresh so users can re-fetch live data on demand.

Walkthrough 2: Build an MS Access / SQL Relational App with Foreign Keys#

Try the ready-made preset: Select MS Access Orders DB (FK + Join) in the topbar Preset dropdown.

  1. Create the parent table (CustomersTable):
    • Add a datasource with provider: ms_access, tableName: customers, primaryKey: id (autonumber), and columns id, name, tier.
  2. Create the child table (OrdersTable):
    • Add a datasource with provider: ms_access, tableName: orders, primaryKey: id, and a Foreign Key rule: customerId → customers.id.
    • LeanUI automatically verifies referential integrity (DATA004 + Lean 4 foreign_keys_valid) and generates an inline Auto-Form with a Customer lookup dropdown!
  3. Join both tables with Data Query (OrdersWithCustomer):
    • Wire OrdersTable.rows → OrdersWithCustomer.source.
    • Wire CustomersTable.rows → OrdersWithCustomer.joinWith.
    • Configure joinType: INNER, joinLocalKey: customerId, joinForeignKey: id, and aggregateField: amount.
  4. Bind to UI & Charts:
    • Wire OrdersWithCustomer.rows into a sortable Table and an inline SVG Chart, and wire OrdersWithCustomer.sum into a Stat KPI tile (Total Revenue).

Walkthrough 3: Realtime Firebase Sync & Local CSV Import#

Try the ready-made preset: Select Firebase Live & Local CSV in the topbar Preset dropdown.

  • Realtime Multi-Tab Sync: Choose provider: firestore or firebase_rtdb. Without entering cloud credentials, LeanUI runs a live browser BroadcastChannel + localStorage realtime emulator — open two browser tabs side-by-side and watch edits sync instantaneously! When ready for production, supply your live Firebase endpoint and declarative security rules.
  • CSV / JSON File Import: Add a datasource with provider: local_file (csv, tsv, json, or ndjson). Studio renders a built-in drag-and-drop file uploader & exporter directly inside Live Preview.

Formal Data Verification#

Every datasource and data_query is checked automatically by both @leanui/verifier and Lean 4 (λ Prove):

  • DATA001–DATA003: Validates provider endpoints, schemas, and required primary keys.
  • DATA004 (foreign_keys_valid): Proves every Foreign Key targets an existing table and key column with no orphan references.
  • DATA005 (data_queries_valid): Proves every JOIN, WHERE, ORDER BY, and aggregate references valid columns.
Diagram Preview
Enlarged diagram