How langchain-ai/social-media-agent works
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: generate-post-graph.ts Generate post · generate-post Shared post nodes · index.ts Repurposer · ingest-data-graph.ts Content sources
Components 20
TypeScript core
Primary LangGraph application and shared runtime in src/.
- Generate post · Central URL-to-social-post workflow with verification, rewriting, and human approval.
src/agents/generate-post/generate-post-graph.ts - Shared post nodes · Reusable post-generation steps such as condense, auth, rewrite, and scheduling.
src/agents/shared/nodes/generate-post - Verification graphs · Source-specific verification for links, Reddit posts, tweets, and general content.
src/agents/verify-links/verify-links-graph.ts - Ingest and curate · Loads content from Slack, Twitter, Reddit, GitHub, newsletters, and URLs into normalized inputs.
src/agents/curate-data/index.ts - Repurposer · Turns existing material into campaign content with extraction, planning, generation, and interrupts.
src/agents/repurposer/index.ts - Image pipeline · 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 · Generates multi-post threads, handles human review, and schedules publication.
src/agents/generate-thread/index.ts - Supervisor · Coordinates post type decisions and groups generated reports or outputs.
src/agents/supervisor/supervisor-graph.ts - Report gen · Extracts key details and generates structured reports from source content.
src/agents/generate-report/index.ts - Human interrupts · 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 · Common state definitions, routing helpers, and persistence used across agents.
src/agents/shared/shared-state.ts - Core utils · Scraping, GitHub fetching, screenshots, scheduling, Supabase, and other glue code.
src/utils - Ops scripts · Cron, backfill, run inspection, deletion, and repurposing entry points.
scripts/generate-post.ts
Python sidecars
Adjacent LangGraph-related Python packages.
- Memory v2 · Separate Python LangGraph project for memory-related capabilities.
memory-v2/memory_v2/graph.py - Slack messaging · 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 · Isolated clients for Twitter, LinkedIn, Reddit, Slack, and auth-server access.
src/clients - LangGraph ops · LangGraph server, Agent Inbox, and LangSmith used to run and inspect workflows.
langgraph.json - Supabase · External persistence for images and other artifacts.
src/utils/supabase.ts - Social platforms · Twitter/X and LinkedIn publishing and scheduling endpoints.
src/clients/twitter/client.ts - Content sources · URLs, Slack, Reddit, GitHub, newsletters, YouTube, and related source systems.
src/agents/ingest-data/ingest-data-graph.ts
Connections 25
- 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.