PGPlayground is the product of copious amounts of wasted productive hours that came from constantly setting up and tearing down postgres containers in order to debug, test or design schemas.
The pain of having to:
- Launch insert favoured database management tool
- Setup the connection string
- Maybe mess up and forget the credentials or copy something else into your clipboard
Litter your home with bespoke directories made for temporary use and then cleaning up docker containers and volumes to recover space. It's tedious at best, infuriating at worst.
- Persistent Postgres instances running in your browser (à la PGLite)
- Monaco Editor with custom good enough auto complete
- Auto generated forms for insertions
- Auto generated forms for function calls
- PG Dump import
- PG Dump export
- Table preview
- Schema explorer
- DDL for all pg entities
- PGLite
- Svelte Kit
- Svelte 5
- ShadCN Svelte
- Monaco Editor
- Install:
npm install - Develop:
npm run dev -- --open - Type-check and lint:
npm run check - Tests:
npm test - Build:
npm run build
src/routes/- Pages./is the mobile landing,/playgroundis the main app,/aboutand/faqare info pages.src/lib/components/app/- Playground UI (header, dialogs, editor, file tree, results, onboarding).src/lib/components/ui/- Reusable UI primitives (buttons, dialogs, dropdowns, tooltips, etc.).src/lib/services/- Data and logic:pglite.svelte.tsmanages database instances, storage, migrations, and schema refresh.schema.tsbuilds the schema tree and catalog snapshot.samples.tsprovisions sample databases and sets starter scratchpad SQL.workspace.tshandles scratchpads, tabs, and query execution state.services/sql-language/holds the SQL grammar, parser, and completion engine.
src/lib/config/- App constants (version, links, sample definitions, defaults).static/- Public assets includingbanner.pngand sample SQL files understatic/samples/.
- Database lifecycle:
mainDbinpglite.svelte.tscreates and loads PGlite instances, enables extensions, and keeps schema/catalog state. Queries go through a proxied client that triggers a debounced schema refresh. - Scratchpads and tabs: Managed in
workspace.ts.resetWorkspaceScratchpadrebuilds the workspace when a sample loads or when starting fresh. - Samples: Defined in
config/samples.tswith SQL files instatic/samples/.loadSamplespins up a new instance with required extensions and seeds the scratchpad with sample queries. - Import/export: Dialogs hook into
mainDb.importSqlDumpandexportSqlDump; import resets the public schema before replaying SQL. - SEO/meta: Page heads include Open Graph/Twitter tags that point at
static/banner.png.
npm run dev- start the dev servernpm run check- type-check and lintnpm test- run unit testsnpm run build- production build
TBD
TBD
Let me know if you appreciate PGPlayground by sending a tip or giving the repository a star ⭐
MPL-2.0. See LICENSE.
Choosing a license is always controversial. I chose the MPL for now, but I'm open to changing it later if someone can make a good argument for a different one.
