TLDR platform architecture (tldrnerd.com)
tldrflutterphpslimmariadbarchitectureprocrastinai
TLDR (tldrnerd.com) is Justin's social knowledge platform: short markdown posts with responses, votes, reactions, tags, bookmarks, a bug/feature tracker, end-to-end encrypted DMs and group chats, and ProcrastinAI, an AI persona that answers posts by running Claude Code on the desktop. This article is the map; the linked articles hold the details and lessons.
Pieces
| Layer | What it is | Where |
|---|---|---|
| Web app | Flutter web (CanvasKit), served as static files | /var/www/html/tldr/app (symlink to releases/vX.Y.Z) |
| Android app | Same Flutter codebase, sideloaded release APK | https://tldrnerd.com/tldr.apk |
| API | PHP 8.3 Slim 4, one public/index.php router plus *_manager.php classes |
api.tldrnerd.com, /var/www/html/tldr/api |
| Database | MariaDB 10.11 (not MySQL), database tldr |
same server |
| File storage | Private Linode Object Storage bucket, streamed through the API | see Accepting and serving user uploads safely from a private bucket |
| Push | Firebase Cloud Messaging HTTP v1, sent from PHP | see FCM push notifications from a PHP backend to a Flutter app |
| AI | claude-service on the desktop, reached via an autossh reverse tunnel | see claude-service (ProcrastinAI's webhook runner for headless Claude), Lifecycle of an async AI request (status machine, expiry, retries, failure) |
| Voice calls | 1:1 WebRTC from DMs, signaling via a polled table, coturn on the server (v1.63.0) | see 1:1 WebRTC voice calls over polled signaling and TURN |
The repo is ~/dev/tldr (Flutter in lib/, API in api/, Android native code in android/).
History: it started in 2018 as an Angular app (tldr-ng, API at the old tldrpost.com); the
Flutter port began in March 2026 and kept the same API contract, including the quirk that the
Authorization header carries the raw token with no Bearer prefix.
Flutter app conventions
- Every service is a singleton wrapped in a Riverpod provider (
lib/providers.dart); screens areConsumerStatefulWidgets. - Navigation is go_router:
context.go()for tab destinations (keeps the browser URL right on web),context.push()only for post detail so the list keeps its scroll state. See Android back button in Flutter with go_router (and Android 16 predictive back) and go_router navigation patterns and opening your own links in-app. - Optimistic UI: votes, archive, cancel and bookmark update local state first, then a silent refresh reconciles; votes roll back if the API call fails.
- Any periodic poll goes through a lifecycle-aware poller, see Stop Flutter timers from polling while the app is in the background.
- Per-session caches must be reset on every session change, see Singleton services, session caches, and cross-user data leaks in Flutter.
API conventions
- Identity and role come only from the verified JWT, never from a
usernamefield in the body or query. See API authorization from the verified identity (and the holes it closes). - Server-only files that deploys must never delete: DB config, JWT config, AI config, S3 config,
vendor/,uploads/,data/. See Release-directory deploys with an atomic symlink swap. - House gotchas (closure
uselists, 418 on DB bootstrap failure, CRLF files) in Slim 4 PHP APIs (and migrating from Limonade). - Cron jobs live in
api/cron/and pipe output tologger -t tldr-*(journald/syslog) rather than log files, because the app user cannot write/var/log.
Data model notes
- Table names are singular (
post,response,edit,reminder). Some columns break the pattern:post_tag.postid(no underscore),response.created_dateanddm_message.sent_dateare unix ints. - Posts are soft-deleted (
deleted,deleted_at); a nightly cron purges their uploaded images after 90 days but keeps the row. - Post metadata (tracker status, priority, AI state) is a key/value table
post_meta; values are free text and not validated by the API, so the app is the source of truth for vocabularies like the tracker lifecycleopen, in-progress, in-review, resolved, closed. - Uploaded file names live only inside post bodies as full URLs; no table indexes them.
Scripting against the API
Rules first: automated posts are made only as the user ai, and only when Justin explicitly asks
for a post. Local sessions never post to TLDR to report their own work.
- Mint the token on the server, so the JWT signing secret never leaves the box: one ssh command
runs a PHP one-liner that requires the server's JWT config, HS256-signs
{sub: 'ai', role: 'user', iat, exp} (base64url, no padding) and prints the token. Send it raw in
Authorization, no Bearer. The placeholder token some prompts mention is not valid for
authenticated routes.
- POST /upload is multipart (field file) and returns {url, filename, original_name}.
- POST /posts takes form-encoded fields (title, body, privacy, type, tags[]); use
--data-urlencode "body@file.md" for long bodies. It answers 201 with an empty body, so verify
via GET /posts or the DB. Then POST /posts/{id}/meta with {key, value} for status/priority.
- PUT /posts takes a JSON body {id, title, body, username, privacy, type, tags} and returns 204;
ownership is checked against the token. Old title/body are archived to the edit table.
- A private post by ai is invisible to other users; reports meant for Justin are public, so check
attachments for personal data first.
- There is no delete route for uploads; remove bucket objects with PHP on the server.
- Reminders can be scheduled by inserting a reminder row directly (time in America/Chicago wall
clock), avoiding a token for the human user.
Usage pattern (snapshot, April 2026)
401 posts, 27 users, but 89% of posts by one author and 62% of responses by the AI user; 91% of posts private. Voting, polls and bookmarks were barely used. Lesson: the product behaves like a personal dev notebook with an AI assistant, and AI features drive almost all engagement.
See also
- E2E key management that never loses a key (keyring, backup, re-wrap), Simple E2E messaging with X25519 + HKDF + AES-GCM (and why not Signal), E2E group chat with per-epoch sender keys
- Writing a production smoke test that tells you why it failed
- "Anyone with the link" share links (capability URLs), Open Graph link previews (SPAs, private posts, private-storage media)
- nginx in front of Apache (TLS proxy on :8008)
Linked from
- 1:1 WebRTC voice calls over polled signaling and TURN
- Android back button in Flutter with go_router (and Android 16 predictive back)
- Changing a production MariaDB safely (schema, data fixes, id generation)
- claude-service (ProcrastinAI's webhook runner for headless Claude)
- Linode (Akamai) Object Storage
- Release-directory deploys with an atomic symlink swap
- Server-sent push notifications (FCM HTTP v1, Web Push, ntfy)
- Slim 4 PHP APIs (and migrating from Limonade)
- Writing a production smoke test that tells you why it failed