tinyfiles.tv
πŸ‘—
Upload your cosplay

Character β€’ Series β€’ Photo β€’ 1-2 lines about how you made it. Be nice in ratings. Be honest in comments.

psst… whisper β€” don't tell everyone yet

🀫 …something's coming.

Not announcing it. Not yet. Just… if you were thinking about posting your best cosplay soon, maybe… soon is good. There might be a competition. There might be prizes. There might be judges who actually know what top-stitching is.
β€” tinyfiles team, whispering

Feed:Cards below are placeholders β€” your cosplay goes here.
πŸ”₯ Hot thread: How do you rate accuracy vs. creativity?

124 replies β€’ placeholder thread. Real talk goes here.

🧡 WIP Wednesday: Show your half-finished build

89 replies β€’ placeholder thread. Unfinished is still cosplay.

πŸ’¬ Cosplayers to watch

People we like: @placeholder1, @placeholder2, @placeholder3 β€” talk about cosplay people like that.

⭐ How we rate

Craft 40% β€’ Accuracy / Interpretation 30% β€’ Presentation 20% β€’ Vibes 10%. Stars below are real β€” click to rate.

Backend  ·  Template · Proposed · Not connected

⬇ Backend — Cosplay Backend — Template

Right now Cosplay is local-only — feed is a hardcoded let cards = [...] in JS, mockUpload() just unshifts a placeholder card, stars only change in the browser, comments / share are alert('placeholder'), and the whisper competition is a hidden <p>. This backend is the map to make it real: uploads live on the server, ratings are one-per-user, comments are stored, filters hit the server. Proposed, not connected.

01 / Files to create
api/cosplay/feed.php            GET  /api/cosplay/feed?cat=all|anime|games|movies|original
api/cosplay/upload.php          POST /api/cosplay/upload (multipart, auth required)
api/cosplay/rate.php            POST /api/cosplay/rate
api/cosplay/comments.php        GET  /api/cosplay/comments?cosplay_id=
                                POST /api/cosplay/comments
api/cosplay/threads.php         GET  /api/cosplay/threads
sql/cosplay_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/cosplay_tables.sql
cosplay_posts
  id INT AUTO_INCREMENT PRIMARY KEY
  user_id INT NOT NULL                  -- FK -> users.id
  character VARCHAR(120) NOT NULL      -- "Gojo Satoru"
  series VARCHAR(120) NOT NULL         -- "Jujutsu Kaisen"
  cat ENUM('anime','games','movies','original') NOT NULL
  description TEXT NOT NULL            -- 1-2 lines about how you made it
  image_path VARCHAR(255) NOT NULL     -- "/uploads/cosplay/....jpg", never base64 in DB
  status ENUM('pending','live','removed') NOT NULL DEFAULT 'pending'
  created_at DATETIME NOT NULL

cosplay_ratings
  id INT AUTO_INCREMENT PRIMARY KEY
  cosplay_id INT NOT NULL               -- FK -> cosplay_posts.id
  user_id INT NOT NULL
  stars TINYINT NOT NULL                -- 1-5
  created_at DATETIME NOT NULL
  UNIQUE(cosplay_id, user_id)           -- one rating per user, re-rate = UPDATE

cosplay_comments
  id INT AUTO_INCREMENT PRIMARY KEY
  cosplay_id INT NOT NULL
  user_id INT NOT NULL
  body TEXT NOT NULL
  created_at DATETIME NOT NULL

cosplay_threads
  id INT AUTO_INCREMENT PRIMARY KEY
  title VARCHAR(200) NOT NULL          -- "How do you rate accuracy vs. creativity?"
  reply_count INT NOT NULL DEFAULT 0
  sort_order INT NOT NULL DEFAULT 0

Score on a card = AVG(stars) in cosplay_ratings scaled to /10, plus count. Never store the average β€” compute it. The whisper competition lives in cosplay_threads / a flag, not in hardcoded HTML.

03 / API endpoints & request flow
GET /api/cosplay/feed?cat=all
- returns { "ok": true, "posts": [ { id, character, series, cat,
  description, image_path, author, score, rating_count }, ... ] }
- cat in [all, anime, games, movies, original], max 50, newest first
- score is AVG(stars)*2, rounded to 1 decimal β€” "9.2 / 10"

POST /api/cosplay/upload (multipart/form-data, auth required)
- fields: character, series, cat, description, photo file
- validates cat allow-list, character/series 1-120 chars, description 1-500
- photo: jpg/png/webp only, max 5MB, stored to /uploads/cosplay/, path in DB
- returns { "ok": true, "id": N, "status": "pending" }

POST /api/cosplay/rate
{ "cosplay_id": 12, "stars": 4 }
- auth required, stars 1-5, INSERT ... ON DUPLICATE KEY UPDATE
- returns { "ok": true, "score": 9.2, "rating_count": 41 }

GET /api/cosplay/comments?cosplay_id=12
- returns { "ok": true, "comments": [ { author, body, created_at }, ... ] }

POST /api/cosplay/comments
{ "cosplay_id": 12, "body": "..." }
- auth required, body 1-1000 chars, plain text, no HTML

GET /api/cosplay/threads
- returns { "ok": true, "threads": [ { title, reply_count }, ... ] }

Feed / filters never need the full image bytes in JSON β€” just image_path. The browser loads the image from that path.

04 / Uploads, moderation & validation (server owns this)
// Upload validation β€” server checks, never trusts the browser:
//   file: MIME sniffed, not extension β€” jpg/png/webp only, <= 5MB
//   dimensions: max 4000x4000, strip EXIF (GPS!) before saving
//   character / series: 1-120 chars, description: 1-500 chars
//   cat must be in [anime, games, movies, original]

// Moderation:
//   new posts start status='pending', not live
//   admin approves -> 'live', or 'removed' with reason
//   ratings + comments only on 'live' posts

// Comments + ratings:
//   body is plain text β€” escape on render, never store HTML
//   "Rate the costume, not the person" β€” report button sets a flag,
//   it does not delete. Admin reviews.

Keep the page’s rule: “Be nice in ratings. Be honest in comments. Rate the costume, not the person.” The backend enforces the upload + moderation part of that.

05 / Frontend wiring
// Replace the hardcoded let cards = [...] in this page:
let cards = []; // filled from server, same shape as now

async function loadCosplay(cat='all'){
  const res = await fetch('/api/cosplay/feed?cat=' + cat);
  const data = await res.json();
  // data.posts -> renderCos(cat), same .cos-card HTML as now
  // image:  replaces emoji thumb when present
}

// Replace mockUpload():
async function mockUpload(){
  const form = new FormData();
  form.append('character', document.getElementById('charName').value);
  form.append('series', document.getElementById('seriesName').value);
  // form.append('cat', ...); form.append('photo', fileInput.files[0]);
  const res = await fetch('/api/cosplay/upload', { method:'POST', body: form });
  const data = await res.json();
  // on ok: show "Pending review β€” will appear after approval"
}

// Replace rate(el, n):
async function rate(el, n){
  const id = el.closest('.cos-card').dataset.id;
  const res = await fetch('/api/cosplay/rate', { method:'POST',
    headers:{'Content-Type':'application/json'},
    body: JSON.stringify({ cosplay_id: id, stars: n }) });
  // update stars + score from response, same UI as now
}

// Replace filterCos(f, el):
//   filterCos -> loadCosplay(f), keep .pill active logic

// On load: loadCosplay('all') + fetch('/api/cosplay/threads')
// If API fails, fall back to current hardcoded cards + placeholder threads.

Keep the current hardcoded cards + whisper playable with no backend — if /api/cosplay/feed fails, use the in-page list as the fallback.

Copy the snippets above into api/cosplay/ + sql/cosplay_tables.sql — no GitHub needed. The <pre> blocks are the backend spec: server-owned uploads + one-rating-per-user + plain-text comments + pending-review moderation, same layout, placeholders stay until wired.