PGSimCity is an interactive 3D city that visualizes PostgreSQL internals, letting users explore mechanisms like shared buffers, WAL, and vacuum through a browser-based simulation.

Stars

286

7-day growth

No data

Forks

15

Open issues

3

License

Apache-2.0

Last updated

2026-07-28

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It reached #1 on Hacker News, offering a unique, visceral way to understand PostgreSQL internals without running a real database, with color-coded semantics and interactive scenarios.

Who it is for

  • Engineers new to database operations
  • Experienced developers wanting deeper PostgreSQL understanding
  • Database instructors seeking visual teaching aids
  • PostgreSQL enthusiasts curious about internal mechanics

Use cases

  • Learning how checkpoints cause latency spikes
  • Observing the effect of long-running transactions on bloat
  • Exploring WAL and replication behavior with slow replay
  • Teaching PostgreSQL internals in a classroom or workshop

Strengths

  • Interactive 3D visualization with semantic color coding
  • Guided tour and keyboard controls for easy exploration
  • No server, no database, no network calls – runs as a static bundle
  • Clearly states its limitations as a prototype and model, not an emulator

Considerations

  • It is a prototype (v0.1) with potential inaccuracies in simulation and explanations
  • Numbers are scaled for human observation, not real PostgreSQL scaling
  • Only simulates PostgreSQL behavior; no actual SQL execution or real query results

README quick start

PGSimCity

An explorable 3D city that shows how PostgreSQL actually works.

PGSimCity turns a PostgreSQL cluster into a city you can inspect, walk through, and break. It is for engineers who are good at their job and have never had to operate a database — the people who need to understand why a checkpoint spikes latency, why one forgotten transaction bloats a table forever, and what synchronous_commit is really charging them.

Explore the live city — no install required.

PGSimCity is an independent, non-commercial educational visualization of PostgreSQL internals. It is not affiliated with, sponsored, endorsed, or approved by Electronic Arts Inc. SimCity is a trademark of Electronic Arts Inc.

This project contains no SimCity code, assets, artwork, logos, characters, audio, or game content.


How much to trust this

PGSimCity is still 0.x: early and moving. It is a model of PostgreSQL, not an emulator: no PostgreSQL source code runs here, and the numbers are scaled so a human can watch them.

Three specialist review rounds checked PostgreSQL correctness against postgresql.org/docs and the source rather than memory; every finding was independently checked by a reviewer tasked with refuting it. A separate audit treated buildings, adjacencies, and animations as claims.

The suite has 234 tests; CI fails the build on a red test. They pin the WAL trigger point as max_wal_size / (1 + checkpoint_completion_target) at every call site, cache hit ratio as blks_hit / (blks_hit + blks_read), and the clock-sweep usage_count cap at 5.

Mistakes have been found and fixed throughout; the commit history records them. Known limitation: touch controls have been verified only in Chrome's mobile emulation. Corrections from people who know the engine are exactly what this needs: open an issue or send a pull request.


A possible future

The city uses a hand-written simulation of PostgreSQL’s mechanisms, which is what makes internals such as the clock sweep’s frame-by-frame victim choice observable. The separate Query flow offers an opt-in PGlite mode: real PostgreSQL supplies parsing, plans, catalogs, buffer counters, errors and results, while its plan drives the cl

Description

An explorable 3D city that shows how Postgres actually works

Related repositories

Similar projects matched by category, topics, and programming language.

TanStack
Featured
TanStack GitHub avatar

router

TanStack Router is a type-safe, data-driven React router with built-in caching, prefetching, and nested layouts, while TanStack Start extends it into a full-stack SSR framework.

Web DevelopmentFrontend Frameworks
14,861
vercel-labs
Featured
vercel-labs GitHub avatar

scriptc

scriptc compiles ordinary TypeScript into small, fast native executables without needing Node.js, V8, or any JavaScript runtime in the binary.

Developer ToolsCode Quality & Build
1,985
Jakubantalik
Featured
Jakubantalik GitHub avatar

thinking-orbs

A React component library that renders six hand-tuned animated thought orb loading indicators on a plain 2D canvas, with two purpose-tuned sizes and automatic theme detection for AI and agent UIs.

AI & Machine LearningAI Agents
1,191