# System map — ollama/ollama

> Canonical page: https://codevetter.com/unpack/ollama/system-map

# System map — ollama/ollama

Scanned commit 6383a0fa9cbf97494b847226e189f6e36b401a08 (2026-09-18). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Single Go module (github.com/ollama/ollama) whose main binary is both the CLI client and the server. `ollama serve` starts a Gin HTTP server that owns a model Scheduler; inference is delegated to subprocesses (llama-server for GGUF, `ollama runner` for MLX/safetensors) spoken to over loopback HTTP. Model artifacts live as sha256 blobs + JSON manifests under OLLAMA_MODELS. Native code (vendored llama.cpp under llama/, MLX under mlx/) is built by CMake; the desktop app adds a webview shell and a React/Vite UI. Everything is configured through OLLAMA_* environment variables centralized in envconfig.
- Process entrypoint is main.go which calls cmd.NewCLI().ExecuteContext; all user-facing commands are cobra subcommands registered in NewCLI in cmd/cmd.go — [main.go](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/main.go) [cmd/cmd.go#L2385-L2600](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/cmd/cmd.go#L2385-L2600)
- The HTTP server is a Gin engine built by Server.GenerateRoutes, registering ~30 routes across /api/*, OpenAI-compatible /v1/*, and Anthropic /v1/messages — [server/routes.go#L1852-L1949](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/server/routes.go#L1852-L1949)
- Inference scheduling is a channel-based Scheduler with pendingReqCh/finishedReqCh/expiredCh/unloadedCh, a loaded map of runnerRef keyed by model path, and a single in-flight load (activeLoading) — [server/sched.go#L61-L106](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/server/sched.go#L61-L106)
- GGUF inference runs in a separate llama-server subprocess spawned via exec.Command and driven over loopback HTTP through the llm.LlamaServer interface (Completion, Chat, Embedding, Tokenize, WaitUntilRunning, Close) — [llm/llama_server.go#L120-L160](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/llm/llama_server.go#L120-L160) [llm/llama_server.go#L424](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/llm/llama_server.go#L424) [llm/server.go#L58-L77](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/llm/server.go#L58-L77)
- Safetensors/MLX models take a different runner path: sched.load detects m.IsMLX() (Config.ModelFormat == "safetensors") and creates an mlxrunner.Client which re-execs the same binary as `ollama runner --model X --port N` — [server/sched.go#L530-L594](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/server/sched.go#L530-L594) [server/images.go#L93-L95](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/server/images.go#L93-L95) [mlxrunner/client.go#L349](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/mlxrunner/client.go#L349) [cmd/cmd.go#L2569-L2576](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/cmd/cmd.go#L2569-L2576)
- Model storage is content-addressed: manifest.Path() -> OLLAMA_MODELS/manifests/<name>, BlobsPath() -> OLLAMA_MODELS/blobs/sha256-<hex>; manifests map model names to typed layers — [manifest/paths.go#L29-L72](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/manifest/paths.go#L29-L72) [server/model.go#L27-L97](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/server/model.go#L27-L97)
- Configuration is centralized in envconfig as OLLAMA_* variables (HOST, MODELS, KEEP_ALIVE, NUM_PARALLEL, MAX_LOADED_MODELS, MAX_QUEUE, ORIGINS, FLASH_ATTENTION, KV_CACHE_TYPE, NO_CLOUD, REMOTES, etc.) exposed via AsMap() — [envconfig/config.go#L20-L341](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/envconfig/config.go#L20-L341)
- The desktop app is a separate main package gated by `//go:build windows || darwin` in app/cmd/app/app.go, bundling a webview, sqlite-backed store (app/store/schema.sql), updater, and a React 19 + Vite + Tailwind UI under app/ui/app — [app/cmd/app/app.go#L1-L34](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/app/cmd/app/app.go#L1-L34) [app/store/schema.sql](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/app/store/schema.sql) [app/ui/app/package.json](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/app/ui/app/package.json)
- Full build is CMake-driven (cmake -B build .; cmake --build build) producing the Go binary plus native payload under build/lib/ollama; go build ./go run . serve works for Go-only iteration against an existing native payload — [AGENTS.md](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/AGENTS.md) [docs/development.md](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/docs/development.md) [CMakeLists.txt](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/CMakeLists.txt)
- Native engines are vendored/pinned: llama.cpp version in LLAMA_CPP_VERSION with llama/server sources, MLX pinned via MLX_VERSION and MLX_C_VERSION under mlx/, GPU backends selected via -DOLLAMA_LLAMA_BACKENDS=cuda_v12;cuda_v13;rocm_v7_1;rocm_v7_2;vulkan;cuda_jetpack5;cuda_jetpack6 — [docs/development.md](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/docs/development.md) [.github/workflows/test.yaml#L40-L49](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/.github/workflows/test.yaml#L40-L49) [LLAMA_CPP_VERSION](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/LLAMA_CPP_VERSION) [MLX_VERSION](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/MLX_VERSION)
- GPU/device discovery is performed by spawning helper binaries: `ollama gpu-discover` (hidden cobra cmd -> discover.RunNativeProbeCommand) and llama-server --list-devices probes in discover/llama_server.go — [cmd/cmd.go#L2581-L2590](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/cmd/cmd.go#L2581-L2590) [discover/native_probe.go#L86](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/discover/native_probe.go#L86) [discover/llama_server.go#L143](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/discover/llama_server.go#L143) [discover/runner.go#L36-L80](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/discover/runner.go#L36-L80)
- The CLI talks to the server through api.Client (api/client.go) whose methods map 1:1 to the REST API and which reads OLLAMA_HOST via ClientFromEnvironment — [api/client.go#L1-L79](https://github.com/ollama/ollama/blob/6383a0fa9cbf97494b847226e189f6e36b401a08/api/client.go#L1-L79)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
