tinyfiles.tv
⚠️ TINKER TOY — NOT LIVE YET — DISCLAIMER

This is a toy prototype. Your city is local-only — stored only in this browser tab. It is NOT saved to the server and NOT shared with anyone yet. Refresh = gone (unless this tab autosaves). Shared community state, accounts, and moderation are coming later. Don’t build anything you wouldn’t want to lose. And yes — the traffic fights back on purpose. It wants gridlock.

Build: 👥 Pop: 0🚗 Traffic HP: 1,000,000🛡️ Shield: off
Tiles: 1 / 1,000,000•999,999 to go•Traffic: 0%•Happy: —

1,000,000 tiles = one very big city. Every tile you place deals 1 damage to Traffic. Every 30 tiles, and every 45 seconds, Traffic hits back — it bulldozes, it jams, it abandons houses. Keep roads close to houses, parks close to houses, or Traffic wins.

🏙️
The traffic says:

One road. One perfect, empty road. Let us keep it that way. No houses. No shops. Just… smooth, silent asphalt.

No attacks yet. Traffic is pretending to flow.

Your district — 20 x 20. This is the first district of the million-tile city.Tap a tile to build — roads first, or houses go empty
🛣️ Road = traffic relief🏠 House = +10 pop🏪 Shop = jobs🌳 Park = happiness🏚️ Abandoned = traffic won

Rule of thumb: 1 road per 4 houses, 1 park per 6 houses. More than that and Traffic starts eating houses. Fight = undoes Traffic’s last attack, +10 bonus damage. Bypass = blocks for 60s.

How it works (when it’s real)

Everyone builds on the same city. One tile at a time. You add a house, Traffic tries to jam it, you fight it back with a bypass. Cooldowns, accounts, and moderation will keep it from becoming chaos. For now, you’re building alone — think of this as practice against very rude gridlock.

  • Place a tile to deal damage — 1 tile = 1 HP off Traffic
  • Every 30 tiles + every 45 seconds, Traffic attacks
  • Fight undoes its last attack, Bypass blocks for 60s
  • Download .txt to keep your district

Community — coming soon

Shared state is not connected yet. This box is a placeholder for what’s next:

🟢 0 mayors building right now (fake — local toy)
🏙️ Last district: —
⚔️ Last fight: — (not saved)
📜 Rules: No hate, no NSFW, no ads. Mods will nuke it later.

Backend  ·  Template · Proposed · Not connected

⬇ Backend — TinyCity Backend — Template

Right now TinyCity is a tinker toy — grid is a local 20 x 20 array in this tab, trafficAttack() bulldozes a tile from the grid, totalEver is a local counter, history is 10 in-memory snapshots, and Refresh = gone (except local autosave). The disclaimer on this page is the truth: local-only, not saved, not shared. This backend is the map to make it real: one shared city, per-tile writes by x / y, traffic attacks as server events, cooldowns, accounts, and moderation. Proposed, not connected.

01 / Files to create
api/tinycity/tile.php          POST /api/tinycity/tile
api/tinycity/tiles.php         GET  /api/tinycity/tiles?since=
api/tinycity/fight.php         POST /api/tinycity/fight
api/tinycity/snapshot.php      GET  /api/tinycity/snapshot
api/tinycity/clear.php         POST /api/tinycity/clear  (mod only)
sql/tinycity_tables.sql

Keep the tinyfiles PHP pattern: each endpoint loads /api/bootstrap.php, uses json_in() / json_out(), prepared PDO statements.

02 / Database tables
-- sql/tinycity_tables.sql
tinycity_tiles
  -- one row per tile — 1,000,000 max, 1000 x 1000 city
  id BIGINT AUTO_INCREMENT PRIMARY KEY
  x SMALLINT NOT NULL               -- 0-999
  y SMALLINT NOT NULL               -- 0-999
  kind CHAR(1) NOT NULL             -- "R" road, "H" house, "S" shop, "P" park
  user_id INT NOT NULL
  placed_at DATETIME NOT NULL
  UNIQUE(x, y)                      -- last write wins per tile

tinycity_attacks
  -- Traffic fights back — server events, not client guesses
  id BIGINT AUTO_INCREMENT PRIMARY KEY
  kind ENUM('bulldoze','jam','gridlock','try_bulldoze_row') NOT NULL
  x SMALLINT NULL
  y SMALLINT NULL
  detail VARCHAR(200) NULL
  created_at DATETIME NOT NULL

tinycity_snapshot
  id INT AUTO_INCREMENT PRIMARY KEY
  path VARCHAR(200) NOT NULL         -- "/data/tinycity/snapshot.json"
  tile_count INT NOT NULL DEFAULT 0
  created_at DATETIME NOT NULL

tinycity_cooldowns
  user_id INT PRIMARY KEY
  last_place_at DATETIME NOT NULL
  tiles_last_minute INT NOT NULL DEFAULT 0

City is 1000 x 1000 = 1,000,000 tiles. Never store a full city per user — store only tiles by x / y, plus one snapshot. Same idea as TinyMap / TinyNovel / TinySong, but tiles instead of pixels / words / notes. Toy shows 20 x 20 — real city is the full 1M-tile map, toy is just the first district.

03 / API endpoints & request flow
POST /api/tinycity/tile
{ "tiles": [ { "x": 512, "y": 400, "kind": "H" }, ... ] }
- auth required, 1-100 tiles per request (one block = many tiles)
- validates x 0-999, y 0-999, kind in R/H/S/P
- cooldown: max 1 write per 500ms, max 100 tiles per request
- writes INSERT ... ON DUPLICATE KEY UPDATE kind, user_id, placed_at
- returns { "ok": true, "placed": 12, "cooldown_ms": 500 }

GET /api/tinycity/tiles?since=2026-11-18T00:00:00Z
- returns { "ok": true, "tiles": [ { x, y, kind }, ... ] }
- since = last poll time, max 5000 tiles per response
- client polls every 2s, applies only new tiles — same grid toggle as now

POST /api/tinycity/fight
{ "attack_id": 123 }
- auth required, one fight per attack, max 1 fight per 5s
- server undoes that attack (restores bulldozed tile)
- returns { "ok": true, "restored": "H", "bonus": 10 }

GET /api/tinycity/snapshot
- returns { "ok": true, "url": "/data/tinycity/snapshot.json",
  "tile_count": 1234, "updated_at": "..." }
- new visitors load snapshot first, then poll /tiles?since=

POST /api/tinycity/clear  (mod only)
- auth + role=mod required, else 403
- clears tinycity_tiles + rebuilds snapshot, logs who cleared it

Traffic attacks are server events in the real version — tinycity_attacks — not client random. Client in this toy fakes them with trafficAttack(). Server decides bulldoze / jam / gridlock / try_bulldoze_row on a timer + every 30 tiles, so everyone sees the same fight.

04 / Cooldown, moderation & validation (server owns this)
// Cooldown — keeps it from becoming chaos:
//   1 write request per 500ms per user
//   100 tiles per request, 1 fight per 5s per user
//   if user exceeds it, return { "ok": false, "error": "cooldown",
//   "retry_ms": 320 } — client shows "Slow down" and retries.

// Moderation:
//   no hate / NSFW / ads — mods can clear + ban user_id from building
//   server stores user_id per tile, so a bad district can be rolled
//   back by user + x / y range, not by wiping the whole city.

// Validation:
//   x / y must be integers 0-999, kind must be R / H / S / P
//   tiles must be an array, 1-100 items — else 400
//   traffic / happiness are derived — server only sees tiles.

Keep the disclaimer until this ships: “Tinker toy — not live yet. Refresh = gone.” Remove it only when /api/tinycity/tile is actually storing tiles.

05 / Frontend wiring
// Grid is already local in this page:
//   grid[20][20] — same array as now
//   totalEver — same counter as now, drives Traffic HP

// After placing a tile (debounced 800ms), also send to server:
async function sendTiles(tiles){
  const res = await fetch('/api/tinycity/tile', { method:'POST',
    headers:{'Content-Type':'application/json'},
    body: JSON.stringify({ tiles }) });
  // if cooldown, wait retry_ms and retry once
}

// Poll for other people's tiles:
async function pollTiles(){
  const res = await fetch('/api/tinycity/tiles?since=' + encodeURIComponent(lastPoll));
  const data = await res.json();
  // data.tiles.forEach(t => setTile(t.x, t.y, t.kind))
  // setTile = same grid assignment as placeTile(), but no history push
}

// On load:
//   1. GET /api/tinycity/snapshot -> load JSON into grid
//   2. setInterval(pollTiles, 2000)
//   3. keep local placeTile() / fightCity() / undo() / downloadCity() as-is
// If API fails, fall back to current local-only toy + disclaimer.

Keep the current toy playable with no backend — if /api/tinycity/tiles fails, building stays local-only and the disclaimer stays.

Copy the snippets above into api/tinycity/ + sql/tinycity_tables.sql — no GitHub needed. The <pre> blocks are the backend spec: shared 1,000,000-tile city, per-tile writes by x / y, traffic attacks as server events, cooldowns + moderation, same layout, disclaimer stays until wired.