TinyNovel.
1,000,000 words. One giant community novel. Write something tiny. The book will fight you.
This is a toy prototype. Your words are local-only — stored only in this browser tab. They are 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 write anything you wouldn’t want to lose. Have fun, don’t be weird. And yes — the book fights back on purpose.
1,000,000 words = about 4,000 pages at 250 words per page. Every word you write deals 1 damage to the book. Every 50 words, and every 45 seconds, the book hits back.
Go on. Write something. I dare you. I am blank, and I intend to stay that way.
No attacks yet. The book is pretending to sleep.
Tip: type, then hit ⚔️ Fight the Book to undo its last attack and deal +10 bonus damage. Hit 🛡️ Defend to block attacks for 60 seconds. ↩ Undo also works — same as TinyMap.
How it works (when it’s real)
Everyone writes on the same novel. One sentence at a time. You write, the book eats a word, you fight it back. Cooldowns, accounts, and moderation will keep it from becoming chaos. For now, you’re writing alone — think of this as practice against a very rude book.
- Type to deal damage — 1 word = 1 HP off the book
- Every 50 words + every 45 seconds, the book attacks
- Fight undoes its last attack, Defend blocks for 60s
- Download .txt to keep your draft
Community — coming soon
Shared state is not connected yet. This box is a placeholder for what’s next:
🟢 0 people writing right now (fake — local toy)
📖 Last chapter: —
⚔️ Last fight: — (not saved)
📜 Rules: No hate, no NSFW, no ads. Mods will nuke it later.
⬇ Backend — TinyNovel Backend — Template
Right now TinyNovel is a tinker toy — countWords() counts words in this tab, bookAttack() eats a word from a textarea, 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 novel, per-word writes with positions, book attacks as server events, cooldowns, accounts, and moderation. Proposed, not connected.
01 / Files to create
api/tinynovel/write.php POST /api/tinynovel/write api/tinynovel/words.php GET /api/tinynovel/words?since= api/tinynovel/fight.php POST /api/tinynovel/fight api/tinynovel/snapshot.php GET /api/tinynovel/snapshot api/tinynovel/clear.php POST /api/tinynovel/clear (mod only) sql/tinynovel_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/tinynovel_tables.sql
tinynovel_words
-- one row per word — 1,000,000 max, ordered by position
id BIGINT AUTO_INCREMENT PRIMARY KEY
position INT NOT NULL -- 0 .. 999,999, unique, defines order
word VARCHAR(80) NOT NULL -- one word, no spaces
user_id INT NOT NULL
written_at DATETIME NOT NULL
UNIQUE(position) -- last write wins per slot
tinynovel_chapters
id INT AUTO_INCREMENT PRIMARY KEY
title VARCHAR(200) NOT NULL
start_position INT NOT NULL -- first word of this chapter
created_at DATETIME NOT NULL
tinynovel_attacks
-- the book fights back — server events, not client guesses
id BIGINT AUTO_INCREMENT PRIMARY KEY
kind ENUM('eat','replace','snark','try_end') NOT NULL
position INT NULL -- which word it ate / replaced
detail VARCHAR(200) NULL
created_at DATETIME NOT NULL
tinynovel_snapshot
id INT AUTO_INCREMENT PRIMARY KEY
path VARCHAR(200) NOT NULL -- "/data/tinynovel/snapshot.txt"
word_count INT NOT NULL DEFAULT 0
created_at DATETIME NOT NULL
tinynovel_cooldowns
user_id INT PRIMARY KEY
last_write_at DATETIME NOT NULL
words_last_minute INT NOT NULL DEFAULT 0
Novel is 1,000,000 words. Never store a full novel per user — store only words by position, plus one snapshot. Same idea as TinyMap, but words instead of pixels.
03 / API endpoints & request flow
POST /api/tinynovel/write
{ "words": [ { "position": 12, "word": "dragon" }, ... ] }
- auth required, 1-100 words per request (one sentence = many words)
- validates position 0-999999, word 1-80 chars, no spaces
- cooldown: max 1 write per 500ms, max 100 words per request
- writes INSERT ... ON DUPLICATE KEY UPDATE word, user_id, written_at
- returns { "ok": true, "written": 12, "cooldown_ms": 500 }
GET /api/tinynovel/words?since=2026-11-18T00:00:00Z
- returns { "ok": true, "words": [ { position, word }, ... ] }
- since = last poll time, max 5000 words per response
- client polls every 2s, applies only new words — same ordering as now
POST /api/tinynovel/fight
{ "attack_id": 123 }
- auth required, one fight per attack, max 1 fight per 5s
- server undoes that attack (restores eaten word, removes snark)
- returns { "ok": true, "restored": "potato", "bonus": 10 }
GET /api/tinynovel/snapshot
- returns { "ok": true, "url": "/data/tinynovel/snapshot.txt",
"word_count": 1234, "updated_at": "..." }
- new visitors load snapshot first, then poll /words?since=
POST /api/tinynovel/clear (mod only)
- auth + role=mod required, else 403
- clears tinynovel_words + rebuilds snapshot, logs who cleared it
Book attacks are server events in the real version — tinynovel_attacks — not client random. Client in this toy fakes them with bookAttack(). Server decides eat / replace / snark / try_end on a timer + every 50 words, 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 words 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 writing
// server stores user_id per word, so a bad paragraph can be rolled
// back by user + position range, not by wiping the whole novel.
// Validation:
// position must be integer 0-999999, word must match /^[^\s]{1,80}$/
// words must be an array, 1-100 items — else 400
// chapter titles are client-side only — server only sees words.
Keep the disclaimer until this ships: “Tinker toy — not live yet. Refresh = gone.” Remove it only when /api/tinynovel/write is actually storing words.
05 / Frontend wiring
// Counting is already local in this page:
// countWords(text) — same function as now
// totalEver — same counter as now, drives Book HP
// After typing (debounced 800ms), also send to server:
async function sendWords(words){
const res = await fetch('/api/tinynovel/write', { method:'POST',
headers:{'Content-Type':'application/json'},
body: JSON.stringify({ words }) });
// if cooldown, wait retry_ms and retry once
}
// Poll for other people's words:
async function pollWords(){
const res = await fetch('/api/tinynovel/words?since=' + encodeURIComponent(lastPoll));
const data = await res.json();
// data.words.forEach(w => insertWordAt(w.position, w.word))
// insertWordAt = same word-array splice as bookAttack(), but no history push
}
// On load:
// 1. GET /api/tinynovel/snapshot -> load .txt into textarea
// 2. setInterval(pollWords, 2000)
// 3. keep local countWords() / fightBook() / undo() / downloadTXT() as-is
// If API fails, fall back to current local-only toy + disclaimer.
Keep the current toy playable with no backend — if /api/tinynovel/words fails, writing stays local-only and the disclaimer stays.
api/tinynovel/ + sql/tinynovel_tables.sql — no GitHub needed. The <pre> blocks are the backend spec: shared 1,000,000-word novel, per-word writes by position, book attacks as server events, cooldowns + moderation, same layout, disclaimer stays until wired.