TinyPoll.
Ask a question, watch the bars move. Vote, share, and find the closest calls.
This is a toy prototype. Polls are local-only, stored only in this browser tab. They are NOT saved to the server and NOT shared with anyone yet. Voting here is real though, the bars move, the percentages update, and the closest calls board updates. Refresh equals your polls gone, except local autosave.
How it works (when it is real)
Everyone votes on the same board. You ask a poll, people vote, the bars move live, and the closest calls rise. For now, you are voting alone, practice your poll.
- Poll equals question plus 2 to 4 options plus category
- Vote equals one vote per poll, you can change it
- Closest equals smallest gap between first and second
- Download .txt to keep your board
Community, coming soon
Shared state is not connected yet.
🟢 0 voters right now (fake, local toy)
🏆 Last closest call: —
📊 Last poll: —
📜 Rules: One vote per poll. No hate. Close it when done.
Backend, TinyPoll Backend, Template
Right now TinyPoll is a tinker toy, polls is a local array in this tab, votes are local counters, comments are local, and Refresh equals gone (except local autosave). The bars moving is real, it runs in your browser. Disclaimer is the truth: local-only, not saved, not shared. This backend is the map to make it real: one shared board, per-poll writes, votes as server counts, comments as server rows, category filters, cooldowns, accounts, moderation. Proposed, not connected.
01 / Files to create
api/tinypoll/poll.php POST /api/tinypoll/poll api/tinypoll/polls.php GET /api/tinypoll/polls?sort=best&tag= api/tinypoll/vote.php POST /api/tinypoll/vote api/tinypoll/comment.php POST /api/tinypoll/comment api/tinypoll/close.php POST /api/tinypoll/close api/tinypoll/snapshot.php GET /api/tinypoll/snapshot sql/tinypoll_tables.sql
Keep the tinyfiles PHP pattern: /api/bootstrap.php, json_in() / json_out(), prepared PDO.
02 / Database tables
tinypoll_polls id BIGINT AUTO_INCREMENT PRIMARY KEY user_id INT NOT NULL question VARCHAR(200) NOT NULL body TEXT NOT NULL category VARCHAR(20) NOT NULL closed TINYINT NOT NULL DEFAULT 0 created_at DATETIME NOT NULL tinypoll_options id BIGINT AUTO_INCREMENT PRIMARY KEY poll_id BIGINT NOT NULL text VARCHAR(120) NOT NULL sort_order INT NOT NULL tinypoll_votes poll_id BIGINT NOT NULL option_id BIGINT NOT NULL user_id INT NOT NULL PRIMARY KEY (poll_id, user_id) tinypoll_comments id BIGINT AUTO_INCREMENT PRIMARY KEY poll_id BIGINT NOT NULL user_id INT NOT NULL body TEXT NOT NULL created_at DATETIME NOT NULL tinypoll_cooldowns user_id INT PRIMARY KEY last_poll_at DATETIME NOT NULL polls_last_hour INT NOT NULL DEFAULT 0
Board is one shared feed. Never store a board per user, store only polls by id, plus options, votes, and comments.
03 / API endpoints
POST /api/tinypoll/poll
{ "question": "Cats or dogs?", "body": "...", "category": "fun", "options": ["Cats","Dogs"] }
- auth required, 1 poll per hour
- validates question 5-200 chars, 2-4 options, each 1-120 chars
- returns { "ok": true, "id": 123 }
GET /api/tinypoll/polls?sort=best&tag=&since=
- returns polls with options and vote counts, plus myVote
POST /api/tinypoll/vote
{ "poll_id": 123, "option_id": 456 } - one vote per user per poll, can change it
- server moves vote, returns new counts
POST /api/tinypoll/comment
{ "poll_id": 123, "body": "Dogs, no contest." } - 1 comment per 10s
POST /api/tinypoll/close
{ "poll_id": 123 } - only owner can closeVotes are server counts, tinypoll_votes, not client counters. Server decides Best, New, and Closest sorting. Closest equals smallest gap between top two options.
04 / Cooldown, moderation and validation
// Cooldown: 1 poll per hour, 1 comment per 10s, 1 vote change per 2s // Moderation: no hate / NSFW / spam, mods can remove plus ban user_id // Validation: question, options, category, else 400 // Closed polls: no new votes, comments still allowed
Keep disclaimer until this ships: Tinker toy, not live yet. Refresh equals gone.
05 / Frontend wiring
// polls[] is already local. After posting (debounced 800ms): // POST /api/tinypoll/poll with new poll // Poll GET /api/tinypoll/polls?sort=best every 5s, apply only new polls // On load: GET /api/tinypoll/snapshot, load into polls[] // Vote: POST /api/tinypoll/vote, then update bars from server counts // If API fails, fall back to local-only toy plus disclaimer.
api/tinypoll/ plus sql/tinypoll_tables.sql, no GitHub needed. Shared board, per-poll writes, votes as server counts, cooldowns plus moderation.