Skip to content

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
ServiceWhat it isPort on the host
postgresPostgres 18 with pgvector 0.8.2. Holds everything: users, Library, chunks and vectors, chats, runs, jobs.127.0.0.1:5002
backendThe FastAPI app and the answer graph. Runs migrations on start. One process on purpose: run cancellation lives in memory.127.0.0.1:5001
workerBackground jobs: indexing, imports, section summaries. Same image as backend.none
frontendThe 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).

ProfileServiceWhat it addsSetting (API on the host)
rerankerllama.cpp with bge-reranker-v2-m3 on CPUCross-encoder reranking, coverage checks, High confidenceRERANKER_URL=http://127.0.0.1:5003/v1
reranker-gpuThe same on an NVIDIA GPU, about 10 times fasterAs aboveRERANKER_URL=http://127.0.0.1:5004/v1
searxngSelf-hosted metasearchWeb search without a key, and the fallback after TavilySEARXNG_URL=http://127.0.0.1:5008
browserPlaywright MCP serverReads web pages that need JavaScriptMCP_BROWSER_URL=http://127.0.0.1:5005/mcp
signinChromium on a virtual screenSigning in to a gated source from a paused Research answerSIGNIN_BROWSER_CDP_URL=http://127.0.0.1:5006
sandboxPython kernels behind a small executor, under gVisorCode cells and equation checksSANDBOX_URL=http://172.31.250.10:5009, SANDBOX_TOKEN
sandbox-bridgeA socat relayReaches the sandbox from Windows when it runs in WSLSANDBOX_URL=http://127.0.0.1:5009
ttsKokoro-82M on the CPUPodcast voicesTTS_URL=http://127.0.0.1:5010
tts-gpuChatterbox Turbo on an NVIDIA GPU (run it or tts, not both)Podcast voices, actedTTS_URL=http://127.0.0.1:5011
videoMakes a podcast episode's video on request (headless Chromium + ffmpeg; 1920×1080, captions as a subtitle track)Podcasts › Download › Make a videoVIDEO_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.

PortWhatVariable
5000Web UI (stack)FRONTEND_PORT
5001API (stack)BACKEND_PORT
5002PostgresPOSTGRES_PORT
5003Reranker (CPU)RERANKER_PORT
5004Reranker (GPU)RERANKER_GPU_PORT
5005Browser for script pages (MCP)BROWSER_MCP_PORT
5006Sign-in browser, DevToolsSIGNIN_CDP_PORT
5007Sign-in browser, screen (VNC)SIGNIN_VNC_PORT
5008SearXNGSEARXNG_PORT
5009Code sandbox (172.31.250.10:5009; the Windows relay on the host)SANDBOX_BRIDGE_PORT
5010Voices, KokoroTTS_PORT
5011Voices, ChatterboxTTS_GPU_PORT
5012Voice service started on the host for development (tts-dev, tts-chatterbox-linux)
5020, 5021Development API and UI dev server (uvicorn --port 5020, npm run dev)
5022, 5023A second development pair (backend-alt, frontend-alt)
5024, 5025The podcast development pair (backend-podcast, frontend-podcast)
5026Documentation 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 postgres
bash
docker compose -f scholarlens-stack.yml --profile reranker --profile searxng --profile browser --profile signin up -d reranker searxng browser signin
bash
docker compose -f scholarlens-stack.yml --profile sandbox up -d --build sandbox

The 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.gguf

Its 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 ​

VolumeHolds
pg_dataThe database
app_dataUploaded 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 worker

Stop everything:

bash
docker compose -f scholarlens-stack.yml down

The 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.