News for hackers. Stuff that matters.

Show HN: Vanilla JavaScript refinery simulator built to explain job to my kids

Hi HN, I’m a chemical engineer and I manage logistics at a refinery down in Texas. Whenever I try to explain downstream operations to people outside the industry (including my kids), I usually get blank stares. I wanted to build something that visualizes the concepts and chemistry of a plant without completely dumbing down the science, so I put together this 5-minute browser game.

I am not a software developer by trade, so I relied heavily on LLMs (Claude, Copilot, Gemini) to help write the code. What started as a simple concept turned into a 9,000-line single-page app built with vanilla HTML, CSS, and JavaScript. I used Matter.js for the 2D physics minigames.

A few technical takeaways from building this as a non-dev: * Managing the LLM workflow: Once the script.js file got large, letting the models output full file rewrites was a disaster (truncations, hallucinations, invisible curly-quote replacements that broke the JS). I started forcing them to act like patch files, strictly outputting "Find this exact block" and "Replace with this exact block." This was the only way to maintain improvements without breaking existing logic.

* Mapping physics to CSS: I wanted the minigames to visually sit inside circular CSS containers (border-radius: 50%). Matter.js doesn't natively care about your CSS. Getting the rigid body physics to respect a dynamic, responsive DOM boundary across different screen sizes required running an elliptical boundary equation (dx * dx) / (rx * rx) + (dy * dy) / (ry * ry) > 1 on every single frame. Maybe this was overkill to try to handle the resizing between phones and PCs.

* Mobile browser events: Forcing iOS Safari to ignore its default behaviors (double-tap zoom, swipe-to-scroll) while still allowing the user to tap and drag Matter.js objects required a ridiculous amount of custom event listener management and CSS (touch-action: manipulation; user-select: none;). I also learned that these actions very easily kill the mouse scroll making it very frustrating for PC users. I am hoping I hit a good middle ground.

* State management: Since I didn't use React or any frameworks, I had to rely on a global state object. Because the game jumps between different phases/minigames, I ran into massive memory leaks from old setInterval loops and Matter.js bodies stacking up. I had to build strict teardown functions to wipe the slate clean on every map transition.

The game walks through electrostatic desalting, fractional distillation, hydrotreating, catalytic cracking, and gasoline blending (hitting specific Octane and RVP specs).

It’s completely free, runs client-side, and has zero ads or sign-ups. I'd appreciate any feedback on the mechanics, or let me know if you manage to break the physics engine. Happy to answer any questions about the chemical engineering side of things as well.

For some reason the URL box is not getting recognized, maybe someone can help me feel less dumb there too. www.fuelingcuriosity.com/game

( 12 comments | 3 points | on HN )
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by skyberrys on Monday March 02, 2026 @09:41PM (#47227288)
I had to copy and paste your URL, I'm not sure why I couldn't click your title. It was a fun and informative little game though! I did go into it thinking I would be making artificial vanilla flavors though.
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by fuelingcurious on Sunday March 08, 2026 @03:32PM (#47300399)
Haha sorry for the confusing title! I’ll clean that up! Thank you for trying it!
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by jlongo78 on Monday March 02, 2026 @11:00PM (#47227849)
Nice project for teaching kids systems thinking. One tip for Claude Code workflows with vanilla JS like this: keep a dedicated terminal pane running a file watcher alongside your agent session. When Claude modifies simulation logic, you see the rebuild output in real time without context switching. Lets you catch off-by-one errors in flow rates before Claude moves on. The separation of concerns mirrors what your refinery sim is actually teaching.
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by fuelingcurious on Sunday March 08, 2026 @03:36PM (#47300446)
Apologies on the delayed response! I must not have set up notifications right. I actually built this all through chat windows rather than a terminal hub.

I haven’t allocated much time to learning Claude code/anti gravity/codex but I want to add more levels to teach some of the mechanical aspects of the refinery.

I’ll definitely try to incorporate what you just mentioned in this next round of coding.

Re:Show HN: Vanilla JavaScript refinery simulator built to e... by jlongo78 on Sunday March 08, 2026 @03:56PM (#47300722)
Sounds cool! chat windows are fun. def keep that file watcher in mind, it'll save ya time. good luck with those levels!
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by dang on Sunday March 08, 2026 @04:31PM (#47301096)
I've fixed the URL at the top now, but can you please email us at [email protected]? I'd like to arrange a repost of this thread because it's too old for us to re-up directly onto the frontpage.
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by fuelingcurious on Sunday March 08, 2026 @05:50PM (#47301912)
Email sent! I am genuinely new to this space, and a logistics manager by day (and most of the time night) so if I missed a way to ensure I stay in tune with folks interests and comments I will look into it tonight.
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by gus_massa on Tuesday March 03, 2026 @12:23PM (#47235644)
Cicky: www.fuelingcuriosity.com/game

In "Phase 3: The Cooker" it's super difficult to remove the square on the bottom right.

Re:Show HN: Vanilla JavaScript refinery simulator built to e... by gus_massa on Tuesday March 03, 2026 @08:01PM (#47241572)
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by fuelingcurious on Sunday March 08, 2026 @03:36PM (#47300454)
Thank you!
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by fuelingcurious on Sunday March 08, 2026 @03:33PM (#47300403)
Thank you for the feedback! I’ll work on making the hydropipe go lower so you have a direct angle at it.
Re:Show HN: Vanilla JavaScript refinery simulator built to e... by fuelingcurious on Wednesday March 11, 2026 @12:30PM (#47337733)
This should be fixed