A map of Threadable's data and services, taken from the last production database dump (April 2025) and the three codebases: the Rails API, the web app it serves, and the React Native app. It's a reference companion to the engineering notes.
01The core models
Six models carry the product. A DocumentProfile is a title: one work, with its metadata, genres and cover. A Book is one uploaded file of that title, a PDF or an EPUB, owned by a user. Books are shared into Circles through a join table, and members join circles with a role (owner, co-owner or member). Inside a circle, members leave Annotations on a passage and discuss them in threaded Replys.
A lot of the graph runs through polymorphic columns, so the database has no foreign keys for them and the models enforce the rules instead. That kept one reply and reaction system working everywhere a person could talk, rather than one table per surface.
Reply.subjectis an annotation, a circle post, a title (which makes it a review) or another reply.Reaction.subjectis a reply or a circle post.Annotation.selection_datais an EPUB CFI range or a PDF page selection.Follow.followed_itemis a user or a title.TrendingActivity.actableis a user, a reply or a title, each scored on its own rules.Activity,FollowActivity,UserNotification,CollectionItemandReportuse the same pattern for feeds, notifications, curation and moderation.
02Every table, by domain
The final schema has 47 tables. Grouped by the part of the product they serve, the catalog and circles are the largest groups, and the conversation layer is small because replies and reactions are shared across every surface.
03Services
The API is the only thing that talks to Postgres and the only holder of service-account keys. Both apps sign in with Firebase directly, then send the Firebase ID token with every API request, and the API verifies it. Slow or outbound work, such as push notifications, AI insights, the hourly trending scores and the weekly bestseller import, runs in Sidekiq.
What each app talks to
- The API. Postgres, Redis and Sidekiq; Cloud Storage through ActiveStorage, with a separate bucket for circle images; Firebase Auth to verify tokens; Cloud Messaging and Firestore from background jobs; Stripe, OpenAI (gpt-4o), the NYT Books API, Mailchimp, Meta's Conversions API and Branch; Sentry and Scout for monitoring.
- The web app. Served by the same Rails process through react_on_rails. It talks to the API, Firebase Auth, Firestore for live updates, Stripe Elements for checkout, ImageKit for resized images and Branch for links, with GA4, Tag Manager and Hotjar for analytics.
- The native app. Everything goes through the API except sign-in (email, Google and Apple through Firebase Auth), push (Cloud Messaging, shown with Notifee), analytics (Firebase Analytics), deep links (Branch) and images (ImageKit). Stripe checkout lived on the web.
04Running it again in 2026
To record a demo after the shutdown, I restored the final production dump into a local database and pointed a development server at the production Firebase project and storage buckets, while keeping push notifications on the staging project so nothing reached real phones. Two years of no activity had decayed every trending score to almost zero, so the time decay now sits behind a flag and the scores were recalculated without it.
