You can see how the whole world of a federated social network—posts, follows, blocks, votes, reports—fits into 54 ledgers. For anyone building their own federated app, these stacks are a floor-plan reference.
At the core is a small custom called runInTransaction(). If you're already inside a transaction, you ride along; if outside, it opens a new one. Every wing in the hall leans on this single custom.
Highlights
- Visibility is built two ways, as a pgEnum and a TS union: public / unlisted / followers / direct / none
- Each concept has a file and a test paired (post.ts/post.test.ts). And the tests are even split by scene of life—lifecycle, remote, draft
- The relationship map in relations.ts is shared by one and the same sheet—both the graphql inquiry room (Pothos drizzle) and these stacks
A passage from the sutra
export const POST_VISIBILITIES = [
"public",
"unlisted",
"followers",
"direct",
"none",
] as const;
export const postVisibilityEnum = pgEnum("post_visibility", POST_VISIBILITIES);