How spoonnotfound/fake-ollama works
Project type and purpose
• From the file tree and README, Fake-Ollama is a lightweight, single‐binary HTTP server written in Go that fully simulates the Ollama API (and OpenAI‐compatible endpoints) for fun or testing. It can run in Docker or as a standalone Go executable.
File structure
• Top level:
• .github/workflows/go.yml – CI build/test pipeline for Go.
• Dockerfile – containerizes the Go server.
• main.go – entry point.
• go.mod / go.sum – dependency management.
• No separate “frontend” or “backend” directories: this is a monolithic service.
• No database or external persistent store; it simulates models in‐memory and streams responses.
README for additional insights
• The server listens on 0.0.0.0:11434 by default, configurable via OLLAMA_HOST.
• Supports streaming output, multiple “DeepSeek‐R1” model simulations, and both Ollama and OpenAI API endpoints.
• Deployable via Docker or Go build.
a. Main components
• External Clients
• Ollama CLI or SDK
• OpenAI‐compatible clients
• Network Layer
• HTTP/TCP
• Fake‐Ollama Server (monolith)
1) HTTP Listener & Router
2) Request Handlers
– Ollama‐API Handler
– OpenAI‐API Handler
3) Simulation Engine
– DeepSeek‐R1 Model Simulator
– Stream Manager
4) Configuration Module (env var reader)
5) Logging/Telemetry (stdout or container logs)
• Container Runtime (Docker) or Host OS
• (Optional) Reverse Proxy or Load Balancer in front, if deployed in production
b. Relationships and data flow
1) Client → HTTP Listener (port 11434)
2) Router directs to the correct handler (Ollama vs. OpenAI path)
3) Handler invokes Simulation Engine
4) Simulation Engine streams tokens back via Stream Manager
5) HTTP response flows back to Client
6) Configuration Module injects host/port settings at startup
7) Logs emitted to stdout / Docker logs
c. Architectural patterns / design principles
• Single‐process monolith for simplicity
• Handler‐based HTTP routing patterns (Go’s net/http mux or similar)
• Pluggable model simulation interfaces (so you could add other “models”)
• Streaming I/O for low‐latency responses
d. Key technologies / libraries
• Go stdlib net/http (server, mux, streaming)
• Docker for containerization
• GitHub Actions for CI (.github/workflows/go.yml)
• Environment‐based configuration (OLLAMA_HOST)
Detailed steps
3) Enclose a big boundary named “Fake‐Ollama Container / Host” with:
• HTTP Listener & Router
• Ollama API Handler
• OpenAI API Handler
• DeepSeek‐R1 Simulator
• Stream Manager
• Config & Logging module
5) Off to the side, note the Docker daemon as the runtime and GitHub Actions as CI.