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:
| Category | Provider | Best For |
|---|---|---|
| Live Web APIs | hacker_news, rest, graphql, websocket | Fetching live JSON APIs, public feeds, GraphQL endpoints, and streaming updates. |
| Realtime Sync | firebase_rtdb, firestore | Live multi-tab synced documents (via Firebase REST or built-in local BroadcastChannel realtime emulator + security rules). |
| Relational Tables | ms_access, sql_db | Local relational databases with Autonumber primary keys, verified Foreign Keys, lookup dropdown Auto-Forms, and SQL JOINs. |
| Local Files | local_file | Letting users upload/import and export .csv, .tsv, .json, or .ndjson files right in the browser. |
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.
- Add a
Data Source(StoriesSource):- Set
provider: hacker_news(orrestwith your API URL, e.g.,https://api.example.com/items). - Define the record schema fields (e.g.,
id,title,score,by,url).
- Set
- Add a reactive search
State(searchText) and anInputcontrol wired tosearchText.value. - Add a
Data Query(FilteredStories):- Wire
StoriesSource.rows → FilteredStories.source. - Wire
searchText.val → FilteredStories.filterVal. - Set
searchField: title,orderBy: score,orderDir: desc,limit: 20.
- Wire
- Display the results:
- Add a
TableorListnode and wireFilteredStories.rows → Table.rows. - Optionally add a
Stattile wired toFilteredStories.countor aChartwired toFilteredStories.rows!
- Add a
- Add a Refresh Button:
- Wire
RefreshBtn.onClick → StoriesSource.refreshso users can re-fetch live data on demand.
- Wire
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.
- Create the parent table (
CustomersTable):- Add a
datasourcewithprovider: ms_access,tableName: customers,primaryKey: id(autonumber), and columnsid,name,tier.
- Add a
- Create the child table (
OrdersTable):- Add a
datasourcewithprovider: ms_access,tableName: orders,primaryKey: id, and a Foreign Key rule:customerId → customers.id. - LeanUI automatically verifies referential integrity (
DATA004+ Lean 4foreign_keys_valid) and generates an inline Auto-Form with a Customer lookup dropdown!
- Add a
- Join both tables with
Data Query(OrdersWithCustomer):- Wire
OrdersTable.rows → OrdersWithCustomer.source. - Wire
CustomersTable.rows → OrdersWithCustomer.joinWith. - Configure
joinType: INNER,joinLocalKey: customerId,joinForeignKey: id, andaggregateField: amount.
- Wire
- Bind to UI & Charts:
- Wire
OrdersWithCustomer.rowsinto a sortableTableand an inline SVGChart, and wireOrdersWithCustomer.suminto aStatKPI tile (Total Revenue).
- Wire
Walkthrough 3: Realtime Firebase Sync & Local CSV Import#
Try the ready-made preset: Select
Firebase Live & Local CSVin the topbar Preset dropdown.
- Realtime Multi-Tab Sync: Choose
provider: firestoreorfirebase_rtdb. Without entering cloud credentials, LeanUI runs a live browserBroadcastChannel+localStoragerealtime 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
datasourcewithprovider: local_file(csv,tsv,json, orndjson). 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 everyJOIN,WHERE,ORDER BY, and aggregate references valid columns.