# obris-dev/openmagpie architecture

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

- Interactive diagram: https://gitdiagram.com/obris-dev/openmagpie
- Repository: https://github.com/obris-dev/openmagpie

## Overview

OpenMagpie is an open-source social-listening system operated through a CLI. The main workflow is to configure feeds and watches, poll community sources into feed items, evaluate new items against natural-language criteria with an OpenAI-compatible LLM, and send matches to a chosen action. The graph also preserves documented backfill, activity, authentication, and delivery capabilities. Relationships beyond the excerpts are based on README workflow statements; unsampled subsystem paths identify their existing source directories, not inspected implementation details.

Main entry points: [`apps/core/watches/services/runs/_service.py`](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/services/runs/_service.py) (Run processing), [`apps/core/watches/actions`](https://github.com/obris-dev/openmagpie/tree/main/apps/core/watches/actions) (Delivery actions), [`apps/core/watches/actions/registry.py`](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/actions/registry.py) (Action dispatch), [`apps/core/feeds/models/feed_item.py`](https://github.com/obris-dev/openmagpie/blob/main/apps/core/feeds/models/feed_item.py) (Feed items)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and access"]
  node_cli_commands["CLI commands"]
  node_cli_context["CLI context<br/>[context.py]"]
  node_cli_transport["CLI API transport<br/>[http.py]"]
  node_api_server["Core API"]
  node_auth["Authentication"]
end

subgraph group_ingestion["Feed ingestion"]
  node_feed_config["Feed configuration"]
  node_source_connectors["Source connectors"]
  node_feed_polling["Feed polling<br/>[polling.py]"]
  node_feed_items[("Feed items<br/>[feed_item.py]")]
end

subgraph group_watch["Watch processing"]
  node_watch_config["Watch configuration"]
  node_watch_trigger["Watch triggering<br/>[trigger.py]"]
  node_run_drain["Run processing<br/>[_service.py]"]
  node_run_batches["Action batching<br/>[_run_batches.py]"]
  node_action_dispatch["Action dispatch<br/>[registry.py]"]
  node_semantic_filter["Semantic filtering<br/>[_engine_action.py]"]
  node_backfills["Backfill processing<br/>[backfill.py]"]
  node_activity[("Activity and delivery records")]
end

subgraph group_integrations["Engines and delivery"]
  node_engine_registry["Engine registry<br/>[registry.py]"]
  node_llm_engine["OpenAI-compatible engine<br/>[engine.py]"]
  node_delivery_actions["Delivery actions"]
end

node_operator(("Operator"))
node_llm_service{{"LLM endpoint"}}
node_webhook_receiver{{"Webhook receiver"}}
node_openbower{{"OpenBower"}}
node_logs["Logs"]

node_operator -->|"configures and operates"| node_cli_commands
node_cli_commands -->|"uses"| node_cli_context
node_cli_context -->|"creates"| node_cli_transport
node_cli_transport -->|"sends API requests"| node_api_server
node_api_server -.->|"provides authentication"| node_auth
node_operator -->|"curates sources"| node_feed_config
node_feed_config -->|"selects sources"| node_source_connectors
node_source_connectors -->|"fetches posts"| node_feed_polling
node_feed_polling -->|"stores items"| node_feed_items
node_operator -->|"defines criteria"| node_watch_config
node_watch_config -->|"configures watches"| node_watch_trigger
node_feed_items -->|"supplies new posts"| node_watch_trigger
node_watch_trigger -->|"triggers runs"| node_run_drain
node_run_drain -->|"uses"| node_run_batches
node_run_drain -.->|"dispatches actions"| node_action_dispatch
node_action_dispatch -->|"runs filter"| node_semantic_filter
node_semantic_filter -->|"resolves engine"| node_engine_registry
node_engine_registry -->|"registers engine"| node_llm_engine
node_llm_engine -->|"scores posts"| node_llm_service
node_action_dispatch -->|"runs delivery"| node_delivery_actions
node_delivery_actions -->|"sends matches"| node_webhook_receiver
node_delivery_actions -->|"sends signals"| node_openbower
node_delivery_actions -->|"writes matches"| node_logs
node_run_drain -.->|"records run results"| node_activity
node_operator -->|"requests backfill"| node_backfills
node_backfills -->|"processes prior posts"| node_feed_items
node_operator -->|"reviews activity"| node_activity

click node_cli_commands "https://github.com/obris-dev/openmagpie/tree/main/apps/cli/src/openmagpie/commands"
click node_cli_context "https://github.com/obris-dev/openmagpie/blob/main/apps/cli/src/openmagpie/context.py"
click node_cli_transport "https://github.com/obris-dev/openmagpie/blob/main/apps/cli/src/openmagpie/http.py"
click node_api_server "https://github.com/obris-dev/openmagpie/tree/main/apps/core"
click node_auth "https://github.com/obris-dev/openmagpie/tree/main/apps/core/auth_api"
click node_feed_config "https://github.com/obris-dev/openmagpie/tree/main/apps/core/feeds"
click node_source_connectors "https://github.com/obris-dev/openmagpie/tree/main/apps/core/sources/connectors"
click node_feed_polling "https://github.com/obris-dev/openmagpie/blob/main/apps/core/feeds/services/polling.py"
click node_feed_items "https://github.com/obris-dev/openmagpie/blob/main/apps/core/feeds/models/feed_item.py"
click node_watch_config "https://github.com/obris-dev/openmagpie/tree/main/apps/core/watches/services/watches"
click node_watch_trigger "https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/operations/trigger.py"
click node_run_drain "https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/services/runs/_service.py"
click node_run_batches "https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/services/_run_batches.py"
click node_action_dispatch "https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/actions/registry.py"
click node_semantic_filter "https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/actions/_engine_action.py"
click node_backfills "https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/operations/backfill.py"
click node_activity "https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/models/watch_action_run.py"
click node_engine_registry "https://github.com/obris-dev/openmagpie/blob/main/apps/core/engine/registry.py"
click node_llm_engine "https://github.com/obris-dev/openmagpie/blob/main/apps/core/engine/engines/openai_compat/engine.py"
click node_delivery_actions "https://github.com/obris-dev/openmagpie/tree/main/apps/core/watches/actions"

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_cli_commands,node_cli_context,node_cli_transport,node_api_server,node_auth toneBlue
class node_feed_config,node_source_connectors,node_feed_polling,node_feed_items toneAmber
class node_watch_config,node_watch_trigger,node_run_drain,node_run_batches,node_action_dispatch,node_semantic_filter,node_backfills,node_activity,node_webhook_receiver toneMint
class node_engine_registry,node_llm_engine,node_delivery_actions toneRose
class node_operator,node_llm_service,node_openbower,node_logs toneIndigo
```

## Components

### CLI and access

- [CLI commands](https://github.com/obris-dev/openmagpie/tree/main/apps/cli/src/openmagpie/commands): `apps/cli/src/openmagpie/commands`
- [CLI context](https://github.com/obris-dev/openmagpie/blob/main/apps/cli/src/openmagpie/context.py): `apps/cli/src/openmagpie/context.py`
- [CLI API transport](https://github.com/obris-dev/openmagpie/blob/main/apps/cli/src/openmagpie/http.py): `apps/cli/src/openmagpie/http.py`
- [Core API](https://github.com/obris-dev/openmagpie/tree/main/apps/core): `apps/core`
- [Authentication](https://github.com/obris-dev/openmagpie/tree/main/apps/core/auth_api): `apps/core/auth_api`

### Feed ingestion

- [Feed configuration](https://github.com/obris-dev/openmagpie/tree/main/apps/core/feeds): `apps/core/feeds`
- [Source connectors](https://github.com/obris-dev/openmagpie/tree/main/apps/core/sources/connectors): `apps/core/sources/connectors`
- [Feed polling](https://github.com/obris-dev/openmagpie/blob/main/apps/core/feeds/services/polling.py): `apps/core/feeds/services/polling.py`
- [Feed items](https://github.com/obris-dev/openmagpie/blob/main/apps/core/feeds/models/feed_item.py): `apps/core/feeds/models/feed_item.py`

### Watch processing

- [Watch configuration](https://github.com/obris-dev/openmagpie/tree/main/apps/core/watches/services/watches): `apps/core/watches/services/watches`
- [Watch triggering](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/operations/trigger.py): `apps/core/watches/operations/trigger.py`
- [Run processing](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/services/runs/_service.py): `apps/core/watches/services/runs/_service.py`
- [Action batching](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/services/_run_batches.py): `apps/core/watches/services/_run_batches.py`
- [Action dispatch](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/actions/registry.py): `apps/core/watches/actions/registry.py`
- [Semantic filtering](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/actions/_engine_action.py): `apps/core/watches/actions/_engine_action.py`
- [Backfill processing](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/operations/backfill.py): `apps/core/watches/operations/backfill.py`
- [Activity and delivery records](https://github.com/obris-dev/openmagpie/blob/main/apps/core/watches/models/watch_action_run.py): `apps/core/watches/models/watch_action_run.py`

### Engines and delivery

- [Engine registry](https://github.com/obris-dev/openmagpie/blob/main/apps/core/engine/registry.py): `apps/core/engine/registry.py`
- [OpenAI-compatible engine](https://github.com/obris-dev/openmagpie/blob/main/apps/core/engine/engines/openai_compat/engine.py): `apps/core/engine/engines/openai_compat/engine.py`
- [Delivery actions](https://github.com/obris-dev/openmagpie/tree/main/apps/core/watches/actions): `apps/core/watches/actions`

### Other components

- **Operator**
- **LLM endpoint**
- **Webhook receiver**
- **OpenBower**
- **Logs**

## Connections

- Operator → CLI commands: configures and operates
- CLI commands → CLI context: uses (evidence: `apps/cli/src/openmagpie/commands/auth.py`)
- CLI context → CLI API transport: creates (evidence: `apps/cli/src/openmagpie/context.py`)
- CLI API transport → Core API: sends API requests (evidence: `apps/cli/src/openmagpie/http.py`)
- Core API → Authentication: provides authentication (evidence: `apps/core/watches/tests_delivery_routes.py`)
- Operator → Feed configuration: curates sources
- Feed configuration → Source connectors: selects sources
- Source connectors → Feed polling: fetches posts
- Feed polling → Feed items: stores items
- Operator → Watch configuration: defines criteria
- Watch configuration → Watch triggering: configures watches
- Feed items → Watch triggering: supplies new posts
- Watch triggering → Run processing: triggers runs
- Run processing → Action batching: uses (evidence: `apps/core/watches/services/runs/_service.py`)
- Run processing → Action dispatch: dispatches actions
- Action dispatch → Semantic filtering: runs filter
- Semantic filtering → Engine registry: resolves engine (evidence: `apps/core/watches/actions/_engine_action.py`)
- Engine registry → OpenAI-compatible engine: registers engine (evidence: `apps/core/engine/registry.py`)
- OpenAI-compatible engine → LLM endpoint: scores posts
- Action dispatch → Delivery actions: runs delivery
- Delivery actions → Webhook receiver: sends matches
- Delivery actions → OpenBower: sends signals
- Delivery actions → Logs: writes matches
- Run processing → Activity and delivery records: records run results
- Operator → Backfill processing: requests backfill
- Backfill processing → Feed items: processes prior posts
- Operator → Activity and delivery records: reviews activity
