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.

01
The 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.

Core data model: a DocumentProfile has many Books; Books are shared into Circles; Users own books, join circles and write Annotations; Replies, Reactions, Follows and TrendingActivity attach to other records through polymorphic links.DocumentProfilea title, its genresBookan uploaded PDF or EPUBCirclea reading groupFollowusers → users, titlesUsersigns in with FirebaseAnnotationa highlight at a CFITrendingActivitya feed scoreReactionon replies and postsReplya threaded discussionSolid: a foreign key. Dashed: a polymorphic link, checked by the model, not the database.
Arrows point from the record that holds the reference. Every user also has a private circle of their own, so reading alone uses the same annotation and reply tables.

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.subject is an annotation, a circle post, a title (which makes it a review) or another reply.
  • Reaction.subject is a reply or a circle post.
  • Annotation.selection_data is an EPUB CFI range or a PDF page selection.
  • Follow.followed_item is a user or a title.
  • TrendingActivity.actable is a user, a reply or a title, each scored on its own rules.
  • Activity, FollowActivity, UserNotification, CollectionItem and Report use the same pattern for feeds, notifications, curation and moderation.

02
Every 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.

The 47 tables in the final production schema, grouped into catalog and reading, annotation and conversation, curation, people and feeds, circles, and platform settings.Catalog and reading13document_profilesbooksgenresdocuments_genresgenres_usersreading_progressesbookmarksuser_purchased_booksdocument_requestsdocument_profile_previewing_usersaffiliate_linksinsightsinsight_votesAnnotation and conversation6annotationsepub_selection_datapdf_selection_datarepliesreactionsreportsCuration3collectionscollection_itemsbooks_collectionsPeople, feeds, notifications7usersfollowsfollow_activitiesactivitiestrending_activitiesuser_notificationsfeatured_usersCircles9circlescircles_usersrolesbooks_circlescircle_postscircle_requestsjoin_notificationscircle_collectionscircle_circle_collectionsPlatform and settings9trending_settingsinsight_settingsfeature_flagsevent_logsform_submissionsversionsactive_storage_blobsactive_storage_attachmentsactive_storage_variant_records
All primary keys are UUIDs. The versions table is the paper_trail audit history, and the three Active Storage tables track every uploaded file, whichever bucket it lives in.

03
Services

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.

Services map: the web and native apps call the Rails API with a Firebase ID token. The API and Sidekiq run on Heroku with Postgres and Redis, and use Google Cloud Storage, Firebase Auth, Cloud Messaging and Firestore, plus third-party services such as Stripe and OpenAI.Web appReact, server-rendered by RailsFirebase JS SDK, Stripe ElementsNative appReact Native, iOS and AndroidFirebase Auth, Messaging, AnalyticsREST, with a Firebase ID tokenHerokuRails APIPuma, ~136 routesserves the web appverifies ID tokensPostgresRedisSidekiqpush, AI, importshourly trending scoresweekly bestsellersfilesverifypushsignalGoogle Cloud + FirebaseStoragebook files, covers,circle imagesAuthemail, Google andApple sign-inMessagingpush to thenative appFirestorechange signalto the web appThird-party servicesStripe purchasesOpenAI insights, genresNYT Books bestsellersImageKit image CDNBranch deep linksMailchimp audiencesMeta conversionsSentry, Scout errors, perfGA4, Hotjar web analytics
Dashed: Firestore carries a “something changed” signal to the web app, which then refetches from the API. The native app relies on push notifications and refetching instead.

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.

04
Running 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.

Back to the engineering notes →