Skip to content

Low Level Design

Sudhanshu edited this page Nov 11, 2026 · 1 revision

Low-Level Design (LLD)

The examples are functions, not an object-oriented agent framework. This UML diagram identifies the project-defined CLI function family and locally scoped schemas alongside LangGraph library types. ExampleFunction and GraphCompiler boxes represent functions, not Python classes.

UML class / module relationships

classDiagram
 direction TB
 class DemoRegistry {
   +EXAMPLES: dict
   +main(argv) int
   +self_test(results) None
 }
 class ExampleFunction {
   <<functions>>
   +example_greeting(export_dir) dict
   +example_conditional_edges(export_dir) dict
   +example_subgraph_wrapper(export_dir) dict
   +example_subgraph_direct(export_dir) dict
   +example_messages_state_llm(export_dir, model_name) dict
 }
 class GraphCompiler {
   <<function>>
   +compile_graph(builder, diagram_name, export_dir)
 }
 class StateGraph {
   <<LangGraph library>>
   +add_node(name, fn)
   +add_edge(source, target)
   +add_conditional_edges(source, router, mapping)
   +compile()
 }
 class CompiledGraph {
   <<LangGraph runtime>>
   +invoke(input_state)
   +get_graph()
 }
 class NumberState {
   <<TypedDict, local to example>>
   +num: int
   +num_type: str
   +output: str
 }
 class ChatMessageState {
   <<MessagesState, local to example>>
   +user_name: str
   +messages: list
 }
 class CompanyState {
   <<TypedDict, local to example>>
   +employee_name: str
   +hr_notes: str
   +it_notes: str
 }
 class HRState {
   <<TypedDict, local to wrapper>>
   +employee_name: str
   +hr_status: str
 }
 class ITState {
   <<TypedDict, local to wrapper>>
   +new_hire_name: str
   +assets: list
 }
 DemoRegistry ..> ExampleFunction : selects
 ExampleFunction ..> GraphCompiler : calls
 ExampleFunction ..> StateGraph : constructs
 GraphCompiler ..> StateGraph : compiles
 StateGraph --> CompiledGraph : creates
 ExampleFunction ..> NumberState : one demo
 ExampleFunction ..> ChatMessageState : chat demos
 ExampleFunction ..> CompanyState : direct subgraph
 ExampleFunction ..> HRState : parent wrapper
 ExampleFunction ..> ITState : inner subgraph
Loading

Execution contracts

Operation Input Output Important behavior
compile_graph(builder, diagram_name, export_dir) LangGraph builder, name, optional directory Compiled graph Exports Mermaid source when requested
main(argv) CLI arguments Exit code Runs topic(s), prints JSON, optionally self-tests
example_conditional_edges() Fixed local inputs 45 and 20 Result map Selects multiply/subtract after adding ten
example_typed_dict_state() NumberState dict Even/odd outputs Router consumes num_type
example_pydantic_state() GraphState Validated result or caught error Checks both input 15 and squared output for input 8
example_subgraph_wrapper() HRState Parent state Maps between HRState and ITState
example_subgraph_direct() CompanyState Shared state Adds compiled IT subgraph directly as a parent node
_openai_llm() Optional model name / environment ChatOpenAI instance Loads credentials only when opted in

Internal diagrams

Caveats

MessagesState and Pydantic are library abstractions. NumberState, CompanyState, HRState, and ITState are locally declared inside individual demos; the code is not a single long-lived shared-state application.

Clone this wiki locally