HN.zip

PGSimCity - How PostgreSQL Works

867 points by jonbaer - 83 comments
seeken [3 hidden]5 mins ago
This is really cool to look at. A couple weeks ago I started vibe-coding a Doom for Beam which will allow you to 'run around' a beam VM as a factory floor and see the modules and functions, how they are connected, how 'hot' they are running, and whether they're throwing sparks. I haven't gotten far yet, but I've been wanting to build it to justify getting myself a VR headset.
layoric [3 hidden]5 mins ago
I love what is trying to be done here. Some feedback to improve would be to cut out a lot of the noise with the "Take tour". There are too many boxes and things changing on the screen to get a sense of what is happening. Also make it interactive rather than automatically switch onto the next subject. Being a passive observer to so much information trying to be conveyed is very confusing.

I really do like these kinds of approaches to showing the inner workings of different kinds of tech, so think this is on the good path to being a very useful tool, but needs some focus rather than more data/graphs/info boxes.

titzer [3 hidden]5 mins ago
It's amazing 3D going on, and then 80% of the visual space is popups that completely block it. It'd be have a nice prominent ways of reducing the noise, and that pops were partially transparent.
npl [3 hidden]5 mins ago
Yea on mobile especially
samokhvalov [3 hidden]5 mins ago
I hear you. WIP!

thanks for all the feedback. It's amazing for me too. It all started yesterday with a single prompt and curiosity what Opus 5 can do.

~3.86B tokens used so far (not counting GPT 5.6 Sol that at some point started to do a lot of legwork for coding)

nugator [3 hidden]5 mins ago
~3.86B * $5/M tokens ≈ $19.3k

Is that the cost you've payed for this or is my calculation completely wrong?

hectormalot [3 hidden]5 mins ago
Likely a lot of those tokens are cached. And because it’s an individual project it’s likely this is under a personal Claude Max 20x plan.
samokhvalov [3 hidden]5 mins ago
correct on both counts
saransh12345 [3 hidden]5 mins ago
Share the prompt here please?
samokhvalov [3 hidden]5 mins ago
it was silly, quick check out of curiosity what Opus 5 can do – and the first thing I saw was so impressive that it made me spend hours during weekend polishing it

here it is from history, without edits

> you're a veteran Postgres hacker and expert. I want 3D visualization of how Postgres works, for browser -- all its major components, presented as a 3d model, complex, with all parts zoomable, and animated, with controls -- checkpointer, bgwriter, autovacuum, walwriter, backends, walsender, etc etc etc. Imagine we need to build a 3d model of whole city. That's same level. We need this so engineers who are non-DB-experts would easily understand how it works. Design must be cool, modern, super cool, running all in browser, with controls, with camera position flying with arrow keys and mouse, zoomable, etc. Think deep how to implement it, which modern cool tech to use, and use ultracode to implement in a new directory (we'll commit it later). OK to use the most cool and most modern stuff. Think deep choose tools wisely and let's build an awesome in-browser 3d model of Postgres engine

(later I came with lots of materials about internals and behavior and we started to polish / improve)

npl [3 hidden]5 mins ago
I frequently have asked Claude to explain different software architecture things that I don’t know because I’m not formally technically trained - like “explain Django as though it’s a city with different parts having different roles”. I’m a visual learner so this helps a lot and gives me ideas for how to have similar visualizing for other stuff at various levels of abstraction.
yieldcrv [3 hidden]5 mins ago
single prompt Claude Design before putting it in Claude Code
derac [3 hidden]5 mins ago
maybe try adding tts to the tour?
andyfilms1 [3 hidden]5 mins ago
This is good general advice. If your software needs a "tour," that's a good indicator you should work on your UX instead. If you're just excited to tell the user about a new feature, they'll discover it when they need it.
appplication [3 hidden]5 mins ago
I think in this case a tour is fine and sort of the point. But I disagree with you generally.
vixen99 [3 hidden]5 mins ago
Not everyone will come to view this model from the same vantage point. Some will simply be curious about some famous software that they don't happen to use. So the tour is an excellent idea. Great presentation. Congratulations.
narmiouh [3 hidden]5 mins ago
I imagined as soon I saw the initial visual that I would somehow be able to enter a query and it would walk me through the flow through the entire system starting from input parsing to all the way to delivering output and perhaps along the way understand some of the autonomous processes that happen in parallel that aren't query specific but run constantly.

What others are saying - fantastic attempt, but don't know where to start or where to end.

samokhvalov [3 hidden]5 mins ago
try pressing T
INTPenis [3 hidden]5 mins ago
How to rotate camera?
justinclift [3 hidden]5 mins ago
If you're using a keyboard and mouse, then SHIFT + left mouse button seems to work.
narmiouh [3 hidden]5 mins ago
That's fantastic, please tell me I was short sighted and missed this when I wrote my comment.
samokhvalov [3 hidden]5 mins ago
yeah, it was there before your comment; maybe not easy to find (help is on "?", which is also maybe not easy to find)
willquack [3 hidden]5 mins ago
This is very similar to what I imagine whenever I get into a deep focus state debugging a program in gdb... I would love to experience debugging a program in VR with graphics like this,,, there would be no better way to learn a codebase. I wonder how good an experience you could achieve by generating a 3d map based on arbitrary code
Curtis_Guan [3 hidden]5 mins ago
Understanding how scheduling works inside a database used to require numerous architecture diagrams to explain. I was amazed when I saw PGSimCity — it presents such a complex technical implementation process in such an engaging way. Since it's already open‑source, I think the same idea can be reused in other domains, such as cloud computing, Kubernetes, and so on.
tptacek [3 hidden]5 mins ago
I've always wanted to do an explainer of the deployment system and state-tracking at Fly.io using Factorio as a visual metaphor.
inigyou [3 hidden]5 mins ago
Let's make a Factorio overhaul mod where your goal is to produce fly.io deployments!

Bonus if it actually deploys on fly.io. This is not possible with a mod alone.

MitziMoto [3 hidden]5 mins ago
I heard you have some free time now, so let's see it!
robertlagrant [3 hidden]5 mins ago
I keep wanting to build a Kubernetes visualiser. I know they exist, but the last time I looked they didn't look that great.
notachatbot123 [3 hidden]5 mins ago
Considering that it has been vibe-coded with not even 48 hours passed: Is this truthful and accurate at all? Or will it lead to false conclusions and anti-knowledge?
parthdesai [3 hidden]5 mins ago
Not entirely sure, but the person vibe coding this does know Postgres really well tbf
itomato [3 hidden]5 mins ago
Glean anything or learn something in particular?

This is a brutalist gew-gah.

stronglikedan [3 hidden]5 mins ago
Nit, but there's no dash in gewgah.
fragmede [3 hidden]5 mins ago
LLMs aren't that bad anymore.
INTPenis [3 hidden]5 mins ago
Like any tool they're as good as the wielder.
stronglikedan [3 hidden]5 mins ago
Except most tools aren't constantly improving exponentially.
arjie [3 hidden]5 mins ago
I can't believe "Rendering The First Frame..." is not "Reticulating Splines..." :)

Cool UI.

jedberg [3 hidden]5 mins ago
I have a pretty good working knowledge of the internals of Postgres, but this just confused me. I think it's too busy to understand. At the very least, it would be cool if there were a "slow down" button.
augunrik [3 hidden]5 mins ago
There are buttons on the bottom left: pause and two to adjust the speed (down to 0.1x). Some parts of the city can be adjusted when you click on it (I just found the transactions/s)
jedberg [3 hidden]5 mins ago
Ah indeed there is. Totally didn't notice that, thanks.

But even at .1x it's too quick. :) I should be able to fire individual transactions and watch them flow.

chrisweekly [3 hidden]5 mins ago
yeah, interactivity would be next-level (as several others in these threads have mentioned)
WiSaGaN [3 hidden]5 mins ago
I assume this is done with the help of AI? I have done similar vibe project that explaining catastrophic forgetting with the help of AI. It's just so satisfying now that if you really want to learn something, you can always do it with the help of AI. Before, it's hard to find good resources, now it's not a problem, the issue now becomes one's own focus and agency.
dbgrman [3 hidden]5 mins ago
At first sight, it looks super cool. Kudos for pulling this off. At closer look, feels very overwhelming. The claude tone doesn't help ease the nerves either. The text version is too verbose.
dostick [3 hidden]5 mins ago
It surely is impressive,but it’s just that - components of db service as buildings/machine. What it needs is narrative, purpose, with main actors clearly defined - client and data. demonstrating what is involved in the chain when data’s written and requested.
computomatic [3 hidden]5 mins ago
Try the tour. It’s exactly that.
samokhvalov [3 hidden]5 mins ago
yep (via pressing T)

but I agree, could be better – thinking

loveparade [3 hidden]5 mins ago
I don't know what I am looking at but it is fabulous.
thelastgallon [3 hidden]5 mins ago
I wonder if games can be developed to teach CS (OS, db, compilers) which are visual. Instead of reading a book on databases, perhaps tinkering with something like this would make learning easier. (I'm not a gamer, but I read about factorio kind of games on hn).
getfluxly [3 hidden]5 mins ago
It's a cool and very educative way to learn. But I wish there's like a live query thing going on so that it'd be easy to understand. I am viewing on the 27" 4K screen and it's perfect for it, like others said, I don't feel there's too much boxes and info at the same time. Although the site is going blank sometimes if I zoom in a bit too much. Really cool nonetheless.
citizenpaul [3 hidden]5 mins ago
> I wish there's like a live query thing

There is. "Run a query" at the top nav bar.

samayashar [3 hidden]5 mins ago
Virtually it's so amazing to see. The layers are clearly separated and it does give a sense of the connections being accepted and processed in the central part.

The operation intricacies are a bit difficult to understand because the core looks a bit clogged up. Nonetheless, great work!

npunt [3 hidden]5 mins ago
This is very cool, just some UX tips to make it more legible:

1. remove ~50% of the UI since it covers too much of a laptop screen

2. improve the camera controls so its easier to pan and zoom.

futurecat [3 hidden]5 mins ago
Bravo! I have worked in observability for years and I have a deep desire for new visualizations technics inspired by video games. It would be great in XR as well.
itomato [3 hidden]5 mins ago
Jira professional here, and OpenRCT2 has been my mental (and my agent’s) model for something similar.
harvie [3 hidden]5 mins ago
We've got GPU accelerated PostgreSQL sooner than GTA VI...
skreem [3 hidden]5 mins ago
This is really cool, I like having visualization to hold on my head!

Also (assuming this is LLM-generated, apologies if it’s not) seems like the future of learning/self-teaching… gonna try and generate similar things for stuff I’m learning

smhaziq [3 hidden]5 mins ago
it is in the commit 'Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>'
robertlagrant [3 hidden]5 mins ago
I would love this as an active visualisation of a live postgres. Imagine monitors with this stuff on, including replication from other postgresses, and whatever pgbouncer is doing on the front.
johnhamlin [3 hidden]5 mins ago
UI looks great on a 32" monitor, idk what everyone's complaining about ;)
manytimesaway [3 hidden]5 mins ago
Besides the sadly obvious vibe-coding, just note that SimCity is still an active trademark from EA, so might be good to rename it.
DonHopkins [3 hidden]5 mins ago
Good point! To respect EA's trademark and the terms of their modifications to the GPL-3 license regarding the use of their SimCity trademark, I renamed the open source version of SimCity to Micropolis, which was its original working title. It would be safe to call this project "PGMicropolis" as long as it wasn't for profit.

At the time, there was a disk drive manufacturer by that name, so Will Wright renamed it SimCity.

Fortunately the guy who now owns the rights to the Micropolis trademark (and is an old school hacker who really gets it) was kind enough to allow us to use the name for non commercial purposes, under the Micropolis Public Name License.

https://github.com/SimHacker/MicropolisCore/blob/main/Microp...

Here's the explanation from the MicropolisCore repo's LICENSE file:

https://github.com/SimHacker/MicropolisCore/blob/main/LICENS...

>MICROPOLIS LICENSING

>The Micropolis project operates under two important licenses:

>1. The Micropolis GPL License Notice - This is the GNU General Public License with additional terms added by Electronic Arts to protect the SimCity trademark while allowing the code to be freely used and modified.

>2. The Micropolis Public Name License - This license governs the use of the "Micropolis" name itself, which is a registered trademark of Micropolis Corporation.

>We extend our sincere gratitude to Electronic Arts <https://www.ea.com> for their generosity in releasing the SimCity source code under an open-source license, and to Micropolis Corporation <https://www.micropolis.com> for allowing the community to use the Micropolis name for this open-source city simulation project. Please respect both Electronic Arts' SimCity trademark and Micropolis Corporation's Micropolis trademark by adhering to the terms of these licenses. Additionally, we ask all users to please honor the terms of the <https://www.gnu.org/licenses/gpl-3.0.html> GNU General Public License v3, which protects the freedoms that allow this project to exist and thrive as open-source software.

More details, and another cautionary tale about accidentally getting sued for trademark infringement:

https://news.ycombinator.com/item?id=46981012

>This matters more than people think. Jeff Braun, CEO of Maxis, told me this story:

>"Maxis was sued by Toho. We never referred to the name Godzilla, our monster on the box cover was a T-Rex looking character, but... a few magazine reviews called the monster, Godzilla. That was all it took. Toho called it 'confusion in the marketplace'. We paid $50k for Godzilla to go away. In all honesty, Toho liked Maxis, they said $50k was the minimum they take for Godzilla infringement."

>So please: call the game Micropolis, not SimCity, or EA's lawyers may come knocking. And unlike Toho, EA and their Saudi investors and Jarod Kushner might want to use their bone saws on you, which are much worse than Godzilla.

If any busy-body lawyers find this thread and actually want to go after someone's who's disparaging their trademark, they should look into this instead of open source projects:

https://news.ycombinator.com/item?id=43952567

>I let the domain "micropolisonline.com" expire, which I was using for the old OpenLaszlo/Flash Python/SWIG/C++ client/server based version of open source SimCity, and somebody took it over and replaced it with AI generated claptrap, stealing a lot of my own and other's images without any credit. It even promises the source code, but doesn't actually link to it, just has promises and placeholders.

>It totally misrepresents what Micropolis is, which was based on the original SimCity classic, and confuses it with all the subsequent versions of SimCity and other made-up stuff. And it never mentions the GPL-3 license, EA's license and restrictions on the use of their SimCity trademark, or Micropolis's license to use their trademark. I have no idea what the point of it is.

Here's some more interesting stuff about applying machine learning and LLMs to Micropolis:

https://news.ycombinator.com/item?id=46981043

>Sam Earle's fractal neural network approach (https://arxiv.org/pdf/2002.03896) is exactly this kind of thing. His key trick: recursive weight-sharing in fractal convolutional blocks, so each column of the network acts as a continuous-valued cellular automaton ticking different numbers of times. The deepest column gets a 33x33 receptive field -- enough to connect power across an entire 32x32 map in one forward pass.

>The agents discovered power-plant + residential pairing, road placement for density, zone clustering by type, and traffic-avoiding road layouts. When stuck at local optima, a human player could intervene (deleting power plants) to force re-exploration -- and the agent would improve its design.

>The paper was 2019, before LLMs were doing this kind of thing. Different paradigm (RL on tile grids vs. LLMs on coordinate text), same hard problem.

https://news.ycombinator.com/item?id=46981059

>Sam Earle did exactly this with RL agents trained via quality-diversity methods on Micropolis:

https://github.com/smearle/gym-city

>[...] Here's more about my plans for making a multi player version of Micropolis with time travel, branching, and merging, by using github as a social network and MMPORG platform (when it's not down ;):

https://github.com/SimHacker/moollm/blob/main/designs/sims/s...

laurentiurad [3 hidden]5 mins ago
how do you know it has been vibe-coded? And why does it matter?
j1436go [3 hidden]5 mins ago
Because it reduces my trust in the truthfulness of the represented information.
laurentiurad [3 hidden]5 mins ago
but how can you know the author used AI in the first place, and more than that, if he indeed did it, that he didn't check what the LLM did?
bspammer [3 hidden]5 mins ago
The AI generated text in the tour is a good clue. But I also don’t think the author is denying it.
antoinetouss [3 hidden]5 mins ago
I love this, let's do all of Data Intensive Application SimCity!
num42 [3 hidden]5 mins ago
Really great work! I've always wanted to build a CPU simulator(Full PC simulator) in this style. I still haven't fully figured out my own approach, but this will definitely be an inspiration for me. Thanks for making and sharing it.
gregsadetsky [3 hidden]5 mins ago
Great work! When zooming out a bit, I'm somewhat sure that the 'blinking'/glitching is due to z-fighting. Just something you may want to look into (ie move 3d surfaces so that they're not at the exact same z)
samokhvalov [3 hidden]5 mins ago
Correct -- z-fighting on coplanar ground surfaces. Fixing with explicit offsets.

thanks

antonyragleap [3 hidden]5 mins ago
Visualizing MVCC and transaction visibility would make this even more valuable as a learning tool.
BowBun [3 hidden]5 mins ago
Amazing, great work. Keep polishing this up!
bazzingadev [3 hidden]5 mins ago
Wow, cool projects are so back again
kandros [3 hidden]5 mins ago
The logo shape of the platform is a very niche touch, kudos
terra_nera [3 hidden]5 mins ago
Anyone else getting Reboot vibes?
LowLevelKernel [3 hidden]5 mins ago
Wow. Can’t wait to explore the architecture
deadbabe [3 hidden]5 mins ago
Someone should make a movie called “Postgres” which is about people living within a Postgres city, in the style of Se7en.

“Every city has secrets. Ours have indexes.”

svog23 [3 hidden]5 mins ago
So much stuff to see but looks very cool!
Jonathanfishner [3 hidden]5 mins ago
thats cool. n1. spent 15min looking on it rn
someothherguyy [3 hidden]5 mins ago
I like the education tools being developed using coding agents, but there should be some review in the process.

Good luck continuing it, hope you generated something that can be iterated on.

npl [3 hidden]5 mins ago
Love this
abstrct [3 hidden]5 mins ago
This is amazing!
bibimsz [3 hidden]5 mins ago
i understood all that.
soulcache [3 hidden]5 mins ago
maybe try adding tts to the tour? Lol
luciana1u [3 hidden]5 mins ago
3.86B tokens to build a visual simulator of a database that runs on a fraction of that compute. we're using the expensive brain to draw pictures of the cheap brain.