# rajsingh18110/lmms architecture

> Architecture diagram of the GitHub repository rajsingh18110/lmms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajsingh18110/lmms
- Repository: https://github.com/rajsingh18110/lmms

## Overview

LMMs is a multi-interface agentic AI platform that runs open-source language models behind a backend for tools, retrieval, research, and session state. The principal workflow is user input through a CLI, GUI, or API into backend orchestration, then model inference through a selected runtime and a response. The README documents the dual runtimes and agent capabilities; sampled code shows API routing, runtime selection, orchestration setup, and research execution. Some connections to unsampled subsystems are documented rather than verified in source.

Main entry points: [`lmms/backend/main.py`](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/main.py) (Backend session), [`lmms/backend/orchestration/pipeline.py`](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/orchestration/pipeline.py) (Request orchestration), [`lmms/engine/manager.py`](https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/manager.py) (Runtime selection), [`lmms/cli/commands.py`](https://github.com/rajsingh18110/lmms/blob/main/lmms/cli/commands.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[commands.py]"]
  node_gui["GUI workspace<br/>[main_window.py]"]
end

subgraph group_gateway["API and backend"]
  node_api["HTTP API<br/>[server.py]"]
  node_backend["Backend session<br/>[main.py]"]
  node_backend_manager["Backend services<br/>[manager.py]"]
end

subgraph group_agent["Agent capabilities"]
  node_pipeline["Request orchestration<br/>[pipeline.py]"]
  node_agent_manager["Agent routing<br/>[manager.py]"]
  node_tool_execution["Tool execution<br/>[executor.py]"]
  node_research["Web research<br/>[engine.py]"]
  node_retrieval["Vector retrieval<br/>[rag.py]"]
  node_memory[("Session memory<br/>[core_memory.py]")]
  node_workspace["Workspace and Git<br/>[manager.py]"]
  node_extension_manager["Extensions<br/>[manager.py]"]
end

subgraph group_inference["Model inference"]
  node_engine_manager["Runtime selection<br/>[manager.py]"]
  node_llama["llama.cpp runtime<br/>[llama_cpp.py]"]
  node_pytorch["PyTorch runtime"]
  node_air["AirEngine<br/>[runtime.py]"]
  node_model_registry[("Model registry<br/>[registry.py]")]
end

node_user(("User"))
node_remote_engine["Remote engine"]

node_user -->|"enters request"| node_cli
node_user -.->|"uses workspace"| node_gui
node_user -->|"sends request"| node_api
node_cli -->|"sends API calls"| node_api
node_cli -->|"targets remote"| node_remote_engine
node_gui -.->|"uses backend"| node_backend
node_api -.->|"routes chat"| node_backend
node_backend -->|"prepares requests"| node_pipeline
node_backend -.->|"uses services"| node_backend_manager
node_pipeline -.->|"routes agent work"| node_agent_manager
node_pipeline -->|"dispatches tools"| node_tool_execution
node_pipeline -.->|"retrieves context"| node_retrieval
node_pipeline -.->|"uses session memory"| node_memory
node_pipeline -.->|"requests research"| node_research
node_backend -.->|"supports workspace"| node_workspace
node_user -.->|"adds extensions"| node_extension_manager
node_backend -.->|"selects runtime"| node_engine_manager
node_engine_manager -->|"selects runtime"| node_llama
node_engine_manager -->|"selects runtime"| node_pytorch
node_engine_manager -->|"loads AirEngine"| node_air
node_engine_manager -.->|"manages models"| node_model_registry
node_llama -.->|"returns generation"| node_backend
node_pytorch -.->|"returns generation"| node_backend
node_air -.->|"returns generation"| node_backend

click node_cli "https://github.com/rajsingh18110/lmms/blob/main/lmms/cli/commands.py"
click node_gui "https://github.com/rajsingh18110/lmms/blob/main/lmms/gui/core/main_window.py"
click node_api "https://github.com/rajsingh18110/lmms/blob/main/lmms/api/server.py"
click node_backend "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/main.py"
click node_backend_manager "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/logic/manager.py"
click node_pipeline "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/orchestration/pipeline.py"
click node_agent_manager "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/agents/manager.py"
click node_tool_execution "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/tools/core/executor.py"
click node_research "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/research/engine.py"
click node_retrieval "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/tools/rag.py"
click node_memory "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/memory/core_memory.py"
click node_workspace "https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/git/manager.py"
click node_extension_manager "https://github.com/rajsingh18110/lmms/blob/main/lmms/extensions/manager.py"
click node_engine_manager "https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/manager.py"
click node_llama "https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/runtimes/llama_cpp.py"
click node_pytorch "https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/runtimes/universal_pytorch.py"
click node_air "https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/air/runtime.py"
click node_model_registry "https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/registry.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_gui,node_user toneBlue
class node_api,node_backend,node_backend_manager toneAmber
class node_pipeline,node_agent_manager,node_tool_execution,node_research,node_retrieval,node_memory,node_workspace,node_extension_manager toneMint
class node_engine_manager,node_llama,node_pytorch,node_air,node_model_registry toneRose
class node_remote_engine toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/rajsingh18110/lmms/blob/main/lmms/cli/commands.py): `lmms/cli/commands.py`
- [GUI workspace](https://github.com/rajsingh18110/lmms/blob/main/lmms/gui/core/main_window.py): `lmms/gui/core/main_window.py`

### API and backend

- [HTTP API](https://github.com/rajsingh18110/lmms/blob/main/lmms/api/server.py): `lmms/api/server.py`
- [Backend session](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/main.py): `lmms/backend/main.py`
- [Backend services](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/logic/manager.py): `lmms/backend/logic/manager.py`

### Agent capabilities

- [Request orchestration](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/orchestration/pipeline.py): `lmms/backend/orchestration/pipeline.py`
- [Agent routing](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/agents/manager.py): `lmms/backend/agents/manager.py`
- [Tool execution](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/tools/core/executor.py): `lmms/backend/tools/core/executor.py`
- [Web research](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/research/engine.py): `lmms/backend/research/engine.py`
- [Vector retrieval](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/tools/rag.py): `lmms/backend/tools/rag.py`
- [Session memory](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/memory/core_memory.py): `lmms/backend/memory/core_memory.py`
- [Workspace and Git](https://github.com/rajsingh18110/lmms/blob/main/lmms/backend/git/manager.py): `lmms/backend/git/manager.py`
- [Extensions](https://github.com/rajsingh18110/lmms/blob/main/lmms/extensions/manager.py): `lmms/extensions/manager.py`

### Model inference

- [Runtime selection](https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/manager.py): `lmms/engine/manager.py`
- [llama.cpp runtime](https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/runtimes/llama_cpp.py): `lmms/engine/runtimes/llama_cpp.py`
- [PyTorch runtime](https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/runtimes/universal_pytorch.py): `lmms/engine/runtimes/universal_pytorch.py`
- [AirEngine](https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/air/runtime.py): `lmms/engine/air/runtime.py`
- [Model registry](https://github.com/rajsingh18110/lmms/blob/main/lmms/engine/registry.py): `lmms/engine/registry.py`

### Other components

- **User**
- **Remote engine**

## Connections

- User → CLI: enters request
- User → GUI workspace: uses workspace
- User → HTTP API: sends request (evidence: `lmms/api/server.py`)
- CLI → HTTP API: sends API calls (evidence: `lmms/cli/commands.py`)
- CLI → Remote engine: targets remote
- GUI workspace → Backend session: uses backend
- HTTP API → Backend session: routes chat (evidence: `lmms/api/server.py`)
- Backend session → Request orchestration: prepares requests (evidence: `lmms/backend/main.py`)
- Backend session → Backend services: uses services (evidence: `lmms/backend/logic/manager.py`)
- Request orchestration → Agent routing: routes agent work
- Request orchestration → Tool execution: dispatches tools
- Request orchestration → Vector retrieval: retrieves context
- Request orchestration → Session memory: uses session memory
- Request orchestration → Web research: requests research
- Backend session → Workspace and Git: supports workspace
- User → Extensions: adds extensions
- Backend session → Runtime selection: selects runtime
- Runtime selection → llama.cpp runtime: selects runtime (evidence: `lmms/engine/manager.py`)
- Runtime selection → PyTorch runtime: selects runtime (evidence: `lmms/engine/manager.py`)
- Runtime selection → AirEngine: loads AirEngine (evidence: `lmms/engine/manager.py`)
- Runtime selection → Model registry: manages models
- llama.cpp runtime → Backend session: returns generation
- PyTorch runtime → Backend session: returns generation
- AirEngine → Backend session: returns generation
