# hwchase17/langgraph-engineer architecture

> Architecture diagram of the GitHub repository hwchase17/langgraph-engineer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hwchase17/langgraph-engineer
- Repository: https://github.com/hwchase17/langgraph-engineer

## Overview

##### High-Level Architecture Components
a. User Interface (LangGraph Studio)
- Web-based UI where a user initiates a “new LangGraph app” request.
b. Agent Service
- Exposed as an API in LangGraph Studio or Cloud.
- Core modules under src/langgraph_engineer:
- loader.py – loads prompts, schemas, config (from langgraph.json, .env).
- gather_requirements.py – conversational interface to collect user input.
- draft.py – uses LLM to generate initial graph draft.
- check.py – runs programmatic validations on the draft.
- critique.py – sends the draft to an LLM critique step.
- agent.py – orchestrates the pipeline steps in sequence.
- state.py – holds intermediate state (requirements, draft, check results).
- model.py – abstraction over the LLM provider (OpenAI, Anthropic, etc.).
c. External Services
- LLM Provider (e.g., OpenAI)
- LangGraph Cloud API / LangGraph Studio Host
d. Static Assets
- static/ – screenshot and any UI assets for branding/documentation.

##### Interactions & Data Flows
1. User clicks “Create new graph” in Studio UI → HTTP request to Agent Service.
2. loader.py loads config & prompt templates → passes to gather_requirements.
3. gather_requirements chats with user → populates state.requirements.
4. draft.py calls model.py (LLM API) with requirements → state.draft.
5. check.py validates state.draft programmatically → if fail, loop.
6. critique.py sends state.draft to LLM critique → if fail, loop.
7. Final draft returned to UI as JSON of nodes & edges.

##### Architectural Patterns & Principles
- Pipeline/Orchestration: a linear sequence of discrete, re–entrant steps.
- Separation of Concerns: each module has a single responsibility (prompt loading, requirements, drafting, checks, critique).
- Pluggable LLM Interface: model.py abstracts away the underlying LLM API.
- Config-Driven: loader.py + langgraph.json + .env.example centralize environment & prompt configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UI["LangGraph Studio UI"]:::external
    UI -->|"HTTP request"| AgentOrch

    subgraph "Agent Service"
        AgentOrch["agent.py\n(Orchestrator)"]:::core
        Loader["loader.py\n(Prompt & Config Loader)"]:::core
        Env[".env.example"]:::data
        Config["langgraph.json"]:::data
        Gather["gather_requirements.py\n(Requirements Gathering)"]:::core
        Draft["draft.py\n(Draft Generation)"]:::core
        Check["check.py\n(Programmatic Checks)"]:::core
        Critique["critique.py\n(LLM Critique)"]:::core
        State["state.py\n(Intermediate State)"]:::data
        Model["model.py\n(Pluggable LLM Interface)"]:::core

        AgentOrch -->|triggers| Loader
        Loader -->|loads prompts/config| Gather
        Env -->|loaded by| Loader
        Config -->|loaded by| Loader
        Gather -->|collects requirements| State
        Gather -->|requirements| Draft
        Draft -->|calls| Model
        Model -->|LLM API call| LLMProvider
        Draft -->|state.draft| Check
        Check -->|validation result| Critique
        Check -->|updates| State
        Critique -->|critique result| State
        Critique -->|loops or passes| Draft
        Critique -->|final draft| AgentOrch
        AgentOrch -->|returns JSON| UI
        State -.-> Draft

    end

    subgraph "External Services"
        LLMProvider["LLM Provider\n(OpenAI, Anthropic)"]:::external
        CloudAPI["LangGraph Cloud API"]:::external
    end

    subgraph "Static & Project Files"
        Static["Static Assets\n(static/)"]:::data
        README["README.md"]:::data
        PyProj["pyproject.toml"]:::data
    end

    UI -->|"serves UI assets"| Static
    AgentOrch -->|"optional cloud integration"| CloudAPI

    click AgentOrch "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/agent.py"
    click Loader "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/loader.py"
    click Gather "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/gather_requirements.py"
    click Draft "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/draft.py"
    click Check "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/check.py"
    click Critique "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/critique.py"
    click State "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/state.py"
    click Model "https://github.com/hwchase17/langgraph-engineer/blob/main/src/langgraph_engineer/model.py"
    click Env "https://github.com/hwchase17/langgraph-engineer/blob/main/.env.example"
    click Config "https://github.com/hwchase17/langgraph-engineer/blob/main/langgraph.json"
    click Static "https://github.com/hwchase17/langgraph-engineer/tree/main/static/"
    click PyProj "https://github.com/hwchase17/langgraph-engineer/blob/main/pyproject.toml"
    click README "https://github.com/hwchase17/langgraph-engineer/blob/main/README.md"

    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFA500,stroke:#000,stroke-width:1px
```
