# andrewnordstrom-eng/corgi architecture

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

- Interactive diagram: https://gitdiagram.com/andrewnordstrom-eng/corgi
- Repository: https://github.com/andrewnordstrom-eng/corgi

## Overview

Corgi is a community-governed Bluesky feed: public activity is collected and filtered, posts are scored against an approved community policy, and the ranked feed is published with inspectable score receipts. Members vote on weights, topics, and content rules in governance rounds; aggregation and review precede policy changes and reranking. The README documents PostgreSQL as canonical storage and Redis as the live-feed snapshot. The graph also includes transparency, user/operator interfaces, and the scoring SDK. Some subsystem links are documented rather than source-verified because their implementation excerpts were not provided.

Main entry points: [`src/scoring/pipeline.ts`](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/pipeline.ts) (Scoring pipeline), [`src/governance/server.ts`](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/server.ts) (Governance API), [`src/ingestion/handlers/post-handler.ts`](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/ingestion/handlers/post-handler.ts) (Post processing), [`src/db/client.ts`](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/db/client.ts) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection and Topics"]
  node_ingest["Activity ingestion<br/>[jetstream.ts]"]
  node_post_handler["Post processing<br/>[post-handler.ts]"]
  node_content_filter["Content rules<br/>[content-filter.ts]"]
  node_topic_classify["Topic tagging<br/>[classifier.ts]"]
  node_embedding["Topic embeddings<br/>[embedder.ts]"]
  node_taxonomy["Topic taxonomy<br/>[taxonomy.ts]"]
end

subgraph group_governance["Governance and Ranking"]
  node_governance_api["Governance API<br/>[server.ts]"]
  node_epoch_manager["Epoch lifecycle<br/>[epoch-manager.ts]"]
  node_aggregation["Vote aggregation<br/>[aggregation.ts]"]
  node_scoring["Scoring pipeline<br/>[pipeline.ts]"]
  node_score_components["Ranking signals"]
end

subgraph group_serving["Feed and Transparency"]
  node_feed_api["Feed endpoint<br/>[server.ts]"]
  node_transparency["Transparency API<br/>[server.ts]"]
end

subgraph group_interfaces["User and Operator Interfaces"]
  node_website["Website"]
  node_cli["Operator CLI<br/>[index.ts]"]
  node_mcp["MCP tools<br/>[server.ts]"]
  node_sdk["Scoring SDK<br/>[index.ts]"]
end

subgraph group_platform["Runtime and Research"]
  node_postgres[("PostgreSQL<br/>[client.ts]")]
  node_redis[("Redis feed snapshot<br/>[redis.ts]")]
  node_runtime["Service runtime<br/>[index.ts]"]
  node_maintenance["Data maintenance<br/>[cleanup.ts]"]
  node_research_harness["Governance harness<br/>[index.ts]"]
end

node_jetstream(("Bluesky Jetstream"))
node_members(("Community members"))
node_bluesky_apps(("Bluesky apps"))

node_jetstream -->|"streams activity"| node_ingest
node_ingest -.->|"dispatches events"| node_post_handler
node_post_handler -->|"applies rules"| node_content_filter
node_post_handler -->|"tags topics"| node_topic_classify
node_topic_classify -->|"uses taxonomy"| node_taxonomy
node_topic_classify -.->|"uses embeddings"| node_embedding
node_post_handler -->|"stores posts"| node_postgres
node_members -->|"submit ballots"| node_governance_api
node_governance_api -.->|"routes governance"| node_epoch_manager
node_epoch_manager -->|"aggregates votes"| node_aggregation
node_epoch_manager -->|"reruns ranking"| node_scoring
node_scoring -->|"reads and stores scores"| node_postgres
node_scoring -->|"scores posts"| node_score_components
node_scoring -->|"publishes snapshot"| node_redis
node_bluesky_apps -->|"requests feed"| node_feed_api
node_feed_api -->|"serves snapshot"| node_redis
node_website -->|"uses APIs"| node_governance_api
node_website -->|"views receipts"| node_transparency
node_cli -->|"operates governance"| node_governance_api
node_mcp -.->|"exposes tools"| node_governance_api
node_transparency -->|"reads score data"| node_postgres
node_runtime -->|"starts service"| node_feed_api
node_runtime -->|"starts ingestion"| node_ingest
node_runtime -->|"starts scoring"| node_scoring
node_maintenance -->|"cleans data"| node_postgres
node_research_harness -.->|"simulates ballots"| node_members
node_sdk -->|"defines contract"| node_score_components

click node_ingest "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/ingestion/jetstream.ts"
click node_post_handler "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/ingestion/handlers/post-handler.ts"
click node_content_filter "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/content-filter.ts"
click node_topic_classify "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/topics/classifier.ts"
click node_embedding "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/topics/embedder.ts"
click node_taxonomy "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/topics/taxonomy.ts"
click node_governance_api "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/server.ts"
click node_epoch_manager "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/epoch-manager.ts"
click node_aggregation "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/aggregation.ts"
click node_scoring "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/pipeline.ts"
click node_score_components "https://github.com/andrewnordstrom-eng/corgi/tree/main/src/scoring/components"
click node_postgres "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/db/client.ts"
click node_redis "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/db/redis.ts"
click node_feed_api "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/feed/server.ts"
click node_transparency "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/transparency/server.ts"
click node_website "https://github.com/andrewnordstrom-eng/corgi/tree/main/web-next"
click node_cli "https://github.com/andrewnordstrom-eng/corgi/blob/main/cli/src/index.ts"
click node_mcp "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/mcp/server.ts"
click node_sdk "https://github.com/andrewnordstrom-eng/corgi/blob/main/packages/feed-sdk/src/index.ts"
click node_runtime "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/index.ts"
click node_maintenance "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/maintenance/cleanup.ts"
click node_research_harness "https://github.com/andrewnordstrom-eng/corgi/blob/main/src/harness/index.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_ingest,node_post_handler,node_content_filter,node_topic_classify,node_embedding,node_taxonomy toneBlue
class node_governance_api,node_epoch_manager,node_aggregation,node_scoring,node_score_components toneAmber
class node_feed_api,node_transparency toneMint
class node_website,node_cli,node_mcp,node_sdk toneRose
class node_postgres,node_redis,node_runtime,node_maintenance,node_research_harness,node_jetstream,node_members,node_bluesky_apps toneIndigo
```

## Components

### Collection and Topics

- [Activity ingestion](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/ingestion/jetstream.ts): `src/ingestion/jetstream.ts`
- [Post processing](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/ingestion/handlers/post-handler.ts): `src/ingestion/handlers/post-handler.ts`
- [Content rules](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/content-filter.ts): `src/governance/content-filter.ts`
- [Topic tagging](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/topics/classifier.ts): `src/scoring/topics/classifier.ts`
- [Topic embeddings](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/topics/embedder.ts): `src/scoring/topics/embedder.ts`
- [Topic taxonomy](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/topics/taxonomy.ts): `src/scoring/topics/taxonomy.ts`

### Governance and Ranking

- [Governance API](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/server.ts): `src/governance/server.ts`
- [Epoch lifecycle](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/epoch-manager.ts): `src/governance/epoch-manager.ts`
- [Vote aggregation](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/governance/aggregation.ts): `src/governance/aggregation.ts`
- [Scoring pipeline](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/scoring/pipeline.ts): `src/scoring/pipeline.ts`
- [Ranking signals](https://github.com/andrewnordstrom-eng/corgi/tree/main/src/scoring/components): `src/scoring/components`

### Feed and Transparency

- [Feed endpoint](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/feed/server.ts): `src/feed/server.ts`
- [Transparency API](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/transparency/server.ts): `src/transparency/server.ts`

### User and Operator Interfaces

- [Website](https://github.com/andrewnordstrom-eng/corgi/tree/main/web-next): `web-next`
- [Operator CLI](https://github.com/andrewnordstrom-eng/corgi/blob/main/cli/src/index.ts): `cli/src/index.ts`
- [MCP tools](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/mcp/server.ts): `src/mcp/server.ts`
- [Scoring SDK](https://github.com/andrewnordstrom-eng/corgi/blob/main/packages/feed-sdk/src/index.ts): `packages/feed-sdk/src/index.ts`

### Runtime and Research

- [PostgreSQL](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/db/client.ts): `src/db/client.ts`
- [Redis feed snapshot](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/db/redis.ts): `src/db/redis.ts`
- [Service runtime](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/index.ts): `src/index.ts`
- [Data maintenance](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/maintenance/cleanup.ts): `src/maintenance/cleanup.ts`
- [Governance harness](https://github.com/andrewnordstrom-eng/corgi/blob/main/src/harness/index.ts): `src/harness/index.ts`

### Other components

- **Bluesky Jetstream**
- **Community members**
- **Bluesky apps**

## Connections

- Bluesky Jetstream → Activity ingestion: streams activity (evidence: `README.md`)
- Activity ingestion → Post processing: dispatches events
- Post processing → Content rules: applies rules (evidence: `src/ingestion/handlers/post-handler.ts`)
- Post processing → Topic tagging: tags topics (evidence: `src/ingestion/handlers/post-handler.ts`)
- Topic tagging → Topic taxonomy: uses taxonomy (evidence: `src/scoring/topics/classifier.ts`)
- Topic tagging → Topic embeddings: uses embeddings
- Post processing → PostgreSQL: stores posts (evidence: `README.md`)
- Community members → Governance API: submit ballots (evidence: `README.md`)
- Governance API → Epoch lifecycle: routes governance
- Epoch lifecycle → Vote aggregation: aggregates votes (evidence: `src/governance/epoch-manager.ts`)
- Epoch lifecycle → Scoring pipeline: reruns ranking (evidence: `src/governance/epoch-manager.ts`)
- Scoring pipeline → PostgreSQL: reads and stores scores (evidence: `README.md`)
- Scoring pipeline → Ranking signals: scores posts (evidence: `src/scoring/pipeline.ts`)
- Scoring pipeline → Redis feed snapshot: publishes snapshot (evidence: `README.md`)
- Bluesky apps → Feed endpoint: requests feed (evidence: `README.md`)
- Feed endpoint → Redis feed snapshot: serves snapshot (evidence: `README.md`)
- Website → Governance API: uses APIs (evidence: `README.md`)
- Website → Transparency API: views receipts (evidence: `README.md`)
- Operator CLI → Governance API: operates governance (evidence: `README.md`)
- MCP tools → Governance API: exposes tools
- Transparency API → PostgreSQL: reads score data (evidence: `README.md`)
- Service runtime → Feed endpoint: starts service (evidence: `src/index.ts`)
- Service runtime → Activity ingestion: starts ingestion (evidence: `src/index.ts`)
- Service runtime → Scoring pipeline: starts scoring (evidence: `src/index.ts`)
- Data maintenance → PostgreSQL: cleans data (evidence: `src/maintenance/cleanup.ts`)
- Governance harness → Community members: simulates ballots
- Scoring SDK → Ranking signals: defines contract (evidence: `README.md`)
