How hwchase17/langgraph-engineer works
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.