# langchain-ai/social-media-agent architecture

> Architecture diagram of the GitHub repository langchain-ai/social-media-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/langchain-ai/social-media-agent
- Repository: https://github.com/langchain-ai/social-media-agent

## Overview

1. **Repository shape and runtime split**
   - The main system is a TypeScript/LangGraph application under `src/`, driven by `yarn` and the LangGraph CLI.
   - There are two notable sidecar packages: `memory-v2/` (a separate Python/LangGraph project) and `slack-messaging/` (a Python Slack-related service/package). They are adjacent to the main app but not the primary post-generation path.

2. **Primary product flow: URL in, social post out**
   - The core user-facing path is `generate_post`: given a URL, the system scrapes or fetches the source content, turns it into structured understanding, generates a social post, and then pauses for human review/approval before publishing or scheduling to Twitter/X and LinkedIn.
   - The README’s quickstart maps directly to this flow: start the LangGraph server, invoke `generate_post`, then inspect the run in LangSmith or Agent Inbox.

3. **Central orchestration layer**
   - The main architecture is graph-based. `src/agents/generate-post/` contains the central graph, its state, prompts, and nodes.
   - The graph is not a single linear chain: it branches into extraction, content verification, post/report generation, social auth, rewriting, and interruption handling, which is why LangGraph is the key runtime boundary.

4. **Content acquisition and normalization**
   - `src/agents/ingest-data/`, `src/agents/curate-data/`, and `src/agents/repurposer/` handle the “bring content into the system” side.
   - These agents ingest from sources like Slack, Twitter, Reddit, GitHub, newsletters, and general URLs. The `curate-data` subsystem has source-specific loaders and verification nodes, while `ingest-data` and `ingest-repurposed-data` move external inputs into the graph pipeline.

5. **Source-specific verification and extraction**
   - Separate verification graphs exist for different content types: `verify-links`, `verify-reddit-post`, `verify-tweet`, and shared verification helpers under `src/agents/shared/nodes/`.
   - This is an important architectural boundary: raw external content is first normalized and validated before it can be used for generation. The repo is deliberately modular here because different sources require different APIs and correctness checks.

6. **Post generation and human-in-the-loop approval**
   - `src/agents/generate-post/` and shared `generate-post` nodes implement the main transformation from source content to a draft post.
   - The flow includes condensing/rewriting, social-specific formatting, optional URL rewriting, and then a human interrupt path (`human-node`, `curated-post-interrupt`, `repurposer-post-interrupt`) so a user can accept, edit, or reject output before publishing. This HITL step is a first-class architectural feature, not an add-on.

7. **Image discovery and media handling**
   - Media is handled by `src/agents/find-and-generate-images/` and `src/agents/repurposer/nodes/validate-images.ts`.
   - The system can find candidate images, generate images, rank them, validate them, and store them externally. The README makes clear that Supabase is used for image storage, which makes media persistence a separate infrastructure concern from text generation.

8. **External service boundary: social auth and platform clients**
   - `src/clients/` isolates integrations with Twitter, LinkedIn, Reddit, Slack, and the auth server.
   - Authentication is a major architectural boundary: the repo supports either Arcade-based auth or direct OAuth/app credentials for Twitter and LinkedIn. Posting and scheduling actions are delegated to these client modules so the graph logic stays platform-agnostic.

9. **Publishing and scheduling**
   - Publishing is not just “send immediately”; there are nodes and scripts for scheduling posts, updating scheduled dates, and uploading content (`upload-post`, `schedule-post`, `update-scheduled-date`).
   - The `generate-thread` agent adds another publishing path for multi-post thread creation and scheduling, showing that “content generation” and “publication orchestration” are separate responsibilities.

10. **Higher-level coordination and repurposing**
   - `src/agents/supervisor/` coordinates multiple outputs, such as determining post type and grouping reports.
   - `src/agents/repurposer/` and `src/agents/curated-post-interrupt/` support a second major use case: taking existing material and turning it into campaign content. This is architecturally distinct from the one-off URL-to-post flow, but it reuses the same shared verification, generation, and interrupt patterns.

11. **Shared utilities and common state**
   - `src/agents/shared/` contains reusable auth, prompt, verification, routing, and scheduling nodes, plus shared state definitions and stores.
   - `src/utils/` holds cross-cutting infrastructure helpers such as Firecrawl scraping, GitHub content fetches, screenshots, date/schedule logic, and Supabase access. These utilities are the glue between the graphs and the external world.

12. **Operational tooling and automation**
   - `scripts/` contains operational entry points for cron creation, backfills, scheduled run inspection, deletion, and repurposing workflows.
   - The repository is designed to run with LangGraph server locally or deployed, and the Agent Inbox is treated as the operator UI for interrupts and approvals. Cron jobs and Slack ingestion make the system asynchronous and batch-friendly.

13. **Quality gates and evaluation**
   - The repo has extensive integration and E2E coverage under `src/tests/`, `src/evals/`, and per-agent test folders.
   - This matters architecturally because many flows depend on live external services; tests and evals are used to validate source extraction, generation quality, and image handling across those service boundaries.

14. **Language and service boundaries**
   - The primary production code is TypeScript, but Python is used for specific LangGraph-adjacent components (`memory-v2`, `slack-messaging`).
   - That split suggests the repo is organized around a TypeScript orchestration core with a few specialized Python services/modules, rather than a single monolithic runtime.

15. **How to draw the diagram**
   - The best architecture diagram would show: external content sources and Slack on the left; a LangGraph orchestration core in the center; shared verification/extraction/generation/image/publishing modules around it; and external services on the right (Anthropic, Firecrawl, Supabase, Twitter/X, LinkedIn, GitHub, Slack, LangSmith, LangGraph Platform/Agent Inbox).
   - The key control flow is: ingest or direct URL → verify/extract/normalize → generate report/post/thread → human interrupt → auth/publish/schedule → optional Slack update or stored artifact.

Main entry points: [`src/agents/generate-post/generate-post-graph.ts`](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/generate-post/generate-post-graph.ts) (Generate post), [`src/agents/shared/nodes/generate-post`](https://github.com/langchain-ai/social-media-agent/tree/main/src/agents/shared/nodes/generate-post) (Shared post nodes), [`src/agents/repurposer/index.ts`](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/repurposer/index.ts) (Repurposer), [`src/agents/ingest-data/ingest-data-graph.ts`](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/ingest-data/ingest-data-graph.ts) (Content sources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_ts_core["TypeScript core"]
  node_n_generate_post{{"Generate post<br/>langgraph app"}}
  node_n_shared_gen_nodes["Shared post nodes<br/>workflow nodes"]
  node_n_verify_chain["Verification graphs<br/>validation flows"]
  node_n_ingest_curate["Ingest and curate<br/>content pipeline<br/>[index.ts]"]
  node_n_repurposer{{"Repurposer<br/>campaign pipeline<br/>[index.ts]"}}
  node_n_images["Image pipeline<br/>media workflow"]
  node_n_thread["Thread builder<br/>thread workflow<br/>[index.ts]"]
  node_n_supervisor["Supervisor<br/>orchestration"]
  node_n_report["Report gen<br/>analysis workflow<br/>[index.ts]"]
  node_n_interrupts(("Human interrupts<br/>approval layer<br/>[human-node.ts]"))
  node_n_shared_state["Shared state<br/>state and stores<br/>[shared-state.ts]"]
  node_n_utils["Core utils<br/>infrastructure helpers"]
  node_n_scripts["Ops scripts<br/>automation<br/>[generate-post.ts]"]
end

subgraph group_grp_py_sidecars["Python sidecars"]
  node_n_memory_v2{{"Memory v2<br/>python langgraph<br/>[graph.py]"}}
  node_n_slack_messaging["Slack messaging<br/>python service<br/>[server.py]"]
end

subgraph group_grp_ext["External services"]
  node_n_clients["Platform clients<br/>integrations"]
  node_n_langsmith["LangGraph ops<br/>runtime and observability<br/>[langgraph.json]"]
  node_n_supabase[("Supabase<br/>storage<br/>[supabase.ts]")]
  node_n_social_platforms["Social platforms<br/>publish targets<br/>[client.ts]"]
  node_n_sources["Content sources<br/>external inputs"]
end

node_n_sources -->|"ingest"| node_n_ingest_curate
node_n_sources -->|"verify"| node_n_verify_chain
node_n_ingest_curate -->|"normalize"| node_n_shared_state
node_n_verify_chain -->|"validate"| node_n_shared_state
node_n_shared_state -->|"drive"| node_n_generate_post
node_n_generate_post -->|"compose"| node_n_shared_gen_nodes
node_n_generate_post -->|"branch"| node_n_report
node_n_generate_post -->|"media"| node_n_images
node_n_generate_post -->|"pause"| node_n_interrupts
node_n_interrupts -->|"approve/edit"| node_n_clients
node_n_shared_gen_nodes -->|"publish"| node_n_clients
node_n_shared_gen_nodes -->|"send"| node_n_social_platforms
node_n_shared_gen_nodes -->|"store media"| node_n_supabase
node_n_repurposer -->|"reuse verify"| node_n_verify_chain
node_n_repurposer -->|"reuse media"| node_n_images
node_n_repurposer -->|"review"| node_n_interrupts
node_n_thread -->|"schedule"| node_n_clients
node_n_supervisor -->|"group"| node_n_report
node_n_utils -->|"fetch"| node_n_sources
node_n_utils -->|"persist"| node_n_supabase
node_n_scripts -->|"run"| node_n_generate_post
node_n_scripts -->|"orchestrate"| node_n_repurposer
node_n_langsmith -.->|"inspect"| node_n_generate_post
node_n_memory_v2 -.->|"adjacent"| node_n_generate_post
node_n_slack_messaging -.->|"adjacent"| node_n_ingest_curate

click node_n_generate_post "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/generate-post/generate-post-graph.ts"
click node_n_shared_gen_nodes "https://github.com/langchain-ai/social-media-agent/tree/main/src/agents/shared/nodes/generate-post"
click node_n_verify_chain "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/verify-links/verify-links-graph.ts"
click node_n_ingest_curate "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/curate-data/index.ts"
click node_n_repurposer "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/repurposer/index.ts"
click node_n_images "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/find-and-generate-images/find-and-generate-images-graph.ts"
click node_n_thread "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/generate-thread/index.ts"
click node_n_supervisor "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/supervisor/supervisor-graph.ts"
click node_n_report "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/generate-report/index.ts"
click node_n_interrupts "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/shared/nodes/generate-post/human-node.ts"
click node_n_shared_state "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/shared/shared-state.ts"
click node_n_clients "https://github.com/langchain-ai/social-media-agent/tree/main/src/clients"
click node_n_utils "https://github.com/langchain-ai/social-media-agent/tree/main/src/utils"
click node_n_langsmith "https://github.com/langchain-ai/social-media-agent/blob/main/langgraph.json"
click node_n_supabase "https://github.com/langchain-ai/social-media-agent/blob/main/src/utils/supabase.ts"
click node_n_social_platforms "https://github.com/langchain-ai/social-media-agent/blob/main/src/clients/twitter/client.ts"
click node_n_sources "https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/ingest-data/ingest-data-graph.ts"
click node_n_memory_v2 "https://github.com/langchain-ai/social-media-agent/blob/main/memory-v2/memory_v2/graph.py"
click node_n_slack_messaging "https://github.com/langchain-ai/social-media-agent/blob/main/slack-messaging/src/langgraph_slack/server.py"
click node_n_scripts "https://github.com/langchain-ai/social-media-agent/blob/main/scripts/generate-post.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_n_generate_post,node_n_shared_gen_nodes,node_n_verify_chain,node_n_ingest_curate,node_n_repurposer,node_n_images,node_n_thread,node_n_supervisor,node_n_report,node_n_interrupts,node_n_shared_state,node_n_utils,node_n_scripts toneBlue
class node_n_memory_v2,node_n_slack_messaging toneAmber
class node_n_clients,node_n_langsmith,node_n_supabase,node_n_social_platforms,node_n_sources toneMint
```

## Components

### TypeScript core

Primary LangGraph application and shared runtime in src/.

- [Generate post](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/generate-post/generate-post-graph.ts): langgraph app · Central URL-to-social-post workflow with verification, rewriting, and human approval. · `src/agents/generate-post/generate-post-graph.ts`
- [Shared post nodes](https://github.com/langchain-ai/social-media-agent/tree/main/src/agents/shared/nodes/generate-post): workflow nodes · Reusable post-generation steps such as condense, auth, rewrite, and scheduling. · `src/agents/shared/nodes/generate-post`
- [Verification graphs](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/verify-links/verify-links-graph.ts): validation flows · Source-specific verification for links, Reddit posts, tweets, and general content. · `src/agents/verify-links/verify-links-graph.ts`
- [Ingest and curate](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/curate-data/index.ts): content pipeline · Loads content from Slack, Twitter, Reddit, GitHub, newsletters, and URLs into normalized inputs. · `src/agents/curate-data/index.ts`
- [Repurposer](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/repurposer/index.ts): campaign pipeline · Turns existing material into campaign content with extraction, planning, generation, and interrupts. · `src/agents/repurposer/index.ts`
- [Image pipeline](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/find-and-generate-images/find-and-generate-images-graph.ts): media workflow · Finds, generates, ranks, validates, and persists images for posts and campaigns. · `src/agents/find-and-generate-images/find-and-generate-images-graph.ts`
- [Thread builder](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/generate-thread/index.ts): thread workflow · Generates multi-post threads, handles human review, and schedules publication. · `src/agents/generate-thread/index.ts`
- [Supervisor](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/supervisor/supervisor-graph.ts): orchestration · Coordinates post type decisions and groups generated reports or outputs. · `src/agents/supervisor/supervisor-graph.ts`
- [Report gen](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/generate-report/index.ts): analysis workflow · Extracts key details and generates structured reports from source content. · `src/agents/generate-report/index.ts`
- [Human interrupts](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/shared/nodes/generate-post/human-node.ts): approval layer · Human-in-the-loop review paths for curated posts, repurposed posts, and general generation. · `src/agents/shared/nodes/generate-post/human-node.ts`
- [Shared state](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/shared/shared-state.ts): state and stores · Common state definitions, routing helpers, and persistence used across agents. · `src/agents/shared/shared-state.ts`
- [Core utils](https://github.com/langchain-ai/social-media-agent/tree/main/src/utils): infrastructure helpers · Scraping, GitHub fetching, screenshots, scheduling, Supabase, and other glue code. · `src/utils`
- [Ops scripts](https://github.com/langchain-ai/social-media-agent/blob/main/scripts/generate-post.ts): automation · Cron, backfill, run inspection, deletion, and repurposing entry points. · `scripts/generate-post.ts`

### Python sidecars

Adjacent LangGraph-related Python packages.

- [Memory v2](https://github.com/langchain-ai/social-media-agent/blob/main/memory-v2/memory_v2/graph.py): python langgraph · Separate Python LangGraph project for memory-related capabilities. · `memory-v2/memory_v2/graph.py`
- [Slack messaging](https://github.com/langchain-ai/social-media-agent/blob/main/slack-messaging/src/langgraph_slack/server.py): python service · Python Slack-related service packaged separately from the main TypeScript app. · `slack-messaging/src/langgraph_slack/server.py`

### External services

Third-party APIs, storage, and operator tools the graphs depend on.

- [Platform clients](https://github.com/langchain-ai/social-media-agent/tree/main/src/clients): integrations · Isolated clients for Twitter, LinkedIn, Reddit, Slack, and auth-server access. · `src/clients`
- [LangGraph ops](https://github.com/langchain-ai/social-media-agent/blob/main/langgraph.json): runtime and observability · LangGraph server, Agent Inbox, and LangSmith used to run and inspect workflows. · `langgraph.json`
- [Supabase](https://github.com/langchain-ai/social-media-agent/blob/main/src/utils/supabase.ts): storage · External persistence for images and other artifacts. · `src/utils/supabase.ts`
- [Social platforms](https://github.com/langchain-ai/social-media-agent/blob/main/src/clients/twitter/client.ts): publish targets · Twitter/X and LinkedIn publishing and scheduling endpoints. · `src/clients/twitter/client.ts`
- [Content sources](https://github.com/langchain-ai/social-media-agent/blob/main/src/agents/ingest-data/ingest-data-graph.ts): external inputs · URLs, Slack, Reddit, GitHub, newsletters, YouTube, and related source systems. · `src/agents/ingest-data/ingest-data-graph.ts`

## Connections

- Content sources → Ingest and curate: ingest · External content is pulled into normalized pipelines.
- Content sources → Verification graphs: verify · Raw inputs are checked before use.
- Ingest and curate → Shared state: normalize · Curated inputs are represented in shared workflow state.
- Verification graphs → Shared state: validate · Verified content is passed into common state.
- Shared state → Generate post: drive · State flows into the main generation graph.
- Generate post → Shared post nodes: compose · Central graph invokes reusable post-generation nodes.
- Generate post → Report gen: branch · The main workflow can also produce report-style outputs.
- Generate post → Image pipeline: media · Post generation can discover or create supporting images.
- Generate post → Human interrupts: pause · Human review is a first-class step before publication.
- Human interrupts → Platform clients: approve/edit · Approved content is handed to platform clients for action.
- Shared post nodes → Platform clients: publish · Shared nodes authenticate and post through platform clients.
- Shared post nodes → Social platforms: send · Posts are published or scheduled to social platforms.
- Shared post nodes → Supabase: store media · Generated or selected images are persisted externally.
- Repurposer → Verification graphs: reuse verify · Repurposing reuses verification and extraction boundaries.
- Repurposer → Image pipeline: reuse media · Campaign content can include validated images.
- Repurposer → Human interrupts: review · Repurposed outputs also pass through human approval.
- Thread builder → Platform clients: schedule · Threads are published or scheduled through platform clients.
- Supervisor → Report gen: group · Supervisor coordinates and groups generated reports.
- Core utils → Content sources: fetch · Utilities implement scraping and source retrieval.
- Core utils → Supabase: persist · Utilities handle external storage access.
- Ops scripts → Generate post: run · Scripts invoke the main generation workflow and cron automation.
- Ops scripts → Repurposer: orchestrate · Operational scripts support repurposing flows.
- LangGraph ops → Generate post: inspect · Runs are executed and inspected through LangGraph/LangSmith tooling.
- Memory v2 → Generate post: adjacent · Separate Python sidecar sits alongside the main app.
- Slack messaging → Ingest and curate: adjacent · Separate Slack service complements ingestion and messaging workflows.
