MCPcopy
hub / github.com/supabase-community/database-build

github.com/supabase-community/database-build @main sqlite

repository ↗ · DeepWiki ↗
445 symbols 1,312 edges 186 files 15 documented · 3%
README

database.build (formerly postgres.new)

In-browser Postgres sandbox with AI assistance.

github-repo-hero

With database.build, you can instantly spin up an unlimited number of Postgres databases that run directly in your browser (and soon, deploy them to S3).

Each database is paired with a large language model (LLM) which opens the door to some interesting use cases:

  • Drag-and-drop CSV import (generate table on the fly)
  • Generate and export reports
  • Generate charts
  • Build database diagrams

How it works

All queries in database.build run directly in your browser. There’s no remote Postgres container or WebSocket proxy.

How is this possible? PGlite, a WASM version of Postgres that can run directly in your browser. Every database that you create spins up a new instance of PGlite that exposes a fully-functional Postgres database. Data is stored in IndexedDB so that changes persist after refresh.

Monorepo

This is a monorepo split into the following projects:

  • Web: The primary web app built with Next.js
  • Browser proxy: Proxies Postgres TCP connections back to the browser using pg-gateway and Web Sockets
  • Deploy worker: Deploys in-browser databases to database platforms (currently Supabase is supported)

Setup

From the monorepo root:

  1. Install dependencies

shell npm i

  1. Start local Supabase stack: shell npx supabase start
  2. Store local Supabase URL/anon key in ./apps/web/.env.local: shell npx supabase status -o env \ --override-name api.url=NEXT_PUBLIC_SUPABASE_URL \ --override-name auth.anon_key=NEXT_PUBLIC_SUPABASE_ANON_KEY | grep NEXT_PUBLIC >> ./apps/web/.env.local
  3. Create an OpenAI API key and save to ./apps/web/.env.local: shell echo 'OPENAI_API_KEY="<openai-api-key>"' >> ./apps/web/.env.local
  4. Store local KV (Redis) vars. Use these exact values:

shell echo 'KV_REST_API_URL="http://localhost:8080"' >> ./apps/web/.env.local echo 'KV_REST_API_TOKEN="local_token"' >> ./apps/web/.env.local

  1. Start local Redis containers (used for rate limiting). Serves an API on port 8080:

shell docker compose -f ./apps/web/docker-compose.yml up -d

  1. Fill in the remaining variables for each app as seen in:

  2. ./apps/web/.env.example

  3. ./apps/browser-proxy/.env.example
  4. ./apps/deploy-worker/.env.example

Development

From the monorepo root:

npm run dev

Important: This command uses turbo under the hood which understands the relationship between dependencies in the monorepo and automatically builds them accordingly (ie. ./packages/*). If you by-pass turbo, you will have to manually build each ./packages/* before each ./app/* can use them.

Why rename postgres.new?

This project is not an official Postgres project and we don’t want to mislead anyone! We’re renaming to database.build because, well, that’s what this does. This will still be 100% Postgres-focused, just with a different URL.

Video

image

License

Apache 2.0

Extension points exported contracts — how you extend this code

paths (Interface)
(no doc)
packages/deploy/src/supabase/management-api/types.ts
ReadableStream (Interface)
(no doc)
apps/web/global.d.ts
components (Interface)
(no doc)
packages/deploy/src/supabase/management-api/types.ts
LineAnimationProps (Interface)
(no doc)
apps/web/components/lines.tsx
operations (Interface)
(no doc)
packages/deploy/src/supabase/management-api/types.ts
AnimatedLineProps (Interface)
(no doc)
apps/web/components/lines.tsx
CodeBlockProps (Interface)
(no doc)
apps/web/components/code-block.tsx
Particle (Interface)
(no doc)
apps/web/components/particles-background.tsx

Core symbols most depended-on inside this repo

cn
called by 126
apps/web/lib/utils.ts
useApp
called by 37
apps/web/components/app-provider.tsx
getMetaDb
called by 14
apps/web/lib/db/index.ts
assertDefined
called by 13
apps/web/lib/sql-util.ts
result
called by 11
apps/web/lib/tools.ts
unwrapNode
called by 11
apps/web/lib/sql-util.ts
getDbInstance
called by 10
apps/web/lib/db/index.ts
useWorkspace
called by 7
apps/web/components/workspace.tsx

Shape

Function 348
Method 54
Class 28
Interface 15

Languages

TypeScript100%

Modules by API surface

apps/web/lib/db/index.ts28 symbols
apps/web/lib/sql-util.ts23 symbols
apps/browser-proxy/src/telemetry.ts16 symbols
apps/web/lib/streams.ts12 symbols
apps/web/lib/hooks.ts12 symbols
apps/browser-proxy/src/connection-manager.ts12 symbols
apps/web/lib/util.ts10 symbols
apps/web/lib/smooth-scroller.ts8 symbols
apps/web/components/particles-background.tsx8 symbols
apps/web/polyfills/readable-stream.ts7 symbols
apps/web/lib/pg-wire-util.ts7 symbols
apps/web/config/ui.config.js7 symbols

Dependencies from manifests, versioned

@ai-sdk/openai1.0.4 · 1×
@aws-sdk/client-s33.645.0 · 1×
@dagrejs/dagre1.1.2 · 1×
@database.build/deploy* · 1×
@electric-sql/pglite-tools0.2.2 · 1×
@gregnr/postgres-meta0.82.0-dev.2 · 1×
@hono/node-server1.13.2 · 1×
@hono/zod-validator0.4.1 · 1×
@hookform/resolvers3.9.1 · 1×
@mertasan/tailwindcss-variables2.7.0 · 1×
@monaco-editor/react4.6.0 · 1×

Datastores touched

postgresDatabase · 1 repos

For agents

$ claude mcp add database-build \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact