Skip to main content

Lakehouse Integration Architecture

The AINative Lakehouse is a MinIO/Parquet/DuckDB architecture that ingests, enriches, and serves data across ZeroDB services, the agent swarm, and the recursive intelligence loop.

Data Inventory​

DatasetRecordsSourceUpdate Frequency
SMB Businesses264,632Socrata Open Data (6 cities)Weekly cron
Federal Grants900USAspending.govMonthly
WHOIS Cache363 (54 enriched)Apollo/Hunter/WHOISDaily DAG
SC County Parcels97,182Santa Cruz CountyMonthly
Knowledge Graph Entities39,714CRM + Enrichment + GrantsDaily
Knowledge Graph Edges49,326works_at, connected_to, received_grant_fromDaily
Paul Graham Essays231paulgraham.comOn-demand
Video Transcripts1,275+YouTube (5 channels)Weekly

SMB City Coverage​

CityRecordsSource API
Denver50,000Colorado SOS (data.colorado.gov)
Los Angeles50,000LA Business Tax (data.lacity.org)
Seattle50,000WA State (data.wa.gov)
San Francisco50,000SF Business Registry (data.sfgov.org)
New York City43,581NYC Business Licenses (data.cityofnewyork.us)
Austin21,051Austin Food Establishments (data.austintexas.gov)

Connectors​

All connectors are Python scripts in scripts/:

ConnectorScriptWhat It Does
SMB Citysmb_city_connector.pyPulls business data from Socrata APIs for 6 US cities
Federal Grantsfederal_grants_connector.pyFetches grant data from USAspending.gov
WHOIS Discoverywhois_discovery_domains.pyEnriches domains with WHOIS data
Montana Livestockmontana_livestock_connector.pyAuction market data
Montana Web3montana_web3_connector.pyCrypto/blockchain entities
SC Countysanta_cruz_county_connector.pyProperty parcel data
SMB Enrichmentsmb_enrichment_pipeline.pyApollo/Hunter/WHOIS/LinkedIn enrichment
Grant Graphbuild_grant_graph_edges.pyBuilds KG edges between grants and SMB businesses
PGWisdompgwisdom_connector.pyPaul Graham essays → lakehouse + ZeroMemory
Video Transcriptsresearch_agent.pyYouTube transcript ingestion (5 channels)

Recursive Integration Loop​

The lakehouse data feeds into ZeroDB services via 4 Celery tasks:

Lakehouse Data
↓
lake.export_marketplace_data (05:00 UTC daily)
→ SMB/grants/WHOIS → Parquet lakehouse (MinIO)
↓
lake.sync_graph_to_zerodb (05:30 UTC daily)
→ KG entity/edge updates → ZeroDB events
↓
lake.emit_lakehouse_signals (06:00 UTC daily)
→ Data snapshot → ZeroMemory agent signals
↓
Agent Swarm (Scout, Vega, Aurora)
→ Consumes signals, triggers downstream actions
↓
lake.score_seed_quality (on project creation)
→ RLHF feedback on auto-seeded prospect quality
→ Feeds back into enrichment DAG adjustments

Auto-Seed Pipeline​

When a new project is created:

  1. POST /api/v1/projects dispatches seed_new_project.delay()
  2. Task pulls 500 prospects from SMB directory + WHOIS data
  3. Scores each prospect with get_lead_score() (0-100)
  4. Stores as rows in project's prospects table
  5. Triggers score_seed_quality for RLHF feedback

Optional params: industry (saas, ecommerce, finance, healthcare, realestate) and city.

GraphRAG Prospecting​

POST /api/v1/public/data/prospect — Hybrid search combining:

  • Text relevance (40%): Full-text search against SMB businesses
  • Graph proximity (30%): Companies connected to CRM contacts or grant recipients rank higher
  • Lead score (30%): Enrichment pipeline score (phone, WHOIS, tech stack, city)

Video Transcription Channels​

ChannelVideosTags
Peter Diamandis864moonshots, exponential-tech
This Week in Startups149startups, venture-capital
Anthropic Official140anthropic, claude, ai-safety
Claude Official103claude-code, developer-tools
AINative AI Agents19agent-cloud, ai-agents

Transcripts stored in scripts/outputs/transcripts/ and ingested to ZeroMemory.

Key Files​

FilePurpose
scripts/smb_city_connector.pySMB business data ingestion
scripts/smb_enrichment_pipeline.pyMulti-source enrichment
scripts/build_grant_graph_edges.pyGrant → company KG edges
scripts/pgwisdom_connector.pyPaul Graham essays
scripts/research_agent.pyYouTube transcript ingestion
src/backend/app/celery_tasks/lakehouse_integration_tasks.py4 integration Celery tasks
src/backend/app/celery_tasks/seed_project_task.pyAuto-seed on project creation
src/backend/app/api/v1/endpoints/graphrag_prospect.pyGraphRAG prospecting API
src/backend/app/api/v1/endpoints/data_marketplace.pyData marketplace endpoints
src/backend/app/services/seed_data.pySeed data service
services/airflow/dags/smb_enrichment_dag.pyDaily enrichment DAG

Multi-Tenant Isolation​

The lakehouse is multi-tenant. Two distinct data planes share the MinIO infrastructure but are kept isolated:

  • Internal platform lake (ainative-lake) — AINative's own agent telemetry, platform metrics, and external datasets. Admin/agent access only. See the internal Data Lake API.
  • Customer lakehouse (ainative-lakehouse) — per-project customer data, exposed as the project-scoped ZeroDB Lakehouse.

Partition layout (Refs #5246)​

Every object is written under a tenant prefix so storage is attributable and isolatable per project/tenant:

ainative-lakehouse/
└── tenant={project_id}/
└── {sensor_type}/
└── date=YYYY-MM-DD/
└── batch_*.parquet

Untagged internal ingestion is attributed to INTERNAL_TENANT_ID (AINative bills itself "like a customer"). LakehouseWriter.write_parquet(..., tenant_id=) keys batches by (tenant_id, sensor_type) so two tenants never share a file.

Read scoping (Refs #5270, #5271)​

The customer query path is project-scoped end to end — the same model as every other ZeroDB project service:

  1. Ownership — _get_project_or_404(project_id, user.id, db) on every endpoint (query, tables, stats, connectors). Non-owner → 404.
  2. Scoped globs — scoped_query.scoped_parquet_glob(project_id, sensor) builds tenant={project_id}/{sensor}/** only. Listings pass Prefix=tenant={project_id}/.
  3. SQL sandbox — validate_scoped_sql allows a single SELECT/WITH over logical table names and rejects raw path access (s3://, read_parquet, read_csv, glob, ATTACH, COPY, SET, PRAGMA, INSTALL, LOAD, multi-statement). rewrite_tables expands logical names to the caller's scoped read_parquet() glob; the bare name never reaches DuckDB. The DuckDB connection is locked (lock_configuration) after credentials are set.

Result: a project can only ever read its own partition. Cross-tenant reads are impossible at both the engine and HTTP boundary (proved by tests/test_lakehouse_project_scoping.py and tests/test_lakehouse_endpoint_scoping.py).

Key isolation files​

FilePurpose
src/backend/app/zerodb/lakehouse/writer.pyTenant-partitioned Parquet writer (#5246)
src/backend/app/zerodb/lakehouse/config.pyPARTITION_TEMPLATE, INTERNAL_TENANT_ID
src/backend/app/zerodb/lakehouse/scoped_query.pyProject-scoped read engine + SQL sandbox (#5270/#5271)
src/backend/app/zerodb/api/lakehouse.pyCustomer-facing project-scoped endpoints