# md-mushfiqur123/lychee architecture

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

- Interactive diagram: https://gitdiagram.com/md-mushfiqur123/lychee
- Repository: https://github.com/md-mushfiqur123/lychee

## Overview

Lychee is a local LLM runtime and orchestration service with CLI and HTTP entry points, a browser dashboard, model acquisition, inference, and compatibility APIs. A typical flow starts with a user command or API request, reaches the server, resolves or loads a model, and streams a result back. The graph also preserves documented compose, memory, routing, structured-output, and image-generation capabilities. Several subsystem links are based on README documentation because their implementation files were not sampled; those evidence limits are reflected in the edges.

Main entry points: [`server/routes.go`](https://github.com/md-mushfiqur123/lychee/blob/main/server/routes.go) (HTTP routes), [`server/sched.go`](https://github.com/md-mushfiqur123/lychee/blob/main/server/sched.go) (Model scheduler), [`api/client.go`](https://github.com/md-mushfiqur123/lychee/blob/main/api/client.go) (Go API client), [`server/internal/registry/server.go`](https://github.com/md-mushfiqur123/lychee/blob/main/server/internal/registry/server.go) (Model acquisition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI commands<br/>[cmd.go]"]
  node_client["Go API client<br/>[client.go]"]
  node_dashboard["Dashboard UI<br/>[c.$chatId.tsx]"]
  node_ui_api["UI API and streaming<br/>[api.ts]"]
end

subgraph group_service["Service API"]
  node_service_routes["HTTP routes<br/>[routes.go]"]
  node_openai_api["OpenAI-compatible API<br/>[routes_openai.go]"]
  node_anthropic_api["Anthropic API"]
end

subgraph group_models["Models and inference"]
  node_model_acquisition["Model acquisition<br/>[server.go]"]
  node_model_resolution["Model resolution<br/>[model_resolver.go]"]
  node_scheduler["Model scheduler<br/>[sched.go]"]
  node_llama_runtime["LLM runtime<br/>[server.go]"]
  node_mlx_runtime["MLX text runtime<br/>[pipeline.go]"]
  node_image_generation["Image generation<br/>[server.go]"]
  node_model_formats["Model conversion<br/>[convert.go]"]
end

subgraph group_orchestration["Orchestration features"]
  node_compose["Multi-model compose<br/>[handler_compose.go]"]
  node_memory[("Persistent memory<br/>[memory_store.go]")]
  node_router["Load-balancing router<br/>[handler_router.go]"]
  node_structured["Structured output"]
  node_tools["Agent and web tools<br/>[registry.go]"]
end

subgraph group_integrations["Client integrations"]
  node_sdk["Language SDKs<br/>[client.py]"]
end

node_user(("User"))
node_external_models["Hugging Face"]

node_user -->|"runs commands"| node_cli
node_cli -->|"uses client"| node_client
node_user -.->|"sends requests"| node_client
node_client -->|"calls REST API"| node_service_routes
node_user -->|"opens dashboard"| node_dashboard
node_dashboard -.->|"requests data"| node_ui_api
node_ui_api -.->|"calls service"| node_service_routes
node_service_routes -.->|"resolves models"| node_model_resolution
node_service_routes -->|"gets runner"| node_scheduler
node_scheduler -.->|"runs inference"| node_llama_runtime
node_scheduler -.->|"runs MLX inference"| node_mlx_runtime
node_service_routes -.->|"serves model operations"| node_model_acquisition
node_external_models -.->|"provides models"| node_model_acquisition
node_model_acquisition -.->|"downloads model files"| node_model_formats
node_service_routes -->|"routes compose"| node_compose
node_service_routes -->|"exposes conversations"| node_memory
node_service_routes -->|"routes management"| node_router
node_service_routes -->|"routes structured output"| node_structured
node_service_routes -.->|"supports tool use"| node_tools
node_openai_api -->|"dispatches handlers"| node_service_routes
node_anthropic_api -.->|"registers API routes"| node_service_routes
node_service_routes -.->|"supports image requests"| node_image_generation
node_sdk -.->|"calls service API"| node_service_routes

click node_cli "https://github.com/md-mushfiqur123/lychee/blob/main/cmd/cmd.go"
click node_client "https://github.com/md-mushfiqur123/lychee/blob/main/api/client.go"
click node_dashboard "https://github.com/md-mushfiqur123/lychee/blob/main/app/ui/app/src/routes/c.%24chatId.tsx"
click node_ui_api "https://github.com/md-mushfiqur123/lychee/blob/main/app/ui/app/src/api.ts"
click node_service_routes "https://github.com/md-mushfiqur123/lychee/blob/main/server/routes.go"
click node_openai_api "https://github.com/md-mushfiqur123/lychee/blob/main/server/routes_openai.go"
click node_anthropic_api "https://github.com/md-mushfiqur123/lychee/blob/main/server/routes_anthropic.go"
click node_model_acquisition "https://github.com/md-mushfiqur123/lychee/blob/main/server/internal/registry/server.go"
click node_model_resolution "https://github.com/md-mushfiqur123/lychee/blob/main/server/model_resolver.go"
click node_scheduler "https://github.com/md-mushfiqur123/lychee/blob/main/server/sched.go"
click node_llama_runtime "https://github.com/md-mushfiqur123/lychee/blob/main/llm/server.go"
click node_mlx_runtime "https://github.com/md-mushfiqur123/lychee/blob/main/x/mlxrunner/pipeline.go"
click node_image_generation "https://github.com/md-mushfiqur123/lychee/blob/main/x/imagegen/server.go"
click node_model_formats "https://github.com/md-mushfiqur123/lychee/blob/main/convert/convert.go"
click node_compose "https://github.com/md-mushfiqur123/lychee/blob/main/server/handler_compose.go"
click node_memory "https://github.com/md-mushfiqur123/lychee/blob/main/server/memory_store.go"
click node_router "https://github.com/md-mushfiqur123/lychee/blob/main/server/handler_router.go"
click node_structured "https://github.com/md-mushfiqur123/lychee/blob/main/server/handler_structured.go"
click node_tools "https://github.com/md-mushfiqur123/lychee/blob/main/x/tools/registry.go"
click node_sdk "https://github.com/md-mushfiqur123/lychee/blob/main/sdk/python/lychee/client.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_client,node_dashboard,node_ui_api,node_user toneBlue
class node_service_routes,node_openai_api,node_anthropic_api toneAmber
class node_model_acquisition,node_model_resolution,node_scheduler,node_llama_runtime,node_mlx_runtime,node_image_generation,node_model_formats toneMint
class node_compose,node_memory,node_router,node_structured,node_tools toneRose
class node_sdk,node_external_models toneIndigo
```

## Components

### User interfaces

- [CLI commands](https://github.com/md-mushfiqur123/lychee/blob/main/cmd/cmd.go): `cmd/cmd.go`
- [Go API client](https://github.com/md-mushfiqur123/lychee/blob/main/api/client.go): `api/client.go`
- [Dashboard UI](https://github.com/md-mushfiqur123/lychee/blob/main/app/ui/app/src/routes/c.%24chatId.tsx): `app/ui/app/src/routes/c.$chatId.tsx`
- [UI API and streaming](https://github.com/md-mushfiqur123/lychee/blob/main/app/ui/app/src/api.ts): `app/ui/app/src/api.ts`

### Service API

- [HTTP routes](https://github.com/md-mushfiqur123/lychee/blob/main/server/routes.go): `server/routes.go`
- [OpenAI-compatible API](https://github.com/md-mushfiqur123/lychee/blob/main/server/routes_openai.go): `server/routes_openai.go`
- [Anthropic API](https://github.com/md-mushfiqur123/lychee/blob/main/server/routes_anthropic.go): `server/routes_anthropic.go`

### Models and inference

- [Model acquisition](https://github.com/md-mushfiqur123/lychee/blob/main/server/internal/registry/server.go): `server/internal/registry/server.go`
- [Model resolution](https://github.com/md-mushfiqur123/lychee/blob/main/server/model_resolver.go): `server/model_resolver.go`
- [Model scheduler](https://github.com/md-mushfiqur123/lychee/blob/main/server/sched.go): `server/sched.go`
- [LLM runtime](https://github.com/md-mushfiqur123/lychee/blob/main/llm/server.go): `llm/server.go`
- [MLX text runtime](https://github.com/md-mushfiqur123/lychee/blob/main/x/mlxrunner/pipeline.go): `x/mlxrunner/pipeline.go`
- [Image generation](https://github.com/md-mushfiqur123/lychee/blob/main/x/imagegen/server.go): `x/imagegen/server.go`
- [Model conversion](https://github.com/md-mushfiqur123/lychee/blob/main/convert/convert.go): `convert/convert.go`

### Orchestration features

- [Multi-model compose](https://github.com/md-mushfiqur123/lychee/blob/main/server/handler_compose.go): `server/handler_compose.go`
- [Persistent memory](https://github.com/md-mushfiqur123/lychee/blob/main/server/memory_store.go): `server/memory_store.go`
- [Load-balancing router](https://github.com/md-mushfiqur123/lychee/blob/main/server/handler_router.go): `server/handler_router.go`
- [Structured output](https://github.com/md-mushfiqur123/lychee/blob/main/server/handler_structured.go): `server/handler_structured.go`
- [Agent and web tools](https://github.com/md-mushfiqur123/lychee/blob/main/x/tools/registry.go): `x/tools/registry.go`

### Client integrations

- [Language SDKs](https://github.com/md-mushfiqur123/lychee/blob/main/sdk/python/lychee/client.py): `sdk/python/lychee/client.py`

### Other components

- **User**
- **Hugging Face**

## Connections

- User → CLI commands: runs commands
- CLI commands → Go API client: uses client (evidence: `api/client.go`)
- User → Go API client: sends requests
- Go API client → HTTP routes: calls REST API (evidence: `api/client.go`)
- User → Dashboard UI: opens dashboard
- Dashboard UI → UI API and streaming: requests data
- UI API and streaming → HTTP routes: calls service
- HTTP routes → Model resolution: resolves models (evidence: `server/routes.go`)
- HTTP routes → Model scheduler: gets runner (evidence: `server/routes.go`)
- Model scheduler → LLM runtime: runs inference
- Model scheduler → MLX text runtime: runs MLX inference
- HTTP routes → Model acquisition: serves model operations
- Hugging Face → Model acquisition: provides models
- Model acquisition → Model conversion: downloads model files
- HTTP routes → Multi-model compose: routes compose (evidence: `server/routes.go`)
- HTTP routes → Persistent memory: exposes conversations (evidence: `server/routes.go`)
- HTTP routes → Load-balancing router: routes management (evidence: `server/routes.go`)
- HTTP routes → Structured output: routes structured output (evidence: `server/routes.go`)
- HTTP routes → Agent and web tools: supports tool use (evidence: `server/routes.go`)
- OpenAI-compatible API → HTTP routes: dispatches handlers (evidence: `server/routes_openai.go`)
- Anthropic API → HTTP routes: registers API routes (evidence: `server/routes_anthropic.go`)
- HTTP routes → Image generation: supports image requests
- Language SDKs → HTTP routes: calls service API
