Architecture overview¶
Middleware Forge has two deployable parts and one engine:
| Part | Technology | Source | Runs on |
|---|---|---|---|
| Web UI | Blazor Web App, .NET 10, Interactive Server rendering, MudBlazor, BlazorMonaco | ui/ |
IIS (ASP.NET Core Module, in process) |
| Backend API | Python 3.13, FastAPI, uvicorn, SSE | src/middleware_forge/api |
Docker container |
| Engine | LangGraph, LiteLLM, Pydantic, lxml, python-docx, SQLAlchemy + Alembic on SQLite | src/middleware_forge |
Inside the backend, or the CLI process |
Context¶
%%{init: {"flowchart": {"nodeSpacing": 35, "rankSpacing": 70}}}%%
flowchart LR
subgraph users[Users]
browser([Browser])
cli([CLI])
end
subgraph web[IIS server]
ui["MiddlewareForge.Web<br/>Blazor Server"]
end
subgraph docker[Docker host]
api["forge-api<br/>FastAPI + LangGraph"]
vol[("/data")]
end
llm[(LLM)]
scm[(Git server)]
browser -->|SignalR| ui
ui -->|"REST, SSE"| api
api --- vol
api --> llm
api --> scm
cli -.-> llm
| Connection | Protocol |
|---|---|
| Browser → web UI | HTTPS and WebSockets (SignalR) |
| Web UI → backend | HTTP and server-sent events, with X-Forge-Api-Key, internal network only |
| Backend → LLM | OpenAI-compatible chat completions over HTTPS |
| Backend → git server | git over HTTPS and the pull-request REST API (Azure DevOps Server, GitHub or plain git) |
| CLI | Runs the same engine in-process with local files; it only needs the LLM |
- Browsers only talk to the web UI. The Blazor server calls the backend server to server and streams downloads through itself, so the backend is never exposed to users and CORS stays off.
- The backend is the only component with state. Everything is under
/data: one SQLite database for application state, one for LangGraph checkpoints, and folders for uploads, generated runs and git workspaces. - The LLM and the source-control server are external services reached over HTTPS, with an optional internal CA bundle.
Layers inside the backend¶
flowchart TB
api["<b>api</b>: HTTP layer<br/>routers: sessions, runs, repository, meta, health<br/>middleware: API key, request id"]
cli["<b>cli</b>: middleware-forge command"]
services["<b>services</b>: use cases<br/>sessions · runs · jobs · plan_ops · planning · grouping<br/>repository · uploads · downloads · retention"]
agent["<b>agent</b>: LangGraph<br/>session_agent (turn graph) · graph (generation graph and nodes)"]
engine["<b>generators</b>: layout · composition · artifacts<br/>builders · templates · llm_xml · validate · docs<br/><b>parsers</b>: detect · inspect · openapi · wsdl · wadl · xsd"]
infra["<b>infrastructure</b><br/>llm · progress (ProgressBroker) · persistence (SQLite stores)<br/>models · config · startup · logging · container"]
api --> services
cli --> services
services --> agent
services --> engine
agent --> engine
services --> infra
agent --> infra
engine --> infra
Dependencies point downwards only:
- Routers stay thin and call services.
- Services own the use cases and start graph runs.
- Graph nodes call generators and parsers.
- Everything uses the infrastructure modules.
The CLI (cli/) calls services.runs directly and skips the session layer.
Key design decisions¶
One plan, one vocabulary. A session owns a versioned GenerationPlan. Every change, from the Service Designer, from a chat message or from the API, is a list of structured plan operations applied by the deterministic plan_ops.apply_patch. The LLM only translates language into those operations; it never edits the plan directly.
Deterministic gates. plan_ops.validate_plan and sessions.session_issues report unassigned or duplicated operations, empty groups, name and endpoint conflicts, missing namespaces, missing schemas and similar problems. Errors block approval. After generation, generators.validate checks every artifact and cross-checks every OSB reference.
Two graphs. A short turn graph (agent/session_agent.py) handles each upload or chat message and edits the plan. A separate generation graph (agent/graph.py) runs an approved plan version as a background job. Chat never waits on generation.
Deterministic builders first, LLM as fallback. WSDL, XSD, WADL, XSLT and OpenAPI come from builders in generators/builders.py; proxies, pipelines and business services from templates in template/. If a builder's output fails validation, the LLM gets a critique loop to produce a valid artifact; if it cannot, the deterministic output is kept and the issue is reported.
Composition in the layout. Routing (direct or routing table) and schema reuse are decided once, when the plan is resolved into a layout, from the operations' backends and their actual schema dependencies. Templates and builders only render those decisions.
Units and fingerprints. A run is split into units (business_service:X, pipeline:Y, proxy:Y, xslt:Op, docs…), each with a hash of its inputs. A later run reuses the files of units whose fingerprint did not change.
Weak-model friendly. Structured LLM replies are requested as JSON schema when the endpoint supports it, validated with Pydantic, and repaired once with the validation error. There is no regular-expression fallback for chat; unclear requests get a question back.
Single process by design. Progress fan-out (ProgressBroker), the session event bus and the job pools live in the API process, and SQLite is the store. This keeps deployment to one container; see Known limitations for what it means for scaling.
Where to read next¶
- Modules: every package and its responsibilities.
- Workflows: sequence and flow diagrams of planning, generation, resume, cancellation and repository write-back.
- Data model and events: the plan, validation codes, database tables, events and file layouts.