# carloslfu/slotstream architecture

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

- Interactive diagram: https://gitdiagram.com/carloslfu/slotstream
- Repository: https://github.com/carloslfu/slotstream

## Overview

Slotstream is a native Swift local-inference engine for running a large model on memory-constrained Apple Silicon Macs. The main workflow is to choose a deployment and memory plan, download and verify model weights, then generate responses through the CLI or compatible HTTP APIs. The README also describes vision input, coding-tool integrations, and an in-process Sevra Mac app. Edges rely on the README or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`Sources/Slotstream/Engine.swift`](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/Engine.swift) (Inference engine), [`Sources/slotstream-cli/main.swift`](https://github.com/carloslfu/slotstream/blob/main/Sources/slotstream-cli/main.swift) (CLI), [`Sources/Slotstream/ModelPackRegistry.swift`](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/ModelPackRegistry.swift) (Pack registry), [`Sources/Slotstream/WeightStore.swift`](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/WeightStore.swift) (Weight store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[main.swift]"]
  node_http_server["HTTP server<br/>[Server.swift]"]
  node_mac_app["Sevra Mac app<br/>[Inference.swift]"]
end

subgraph group_serving["Inference runtime"]
  node_engine["Inference engine<br/>[Engine.swift]"]
  node_tool_parser["Tool-call parser"]
  node_vision["Vision input<br/>[VisionPrompt.swift]"]
end

subgraph group_deployment["Model deployment"]
  node_pack_registry["Pack registry"]
  node_model_weights["Pinned model<br/>[PinnedModel.swift]"]
  node_weight_store["Weight store<br/>[WeightStore.swift]"]
end

subgraph group_memory["Memory and reuse"]
  node_machine["Hardware detection<br/>[Machine.swift]"]
  node_memory_profile["Memory profile"]
  node_prefix_cache[("Prefix cache<br/>[PrefixCache.swift]")]
  node_expert_store[("Expert store<br/>[ExpertStore.swift]")]
end

node_user(("User"))
node_api_client(("API client"))
node_weight_host["Model host"]

node_user -->|"runs commands"| node_cli
node_user -->|"sends requests"| node_http_server
node_api_client -->|"uses compatible API"| node_http_server
node_cli -->|"pulls weights"| node_weight_store
node_weight_store -->|"checks pinned files"| node_model_weights
node_weight_store -->|"downloads from"| node_weight_host
node_cli -->|"selects deployment"| node_pack_registry
node_pack_registry -->|"defines deployment"| node_model_weights
node_cli -->|"starts inference"| node_engine
node_http_server -->|"generates responses"| node_engine
node_engine -->|"uses resource contract"| node_memory_profile
node_pack_registry -->|"selects resource profile"| node_memory_profile
node_machine -.->|"informs planning"| node_cli
node_engine -->|"uses prefix reuse"| node_prefix_cache
node_engine -.->|"uses expert storage"| node_expert_store
node_engine -->|"supports image input"| node_vision
node_engine -.->|"parses tool calls"| node_tool_parser
node_mac_app -->|"runs in process"| node_engine

click node_cli "https://github.com/carloslfu/slotstream/blob/main/Sources/slotstream-cli/main.swift"
click node_http_server "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/Server.swift"
click node_mac_app "https://github.com/carloslfu/slotstream/blob/main/apps/macos/Runtime/Inference.swift"
click node_engine "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/Engine.swift"
click node_tool_parser "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/ToolCallSplitter.swift"
click node_vision "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/VisionPrompt.swift"
click node_pack_registry "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/ModelPackRegistry.swift"
click node_model_weights "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/PinnedModel.swift"
click node_weight_store "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/WeightStore.swift"
click node_machine "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/Machine.swift"
click node_memory_profile "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/PackMemoryProfile.swift"
click node_prefix_cache "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/PrefixCache.swift"
click node_expert_store "https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/ExpertStore.swift"

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_http_server,node_mac_app,node_user,node_api_client toneBlue
class node_engine,node_tool_parser,node_vision toneAmber
class node_pack_registry,node_model_weights,node_weight_store toneMint
class node_machine,node_memory_profile,node_prefix_cache,node_expert_store toneRose
class node_weight_host toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/carloslfu/slotstream/blob/main/Sources/slotstream-cli/main.swift): `Sources/slotstream-cli/main.swift`
- [HTTP server](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/Server.swift): `Sources/Slotstream/Server.swift`
- [Sevra Mac app](https://github.com/carloslfu/slotstream/blob/main/apps/macos/Runtime/Inference.swift): `apps/macos/Runtime/Inference.swift`

### Inference runtime

- [Inference engine](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/Engine.swift): `Sources/Slotstream/Engine.swift`
- [Tool-call parser](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/ToolCallSplitter.swift): `Sources/Slotstream/ToolCallSplitter.swift`
- [Vision input](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/VisionPrompt.swift): `Sources/Slotstream/VisionPrompt.swift`

### Model deployment

- [Pack registry](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/ModelPackRegistry.swift): `Sources/Slotstream/ModelPackRegistry.swift`
- [Pinned model](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/PinnedModel.swift): `Sources/Slotstream/PinnedModel.swift`
- [Weight store](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/WeightStore.swift): `Sources/Slotstream/WeightStore.swift`

### Memory and reuse

- [Hardware detection](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/Machine.swift): `Sources/Slotstream/Machine.swift`
- [Memory profile](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/PackMemoryProfile.swift): `Sources/Slotstream/PackMemoryProfile.swift`
- [Prefix cache](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/PrefixCache.swift): `Sources/Slotstream/PrefixCache.swift`
- [Expert store](https://github.com/carloslfu/slotstream/blob/main/Sources/Slotstream/ExpertStore.swift): `Sources/Slotstream/ExpertStore.swift`

### Other components

- **User**
- **API client**
- **Model host**

## Connections

- User → CLI: runs commands (evidence: `README.md`)
- User → HTTP server: sends requests (evidence: `README.md`)
- API client → HTTP server: uses compatible API (evidence: `README.md`)
- CLI → Weight store: pulls weights (evidence: `Sources/slotstream-cli/main.swift`)
- Weight store → Pinned model: checks pinned files (evidence: `Sources/Slotstream/WeightStore.swift`)
- Weight store → Model host: downloads from (evidence: `README.md`)
- CLI → Pack registry: selects deployment (evidence: `Sources/slotstream-cli/main.swift`)
- Pack registry → Pinned model: defines deployment (evidence: `Sources/Slotstream/ModelPackRegistry.swift`)
- CLI → Inference engine: starts inference (evidence: `Sources/slotstream-cli/main.swift`)
- HTTP server → Inference engine: generates responses (evidence: `Sources/Slotstream/Server.swift`)
- Inference engine → Memory profile: uses resource contract (evidence: `Sources/Slotstream/Engine.swift`)
- Pack registry → Memory profile: selects resource profile (evidence: `Sources/Slotstream/ModelPackRegistry.swift`)
- Hardware detection → CLI: informs planning (evidence: `Sources/slotstream-cli/main.swift`)
- Inference engine → Prefix cache: uses prefix reuse (evidence: `Sources/Slotstream/Engine.swift`)
- Inference engine → Expert store: uses expert storage (evidence: `Sources/Slotstream/Engine.swift`)
- Inference engine → Vision input: supports image input (evidence: `README.md`)
- Inference engine → Tool-call parser: parses tool calls (evidence: `Sources/Slotstream/Engine.swift`)
- Sevra Mac app → Inference engine: runs in process (evidence: `README.md`)
