How bsorrentino/langgraph4j works
Project type and purpose
• This is a multi-module, open-source Java framework (LangGraph4j) plus accompanying tools (CLI samples, code generator, web-based “studio”) for building stateful, multi-agent LLM applications.
File structure
• Top-level modules:
• core/ — the heart of the library (state graphs, nodes, edges, checkpointing, visualization).
• agent-executor/ — a CLI sample that uses core + LangChain4j or Spring AI to run agents.
• generator/ — a Java backend + Next.js “builder-webui” frontend to scaffold LangGraph code.
• langchain4j/, spring-ai/, spring-ai-agent/ — integration libraries and samples for different LLM stacks.
• studio/ — multiple server implementations (jetty/, quarkus/, springboot/) plus a pure frontend webui/ module.
• samples/ & how-tos/ — example projects and notebooks.
• pom.xml + CI workflows + scripts — build and deploy pipelines.
README for additional insights
• References to external LLM services (OpenAI, Azure OpenAI, custom tools).
• The “generator” is a visual builder linked in the docs.
a. Main components
• Core Library (langgraph4j-core)
• Integration Libraries (langchain4j, spring-ai modules)
• CLI Sample (agent-executor)
• Generator Service
• Generator Backend (Java)
• Builder-WebUI (Next.js)
• Studio Players
• Backend Servers (Jetty, Quarkus, Spring Boot)
• Frontend WebUI (static assets served by any server)
• External Systems
• LLM Providers (OpenAI, Azure, Ollama, etc.)
• Tool Endpoints (e.g., custom functions)
b. Relationships & interactions
1. Developer apps depend on Core → build graphs → at runtime call LLM Providers.
2. CLI Sample uses Core + Integration Lib to orchestrate agent loop.
3. Generator UI → calls Generator Backend → produces scaffolded Java code (uses Core).
4. Studio Frontend → issues HTTP requests to chosen Backend (Jetty/Quarkus/Spring Boot) → backends load Core + serializers + stateful graph engine → call LLM Providers and return streaming updates to UI.
5. How-tos and samples illustrate direct Core usage or integration patterns.
c. Architectural patterns & principles
• Multi-module Maven layering:
Core at the base → integration modules → tools & services → UIs.
• Plugin-style extensibility: each module plugs into Core via well-defined APIs (NodeAction, EdgeAction, Serializer).
• Microservice pattern for Studio: interchangeable servers serving the same WebUI.
• Reactive/async streaming between engine and UI (CompletableFuture & WebSockets or SSE).
d. Key technologies/frameworks
• Java 17, Maven multi-module
• Spring Boot, Quarkus, Jetty for servers
• Next.js for Builder-WebUI & WebUI frontend
• CompletableFuture & java-async-generator for streaming
• CI/CD via GitHub Actions (deploy to Maven Central & GitHub Pages)