# xittered/xitter architecture

> Architecture diagram of the GitHub repository xittered/xitter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xittered/xitter
- Repository: https://github.com/xittered/xitter

## Overview

Xitter is a self-hosted backend that serves a pinned X web client and implements its API using instance data. The main workflow is a browser using that client to send requests to Xitter, which authenticates the account, dispatches API operations, applies domain rules, and reads or writes PostgreSQL-backed state before returning client-shaped responses. The graph includes the documented social, media, messaging, discovery, and administration capabilities. Some subsystem links are documented in the README; unsampled implementation details and relationships are not inferred.

Main entry points: [`src/posts.ts`](https://github.com/xittered/xitter/blob/main/src/posts.ts) (Posts and timelines), [`src/graphql.ts`](https://github.com/xittered/xitter/blob/main/src/graphql.ts) (GraphQL API), [`src/server.ts`](https://github.com/xittered/xitter/blob/main/src/server.ts) (HTTP server), [`src/auth.ts`](https://github.com/xittered/xitter/blob/main/src/auth.ts) (Sessions and identity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Request runtime"]
  node_server["HTTP server<br/>[server.ts]"]
  node_graphql["GraphQL API<br/>[graphql.ts]"]
  node_rest["Public API<br/>[public-api.ts]"]
  node_model["Client response models<br/>[model.ts]"]
  node_client_cache[("Client asset archive<br/>[client-cache.ts]")]
  node_build["Client asset build<br/>[build.ts]"]
end

subgraph group_social["Social content"]
  node_posts["Posts and timelines<br/>[posts.ts]"]
  node_articles["Long-form articles<br/>[articles.ts]"]
  node_discovery["Search and discovery<br/>[search.ts]"]
  node_communities["Communities and lists<br/>[communities.ts]"]
  node_notes["Community Notes<br/>[notes.ts]"]
end

subgraph group_accounts["Accounts and safety"]
  node_auth["Sessions and identity<br/>[auth.ts]"]
  node_users["Profiles and follows<br/>[users.ts]"]
  node_blocks["Blocks and mutes<br/>[blocks.ts]"]
  node_moderation["Moderation controls<br/>[moderation.ts]"]
end

subgraph group_media_chat["Media and messaging"]
  node_media["Media uploads<br/>[media.ts]"]
  node_chat["Encrypted messaging<br/>[chat.ts]"]
end

subgraph group_operations["Instance operations"]
  node_admin["Admin panel<br/>[admin.ts]"]
  node_settings["Instance settings<br/>[settings.ts]"]
  node_analytics["Account analytics<br/>[analytics.ts]"]
  node_notifications["Notifications and push<br/>[notifications.ts]"]
end

node_browser(("Browser user"))
node_web_client["Pinned X client"]
node_database[("PostgreSQL")]

node_browser -->|"uses"| node_web_client
node_web_client -->|"sends API requests"| node_server
node_server -->|"routes requests"| node_graphql
node_server -->|"uses sessions"| node_auth
node_server -->|"routes admin"| node_admin
node_graphql -->|"dispatches operations"| node_posts
node_graphql -->|"dispatches operations"| node_chat
node_graphql -->|"dispatches operations"| node_communities
node_graphql -->|"dispatches operations"| node_analytics
node_graphql -->|"dispatches operations"| node_notifications
node_posts -->|"loads media"| node_media
node_posts -->|"loads authors"| node_users
node_posts -->|"checks blocks"| node_blocks
node_posts -->|"checks content"| node_moderation
node_posts -->|"checks blocked phrases"| node_settings
node_posts -->|"uses response models"| node_model
node_articles -->|"uses media"| node_media
node_articles -->|"uses response models"| node_model
node_auth -->|"expires sanctions"| node_moderation
node_admin -->|"updates settings"| node_settings
node_build -->|"reads archive"| node_client_cache
node_server -->|"serves public API"| node_rest
node_server -->|"serves client assets"| node_client_cache
node_posts -->|"reads and writes"| node_database
node_auth -->|"reads and writes"| node_database
node_admin -->|"reads and writes"| node_database
node_graphql -->|"dispatches operations"| node_discovery

click node_server "https://github.com/xittered/xitter/blob/main/src/server.ts"
click node_graphql "https://github.com/xittered/xitter/blob/main/src/graphql.ts"
click node_rest "https://github.com/xittered/xitter/blob/main/src/public-api.ts"
click node_model "https://github.com/xittered/xitter/blob/main/src/model.ts"
click node_posts "https://github.com/xittered/xitter/blob/main/src/posts.ts"
click node_articles "https://github.com/xittered/xitter/blob/main/src/articles.ts"
click node_discovery "https://github.com/xittered/xitter/blob/main/src/search.ts"
click node_communities "https://github.com/xittered/xitter/blob/main/src/communities.ts"
click node_notes "https://github.com/xittered/xitter/blob/main/src/notes.ts"
click node_auth "https://github.com/xittered/xitter/blob/main/src/auth.ts"
click node_users "https://github.com/xittered/xitter/blob/main/src/users.ts"
click node_blocks "https://github.com/xittered/xitter/blob/main/src/blocks.ts"
click node_moderation "https://github.com/xittered/xitter/blob/main/src/moderation.ts"
click node_media "https://github.com/xittered/xitter/blob/main/src/media.ts"
click node_chat "https://github.com/xittered/xitter/blob/main/src/chat.ts"
click node_client_cache "https://github.com/xittered/xitter/blob/main/src/client-cache.ts"
click node_admin "https://github.com/xittered/xitter/blob/main/src/admin.ts"
click node_settings "https://github.com/xittered/xitter/blob/main/src/settings.ts"
click node_analytics "https://github.com/xittered/xitter/blob/main/src/analytics.ts"
click node_notifications "https://github.com/xittered/xitter/blob/main/src/notifications.ts"
click node_build "https://github.com/xittered/xitter/blob/main/src/build.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_graphql,node_rest,node_model,node_client_cache,node_build,node_browser,node_web_client toneBlue
class node_posts,node_articles,node_discovery,node_communities,node_notes,node_database toneAmber
class node_auth,node_users,node_blocks,node_moderation toneMint
class node_media,node_chat toneRose
class node_admin,node_settings,node_analytics,node_notifications toneIndigo
```

## Components

### Request runtime

- [HTTP server](https://github.com/xittered/xitter/blob/main/src/server.ts): `src/server.ts`
- [GraphQL API](https://github.com/xittered/xitter/blob/main/src/graphql.ts): `src/graphql.ts`
- [Public API](https://github.com/xittered/xitter/blob/main/src/public-api.ts): `src/public-api.ts`
- [Client response models](https://github.com/xittered/xitter/blob/main/src/model.ts): `src/model.ts`
- [Client asset archive](https://github.com/xittered/xitter/blob/main/src/client-cache.ts): `src/client-cache.ts`
- [Client asset build](https://github.com/xittered/xitter/blob/main/src/build.ts): `src/build.ts`

### Social content

- [Posts and timelines](https://github.com/xittered/xitter/blob/main/src/posts.ts): `src/posts.ts`
- [Long-form articles](https://github.com/xittered/xitter/blob/main/src/articles.ts): `src/articles.ts`
- [Search and discovery](https://github.com/xittered/xitter/blob/main/src/search.ts): `src/search.ts`
- [Communities and lists](https://github.com/xittered/xitter/blob/main/src/communities.ts): `src/communities.ts`
- [Community Notes](https://github.com/xittered/xitter/blob/main/src/notes.ts): `src/notes.ts`

### Accounts and safety

- [Sessions and identity](https://github.com/xittered/xitter/blob/main/src/auth.ts): `src/auth.ts`
- [Profiles and follows](https://github.com/xittered/xitter/blob/main/src/users.ts): `src/users.ts`
- [Blocks and mutes](https://github.com/xittered/xitter/blob/main/src/blocks.ts): `src/blocks.ts`
- [Moderation controls](https://github.com/xittered/xitter/blob/main/src/moderation.ts): `src/moderation.ts`

### Media and messaging

- [Media uploads](https://github.com/xittered/xitter/blob/main/src/media.ts): `src/media.ts`
- [Encrypted messaging](https://github.com/xittered/xitter/blob/main/src/chat.ts): `src/chat.ts`

### Instance operations

- [Admin panel](https://github.com/xittered/xitter/blob/main/src/admin.ts): `src/admin.ts`
- [Instance settings](https://github.com/xittered/xitter/blob/main/src/settings.ts): `src/settings.ts`
- [Account analytics](https://github.com/xittered/xitter/blob/main/src/analytics.ts): `src/analytics.ts`
- [Notifications and push](https://github.com/xittered/xitter/blob/main/src/notifications.ts): `src/notifications.ts`

### Other components

- **Browser user**
- **Pinned X client**
- **PostgreSQL**

## Connections

- Browser user → Pinned X client: uses
- Pinned X client → HTTP server: sends API requests
- HTTP server → GraphQL API: routes requests (evidence: `src/server.ts`)
- HTTP server → Sessions and identity: uses sessions (evidence: `src/server.ts`)
- HTTP server → Admin panel: routes admin (evidence: `src/server.ts`)
- GraphQL API → Posts and timelines: dispatches operations (evidence: `src/graphql.ts`)
- GraphQL API → Encrypted messaging: dispatches operations (evidence: `src/graphql.ts`)
- GraphQL API → Communities and lists: dispatches operations (evidence: `src/graphql.ts`)
- GraphQL API → Account analytics: dispatches operations (evidence: `src/graphql.ts`)
- GraphQL API → Notifications and push: dispatches operations (evidence: `src/graphql.ts`)
- Posts and timelines → Media uploads: loads media (evidence: `src/posts.ts`)
- Posts and timelines → Profiles and follows: loads authors (evidence: `src/posts.ts`)
- Posts and timelines → Blocks and mutes: checks blocks (evidence: `src/posts.ts`)
- Posts and timelines → Moderation controls: checks content (evidence: `src/posts.ts`)
- Posts and timelines → Instance settings: checks blocked phrases (evidence: `src/posts.ts`)
- Posts and timelines → Client response models: uses response models (evidence: `src/posts.ts`)
- Long-form articles → Media uploads: uses media (evidence: `src/articles.ts`)
- Long-form articles → Client response models: uses response models (evidence: `src/articles.ts`)
- Sessions and identity → Moderation controls: expires sanctions (evidence: `src/auth.ts`)
- Admin panel → Instance settings: updates settings (evidence: `src/admin.ts`)
- Client asset build → Client asset archive: reads archive (evidence: `src/build.ts`)
- HTTP server → Public API: serves public API (evidence: `src/server.ts`)
- HTTP server → Client asset archive: serves client assets (evidence: `src/server.ts`)
- Posts and timelines → PostgreSQL: reads and writes (evidence: `src/posts.ts`)
- Sessions and identity → PostgreSQL: reads and writes (evidence: `src/auth.ts`)
- Admin panel → PostgreSQL: reads and writes (evidence: `src/admin.ts`)
- GraphQL API → Search and discovery: dispatches operations (evidence: `src/graphql.ts`)
