Stack services
Scholar Lens runs as a set of containers described in one file, scholarlens-stack.yml. The Dockerfiles and the nginx config are inline, so the file and the source folders are all you need. This page lists every service, what it is for, and how to start it.
Docker Compose v2.24 or newer is required.
Core services
These start with a plain up:
bash
docker compose -f scholarlens-stack.yml up -d --build --wait| Service | What it is | Port on the host |
|---|---|---|
postgres | Postgres 18 with pgvector 0.8.2. Holds everything: users, Library, chunks and vectors, chats, runs, jobs. | 127.0.0.1:5002 |
backend | The FastAPI app and the answer graph. Runs migrations on start. One process on purpose: run cancellation lives in memory. | 127.0.0.1:5001 |
worker | Background jobs: indexing, imports, section summaries. Same image as backend. | none |
frontend | The React app, built and served by nginx, which also forwards /api to the backend. | 127.0.0.1:5000 |
In development you usually start only postgres and run the API and UI on the host. See Contributing.
Optional services
Each one is a Compose profile. Start it with --profile <name>, then set the matching setting in .env (see Configuration).
| Profile | Service | What it adds | Setting (API on the host) |
|---|---|---|---|
reranker | llama.cpp with bge-reranker-v2-m3 on CPU | Cross-encoder reranking, coverage checks, High confidence | RERANKER_URL=http://127.0.0.1:5003/v1 |
reranker-gpu | The same on an NVIDIA GPU, about 10 times faster | As above | RERANKER_URL=http://127.0.0.1:5004/v1 |
searxng | Self-hosted metasearch | Web search without a key, and the fallback after Tavily | SEARXNG_URL=http://127.0.0.1:5008 |
browser | Playwright MCP server | Reads web pages that need JavaScript | MCP_BROWSER_URL=http://127.0.0.1:5005/mcp |
signin | Chromium on a virtual screen | Signing in to a gated source from a paused Research answer | SIGNIN_BROWSER_CDP_URL=http://127.0.0.1:5006 |
sandbox | Python kernels behind a small executor, under gVisor | Code cells and equation checks | SANDBOX_URL=http://172.31.250.10:5009, SANDBOX_TOKEN |
sandbox-bridge | A socat relay | Reaches the sandbox from Windows when it runs in WSL | SANDBOX_URL=http://127.0.0.1:5009 |
tts | Kokoro-82M on the CPU | Podcast voices | TTS_URL=http://127.0.0.1:5010 |
tts-gpu | Chatterbox Turbo on an NVIDIA GPU (run it or tts, not both) | Podcast voices, acted | TTS_URL=http://127.0.0.1:5011 |
video | Makes a podcast episode's video on request (headless Chromium + ffmpeg; 1920×1080, captions as a subtitle track) | Podcasts › Download › Make a video | VIDEO_EXPORT=true |
Inside the stack, use the service names instead, for example http://reranker:5003/v1 and http://sandbox:5009. Each service listens on the same port inside Docker as on the host. The voice services both answer as http://tts:5010.
Port map
Everything Scholar Lens uses sits in the 5000s. Each stack service listens on the same port inside Docker as on the host (loopback only); the variable in the root .env moves the host port.
| Port | What | Variable |
|---|---|---|
| 5000 | Web UI (stack) | FRONTEND_PORT |
| 5001 | API (stack) | BACKEND_PORT |
| 5002 | Postgres | POSTGRES_PORT |
| 5003 | Reranker (CPU) | RERANKER_PORT |
| 5004 | Reranker (GPU) | RERANKER_GPU_PORT |
| 5005 | Browser for script pages (MCP) | BROWSER_MCP_PORT |
| 5006 | Sign-in browser, DevTools | SIGNIN_CDP_PORT |
| 5007 | Sign-in browser, screen (VNC) | SIGNIN_VNC_PORT |
| 5008 | SearXNG | SEARXNG_PORT |
| 5009 | Code sandbox (172.31.250.10:5009; the Windows relay on the host) | SANDBOX_BRIDGE_PORT |
| 5010 | Voices, Kokoro | TTS_PORT |
| 5011 | Voices, Chatterbox | TTS_GPU_PORT |
| 5012 | Voice service started on the host for development (tts-dev, tts-chatterbox-linux) | |
| 5020, 5021 | Development API and UI dev server (uvicorn --port 5020, npm run dev) | |
| 5022, 5023 | A second development pair (backend-alt, frontend-alt) | |
| 5024, 5025 | The podcast development pair (backend-podcast, frontend-podcast) | |
| 5026 | Documentation site (npm run dev in site/) |
Inside its own container the sign-in browser's Chromium keeps DevTools on loopback port 5016, which socat publishes as 5006.
For example, a full development set-up runs:
bash
docker compose -f scholarlens-stack.yml up -d postgresbash
docker compose -f scholarlens-stack.yml --profile reranker --profile searxng --profile browser --profile signin up -d reranker searxng browser signinbash
docker compose -f scholarlens-stack.yml --profile sandbox up -d --build sandboxThe reranker model
The reranker is not an LM Studio model, because LM Studio has no rerank API. Download its file once into models/:
bash
mkdir -p models && curl -L -o models/bge-reranker-v2-m3-Q8_0.gguf https://huggingface.co/gpustack/bge-reranker-v2-m3-GGUF/resolve/main/bge-reranker-v2-m3-Q8_0.ggufIts SHA-256 is a43c7c9b11a4c1517e5bf95151960e1621d1b72f7a493364b01e386cf1aaa1d3.
The sandbox needs gVisor
The sandbox service runs with the runsc runtime from gVisor. It refuses to start under the normal runc runtime unless SANDBOX_ALLOW_RUNC=true, which is for development only. Install gVisor as described in Install on Linux. The sandbox has no route to the internet: it sits on an internal network that only the backend joins.
Ports and exposure
Every port binds to 127.0.0.1. Set BIND_ADDRESS=0.0.0.0 only on a trusted network, and serve over HTTPS with COOKIE_SECURE=true when others connect. The sign-in browser's DevTools and VNC ports have no authentication and must stay on loopback.
Data
| Volume | Holds |
|---|---|
pg_data | The database |
app_data | Uploaded files |
CAUTION
docker compose -f scholarlens-stack.yml down -v deletes both volumes: the whole Library, every chat and every vector. Make a backup first (see Backups and upgrades).
Everyday commands
Follow the logs:
bash
docker compose -f scholarlens-stack.yml logs -f backend workerStop everything:
bash
docker compose -f scholarlens-stack.yml downThe API's documentation, generated from the code, is at http://localhost:5001/docs.
New to Docker? See Docker basics for everyday commands, updating only part of the stack, and common errors.