Daily Affirmation.
You already have The Meadow above — that one stays. Here are 4 more JavaScript pictures, drawn live in your browser. No photos to load, no feed. Click a thumbnail, or Prev / Next, or Shuffle. Each picture comes with its own nicer thing.
Daily Affirmation Backend — Proposed Architecture
Right now this page is local-only: the quote is picked by day-of-year in JavaScript, affirmations are a hard-coded array in the page, the Meadow + More Pictures are drawn live on canvas, and the Music Box is all Web Audio in the browser. No server, no login, no tracking — that part stays. This is the map to make it real without losing that feeling: server picks the daily quote + affirmation + picture, front-end still draws the pictures on canvas, and nothing personal is ever stored.
01 / Files to create
api/affirmation/daily.php GET /api/affirmation/daily?date=2026-11-18 api/affirmation/list.php GET /api/affirmation/list?kind=affirmation admin/affirmation_write.php POST /admin/affirmation_write (login required) sql/affirmation_tables.sql cron/daily_pick.php CLI — pre-pick tomorrow’s quote + affirmation
Keep the tinyfiles PHP pattern: each endpoint loads /api/bootstrap.php, uses json_in() / json_out(), prepared PDO statements. The Music Box stays 100% client-side — no backend needed for it.
02 / Database tables
-- sql/affirmation_tables.sql
affirmations
id INT AUTO_INCREMENT PRIMARY KEY
kind ENUM('affirmation','nice_line','picture_caption') NOT NULL
text TEXT NOT NULL -- plain text, no HTML
active TINYINT NOT NULL DEFAULT 1
created_at DATETIME NOT NULL
quotes
id INT AUTO_INCREMENT PRIMARY KEY
text TEXT NOT NULL
author VARCHAR(120) NOT NULL
active TINYINT NOT NULL DEFAULT 1
pictures
id VARCHAR(20) PRIMARY KEY -- 'meadow','sunset','night','ocean','cozy'
title VARCHAR(60) NOT NULL
emoji VARCHAR(10) NOT NULL
mode VARCHAR(20) NOT NULL -- which canvas drawer to use
caption TEXT NOT NULL
active TINYINT NOT NULL DEFAULT 1
daily_picks
pick_date DATE PRIMARY KEY
quote_id INT NOT NULL
affirmation_id INT NOT NULL
picture_id VARCHAR(20) NOT NULL
FOREIGN KEY (quote_id) REFERENCES quotes(id)
FOREIGN KEY (affirmation_id) REFERENCES affirmations(id)
FOREIGN KEY (picture_id) REFERENCES pictures(id)
Daily picks are pre-computed so every visitor on the same day sees the same quote + affirmation + picture, but the “Daily Affirmation” button + “Say something nice” + picture gallery still cycle locally — no server call per click.
03 / API & request flow
GET /api/affirmation/daily?date=2026-11-18
- returns { "quote": {...}, "affirmation": "...", "picture": {...} }
- If no row in daily_picks for that date, pick by day-of-year
(same logic as today) and insert it, so it is stable after that.
GET /api/affirmation/list?kind=affirmation
- returns all active affirmations for the button + nice-line cycler.
- Front-end falls back to the hard-coded 24 in this page if the API fails.
Cron: cron/daily_pick.php (once a day, 00:05)
1. For tomorrow, pick quote + affirmation + picture by day-of-year.
2. Insert into daily_picks if not already there.
3. No user data touched — picks are the same for everyone.
Front-end (production):
- Page loads, calls /api/affirmation/daily once.
- If it fails, use the hard-coded quote + affirmation + Sunset picture.
- Canvas pictures are still drawn by mode in JS — the server only
tells the page which mode + caption to use. No image files.
04 / Validation & rules
// Server owns the truth. Browser submits intent only. Affirmations / quotes / captions (admin only): - text required, plain text, max 300 chars, no HTML, no scripts. - kind must be one of affirmation / nice_line / picture_caption. - active 0/1 only. Deleting = set active=0, never hard-delete a daily pick. Pictures (admin only): - id: lowercase slug, unique. mode must be one of meadow / sunset / night / ocean / cozy — the front-end only knows those 5 drawers, so an unknown mode falls back to sunset. - caption: plain text, max 300 chars. No tracking: - Do NOT add a table for who clicked what, who listened, or who visited. - The page promise is “No logs required. No tracking.” The backend must keep that promise. No user ids, no IPs, no cookies for this page.
05 / Adding a picture / affirmation
-- Add a nicer thing (no code change):
INSERT INTO affirmations (kind, text) VALUES
('affirmation', 'You are loved, even when the day is loud.');
-- Add a new picture (needs a JS drawer for the mode first):
INSERT INTO pictures (id, title, emoji, mode, caption) VALUES
('forest', 'Forest', '🌲', 'forest', 'Quiet is not empty. The forest is full of life.');
New affirmation = one row, button + nice-line cycler pick it up. New picture = one row + one canvas drawer function in the page. No deploy for new copy.