Cloudflare
I turned my portfolio into a town square you walk around with the other visitors

Most portfolios are a page you read alone. I wanted mine to feel like a place, so I built Vivek’s Square: a small 3D town square where everyone on the site at the same moment shows up as a little character. You walk around, wave, say a few set phrases, and if you tap someone you can challenge them to a duel. Accept, and you’re both dropped into the same online match.
It runs on phones held upright, needs no sign-up, and costs close to nothing on a quiet day. This is how it’s put together.
The shape of it
- The page is three.js, written by hand: a paved square, a banyan tree on a stone platform, bunting, lamp posts, and a ring of buildings. Every building is a door to something already on the site: the arcade, the blog, my projects, the guestbook.
- The server is a Cloudflare Durable Object called
Plaza, one per square. A square holds up to 50 people. When it fills, the lobby sends newcomers to square 2, and so on, so every square feels lively and none is a crowd. - The lobby lives in another Durable Object that already ran my site’s “here now” counter, reactions and guestbook. Each square reports how full it is; the lobby hands out the first square with room.
Everything else (static pages, the games) is plain files on Cloudflare’s edge. Only /api/* runs code.
Keeping the traffic small
The obvious version sends every player’s position to every other player, many times a second. With 50 people that’s 2,500 messages per tick. Instead:
- A phone sends its position at most 10 times a second, and only while it’s moving. Standing still costs nothing.
- The square collects everyone’s moves and sends one bundled message every 100 ms to each person.
- Each phone draws other people about 160 ms in the past, blending between the last two positions it has, so walking looks smooth even when messages arrive unevenly.
Talking is six emotes and twelve set phrases. No free text, so there’s nothing to moderate. Names go through the same filter my arcade leaderboards use.
Making it run on a cheap phone
A town square has a lot of small things in it: bricks, flags, lamp posts, trees. Drawn one by one, that’s hundreds of draw calls, and a mid-range phone starts dropping frames. So everything that never moves is baked into a single mesh at load time, with each part’s colour written into the vertices. The whole square, bunting included, is one draw call. The signs are the only textured pieces.
The characters get the same treatment: each look (shirt colour, hat, skin tone) is baked once into one mesh and shared, so a person is one draw call plus their name tag. Everyone’s soft round shadow is drawn together, in one instanced mesh.
Dueling a stranger
My arcade already had three online duels (Rooftop Duel, Kabaddi Dash and Slime Volley) where one player hosts a room and the other types a five-letter code. The square just removes the typing:
- When you challenge someone, your phone makes up a room code and sends it with the challenge, through the square, to that one person.
- If they accept, you both leave the square: you open the duel as the host of that code, they open it as the guest.
- The match starts the moment both are in. If the guest’s page loads first, it quietly retries for a few seconds until the host’s room exists.
The host’s device runs the match and streams snapshots to the guest. Phone networks deliver in bursts, so the guest now keeps a small buffer of snapshots stamped with the host’s clock, and plays them back a little behind, at a delay that grows on a shaky link and shrinks on a good one. On a simulated phone network with regular stalls, that took the guest’s picture from 250 frozen frames and 95 backward jerks in 18 seconds to none, for about 25 ms of extra delay.
A daily puzzle, built backwards
Next to the square there’s Barish (Hindi for rain): one puzzle a day for everyone. Rain falls from clouds onto slanted roof tiles; you flip tiles so every field gets water and no house gets wet.
Each day starts from a solved board. The builder flips a few tiles to make the puzzle, then searches every shorter set of flips (only tiles a raindrop actually touches can matter, which keeps the search small) and throws the board away if any of them solves it. So the par is exact: “par 4” really means four flips is the fewest. The hardest days take up to a second to build, too slow for a phone, so a year of puzzles is built when the site is built and the page just reads today’s.
Bugs that taught me something
- The lobby forgot everything. Square counts were kept in memory in the lobby’s Durable Object. That object also holds the site’s “here now” WebSockets with the hibernation API, which means Cloudflare can put it to sleep between requests, and sleeping wipes memory. Counts now live in its SQLite storage. Rule I’m keeping: if a Durable Object hibernates, nothing important lives in a variable.
requestAnimationFrametime can be older than the click. The rain animation started fromperformance.now()in the click handler, and the next frame’s timestamp was a few milliseconds earlier. Negative elapsed time, an index of -1, and the animation silently stopped. Clamp at zero.- “Right” wasn’t right. In my battle royale, pushing the joystick right walked you left, on keyboard too. With the camera looking along +Z, screen-right is −X; the movement code had it the other way. I now derive camera-relative directions from the camera’s own vectors instead of from memory.
What it costs
Very little while it’s quiet: a square only works while people are in it, and idle sockets hibernate. The cap of 50 per square and “only send while moving” keep a busy day bounded. I’ll share real numbers once it has seen some traffic.
Try it
Open the square on your phone, send the link to a friend, and challenge them to a duel. If nobody’s there yet, stay a minute: whoever walks in next will see you standing by the banyan tree.
Enjoyed this?
Written by Vivek Bhange, Full-Stack AI Engineer. See his work or work with me.