Inspiration

Every engineering team has shipped a broken schema. Missing constraints, wrong cascade rules, orphaned rows — bugs that don't surface until production data is corrupted. We asked: what if AI could not just generate a database schema, but prove it works before a single line of code ships?

Palantir's Foundry Ontology inspired our architecture — the idea that data systems need a semantic layer (objects, links, actions) on top of the physical schema. We wanted to democratize that enterprise-grade thinking and make it accessible to any developer in 30 seconds

What it does

Episteme transforms plain-English requirements into verified, production-grade database systems. Type "build an inventory management system for a sneaker brand" and watch as Gemini 3 constructs a complete ontology, generates an ERD with tables, columns, and constraints, stress-tests it with adversarial chaos scenarios, and self-heals failures — all rendered live on an interactive canvas.

The full pipeline: Plan → Ontology → ERD → Constraints → Actions → Verify → Auto-Fix Key capabilities:

-Live build animation on a Lucidchart-style canvas powered by React Flow

-Palantir-inspired ontology layer with object types, link types, action types, and interfaces

-Chaos testing in an in-browser SQLite sandbox — duplicate keys, null violations, negative values, orphaned records|

-Self-healing schema — Gemini diagnoses failures and generates migration patches, verified with proof

-One-click export of SQL migrations, ontology JSON, and a verification report

How we built it

Gemini 3 Flash is the core engine across every phase. We use structured JSON outputs constrained by Zod schemas — no free-form text parsing, fully type-safe. Each pipeline phase feeds its structured output into the next phase's prompt context, creating a coherent reasoning chain.

The frontend is Next.js with React Flow (@xyflow/react) for the interactive ERD canvas, Zustand for state management, and Framer Motion for build animations. Schema verification runs entirely client-side using sql.js (SQLite compiled to WebAssembly) — no backend database needed.

For the self-healing loop: failed chaos tests are sent back to Gemini with full context (failing SQL, error message, schema state). Gemini diagnoses root causes and generates minimal ALTER TABLE patches. Patches are applied in the sandbox and tests automatically rerun to produce verified proof.

We use thinking level HIGH for generation phases (deep architectural reasoning) and LOW for validation phases (fast, focused fixes). A quota-aware fallback system with deterministic local templates ensures the app never breaks during demos.

The intro video was generated using Google Veo 3.1 to create a cinematic 5-second animation matching our warm beige design aesthetic.

Challenges we ran into

-Gemini rate limits on free tier — 30 RPM meant we couldn't iterate fast during development. We solved this by building a robust template fallback system that generates schemas deterministically when the API quota is exhausted.

-Structured output reliability — Getting Gemini to consistently return valid JSON matching complex nested schemas (tables with columns with constraints with indexes) required careful schema design and few-shot examples in our prompts.

-React Flow edge label overlap — Cardinality labels and FK annotations cluttered the canvas. We solved this by showing detailed labels only on edge selection, keeping the default view clean.

-Making the demo story work — When chaos tests all pass, Auto-Fix has nothing to show. We engineered specific adversarial scenarios that reliably expose real schema weaknesses, making the self-healing loop demonstrable every time.

Accomplishments that we're proud of

-The self-healing loop actually works. It's not scripted — Gemini genuinely diagnoses schema failures and generates correct migration patches, verified in-sandbox. The "it broke → it explained → it fixed → it proved it" arc is real.

-7-phase pipeline with structured outputs — Every Gemini call returns typed, validated JSON. Zero regex parsing, zero prompt-and-pray.

-Entire verification runs in the browser — sql.js means no server, no database setup, no cost. Anyone can click the link and test.

-Built and deployed in under a week using Claude Code and Codex for agentic coding, with comprehensive handoff documents enabling seamless relay between AI coding agents.

What we learned

Gemini 3's structured outputs with Zod/JSON Schema are incredibly powerful for building deterministic AI pipelines — the key is constraining the output space tightly enough that every response is usable.

Thinking levels matter — HIGH for creative generation, LOW for mechanical validation. This isn't just a cost optimization; it produces better results.

Building AI tools (not AI chat wrappers) requires treating the model as an engine, not an interface. The user never sees a prompt or a response — they see tables appearing on a canvas.

Agentic coding with proper handoff documentation dramatically accelerates development.

What's next for Episteme

-Real-time collaboration — Multiple users editing the same ontology simultaneously -Gemini 3 Pro upgrade — Deeper reasoning for more complex multi-domain schemas -Migration history — Version-controlled schema evolution with rollback -Custom chaos test authoring — Let users write their own adversarial scenarios -Database deployment — One-click deploy the verified schema to Supabase, PlanetScale, or Neon -Import existing schemas — Reverse-engineer ontologies from existing SQL dumps

Built With

  • gemini3flashapi
  • next.js
  • reactflow
  • sql.js
  • tailwind
  • typescript
  • veo3.1
  • vercel
  • zod
  • zustand
Share this project:

Updates