How mdrideout/junjo works
Project type and purpose
• This is primarily a Python library/framework (“Junjo”) for constructing, executing, and instrumenting AI workflows as directed graphs.
• It is not itself a deployed application but provides core modules (graph, node, workflow, telemetry, visualization) plus example applications (AI chat full-stack and a base sample workflow).
File structure
• src/junjo/ contains the core engine:
• app.py, workflow.py – orchestration entrypoints
• graph.py, node.py, edge.py, condition.py, state.py, store.py – graph construction and execution primitives
• react_flow/ – schema definitions for React Flow integration
• graphviz/ – utilities to render Graph objects via Graphviz
• telemetry/ – hook manager, schemas, junjo-server client, proto definitions, OTEL exporter
• util.py, run_concurrent.py – helper functions
• examples/ holds two references:
• ai_chat/ – full-stack example with a FastAPI backend structured by junjo workflows and a React/Vite frontend
• base/ – minimal Python CLI example showing junjo workflows and subflows
• docs/ holds Sphinx architecture and usage docs.
README for additional insights
• Junjo’s design goals: TDD, telemetry (OpenTelemetry), concurrent execution (asyncio), type safety (Pydantic).
• Optional companion junjo-server for telemetry visualization.
• Graphviz rendering support (broken currently).
Main components
a. Core Engine Modules (src/junjo)
• Graph Builder (graph.py)
• Node & Edge abstractions (node.py, edge.py, condition.py)
• Workflow Executor (workflow.py, run_concurrent.py)
• State & Store management (state.py, store.py)
• Utilities (util.py)
b. Telemetry Subsystem
• Hook Manager (telemetry/hook_manager.py)
• OTEL-compatible schemas & exporter (telemetry/otel_schema.py, junjo_server_otel_exporter.py)
• junjo-server gRPC client & proto (telemetry/junjo_server/client.py + proto/*.proto)
c. Visualization
• Graphviz Renderer (graphviz/utils.py)
• React Flow Schema (react_flow/schemas.py) for UI integration
d. Example Integrations
• ai_chat Backend: FastAPI app, database models, routes, LLM services, workflows
• ai_chat Frontend: React + Vite, API hooks, UI components
• base CLI: simple sample_workflow graph executed from main.py
Relationships and interactions
• Workflow Definition → uses Graph Builder to assemble nodes/edges.
• Workflow Executor → takes a Graph, schedules nodes (asyncio), updates State & Store.
• Telemetry Hook Manager → intercepts node/workflow lifecycle events, emits OTEL spans.
• OTEL Exporter → forwards telemetry to any OTEL backend or junjo-server via gRPC.
• Graphviz Renderer → consumes Graph → outputs image for offline visualization.
• React Flow Schema → serializes Graph → consumed by React Flow UI in frontend.
• Examples → import core modules to define workflows → integrate in a web service or CLI.
Architectural patterns & design principles
• Directed Graph (DAG) for workflow orchestration
• Dependency Injection via Hook Manager for telemetry
• Async/await concurrency model for parallel node execution
• Separation of Concerns: core engine vs. telemetry vs. visualization vs. integration
• Extensibility: users supply their own LLM functions, DB calls, business logic in nodes