How startrail-org/pixelrag works
1. Repo shape: a multi-package monorepo
- This repository is organized around several separately installable Python packages plus one Next.js frontend.
- The main Python packages are pixelrag_render, pixelrag_index, pixelrag_embed, pixelrag_serve, and the top-level pixelrag CLI wrapper in src/pixelrag.
- train/ is intentionally a separate Python project with its own environment and dependency pinning; it is not part of the runtime pipeline.
2. Core end-to-end pipeline
- The primary data flow is: document source → rendered screenshot tiles → chunks/shards → embeddings → FAISS index → search API.
- The README and directory layout make this explicit: render produces images, embed turns images into vectors, index assembles/searches the index, and serve exposes it over HTTP.
- This is the main architecture to draw: rendering and retrieval are separate stages with clean handoffs via files/artifacts on disk.
3. Rendering subsystem
- render/src/pixelrag_render is the screenshot engine behind pixelshot.
- It supports multiple backends: Chromium/CDP (backends/cdp.py, fast_cdp.py), PDF rendering (backends/pdf.py), and many strategy implementations under strategies/.
- The renderer is built for high-throughput tile generation, with special attention to Chrome attachment, page tiling, and performance benchmarking.
- render/chrome-build/ and the Chromium patch files indicate the project can ship or patch a custom headless browser build for Linux.
4. Index ingestion subsystem
- index/src/pixelrag_index orchestrates turning a source into an index.
- Sources are abstracted in sources/base.py with concrete adapters for local, pdf, web, and kiwix.
- This is the boundary where “what to index” is normalized into a common ingest pipeline, so the architecture supports local folders, PDFs, web content, and offline Kiwix archives.
5. Embedding subsystem
- embed/src/pixelrag_embed is responsible for converting rendered tiles into vector embeddings.
- The split between embed.py, embed_cpu.py, chunk.py, and index.py suggests separate concerns for chunking tiles, embedding execution, and index assembly.
- In the product story, this layer is where screenshot images become the semantic retrieval space, and it is the bridge from visual assets to searchable vectors.
6. Serving subsystem
- serve/src/pixelrag_serve provides the HTTP search layer used by the hosted API and local installs.
- api.py is the main request surface, while render_ondemand.py and the ZIM server modules show that serving can also trigger rendering or stream archived web content.
- The serving boundary is intentionally independent of training and browser rendering internals: it consumes built indexes and returns ranked documents/tiles over HTTP.
7. User-facing interfaces
- The root src/pixelrag/cli.py exposes the umbrella CLI (pixelrag chunk, embed, build-index, index, serve), while pixelshot is the rendering-focused entrypoint.
- web/ is a separate Next.js app for the public site and interactive demo; it calls the backend API from the browser/server-side app routes.
- plugin/ and skill/ add a Claude Code integration, where the pixelbrowse skill uses local pixelshot to give the agent visual access without an MCP backend.
8. Training is a distinct boundary
- train/ is a standalone project for LoRA fine-tuning the embedding model, with its own pyproject.toml, lockfile, and experiment scripts.
- It handles dataset preparation, filtering, hard-negative mining, evaluation, and model training/export.
- The runtime architecture depends on trained weights/adapters produced here, but not on training code at inference time.
9. Evaluation and reproduction
- eval/ contains benchmark runners, graders, retrieval helpers, and reproduction scripts for the paper’s experiments.
- This layer sits beside the product pipeline rather than inside it: it consumes rendered tiles, embeddings, and APIs to measure retrieval/QA quality.
- assets/, docs/reproducing_paper.md, and eval/REPRODUCE.md support reproducibility and paper-aligned comparisons.
10. Deployment and operations
- deploy/ and .github/workflows/ cover packaging, CI, release, and production rollout.
- The deploy artifacts include systemd units and an Nginx upstream config, which implies the API is run as a managed service behind a reverse proxy.
- history/ stores environment or rollout snapshots, suggesting operational tracking of service components like API, website, tile serving, and agent integration.
11. External services and hosted assets
- The README references a hosted search API at api.pixelrag.ai, a website at pixelrag.ai, and published datasets/adapters on Hugging Face.
- Those are not required for local architecture, but they matter because the repo supports both self-hosted indexing and a prebuilt public Wikipedia index.
- The public service likely uses the same serve package and a precomputed FAISS index stored under index/ artifacts.
12. How to diagram the system
- Draw four main runtime boxes: Render, Embed/Index, Serve/Search, and UI/Agent clients.
- Add a separate Training box feeding model adapters into Embed/Serve, and a separate Deployment/CI box controlling packaging and release.
- The key arrows are:
- documents/URLs/PDFs into Render,
- screenshots/tile shards into Embed,
- vectors into Index,
- index into Serve,
- Serve into Web/API clients,
- and local pixelshot directly into the Claude skill.
Main entry points: api.py Search API · render.py Render core · embed.py Embed runner · pipelines.py Index pipeline
Components 20
Render
Screenshot generation and browser/PDF capture pipeline.
- Render core · Main rendering orchestration and capture workflow.
render/src/pixelrag_render/render.py - CDP backend · Chromium/CDP-based rendering backend.
render/src/pixelrag_render/backends/cdp.py - PDF backend · PDF rendering backend for non-web sources.
render/src/pixelrag_render/backends/pdf.py - Tile strategies · High-throughput page tiling and capture strategies.
render/src/pixelrag_render/strategies/base.py - Chrome build · Custom headless browser build and patching artifacts.
render/chrome-build/pixelrag-chrome.patch
Embed & Index
Chunking, embedding, and FAISS index assembly.
- Source adapters · Normalization boundary for local, PDF, web, and Kiwix inputs.
index/src/pixelrag_index/sources/base.py - Index pipeline · Coordinates ingest, chunking, and index build/search flows.
index/src/pixelrag_index/pipelines.py - Chunking · Splits rendered tiles into retrieval-ready chunks.
embed/src/pixelrag_embed/chunk.py - Embed runner · Converts chunks or tiles into vector embeddings.
embed/src/pixelrag_embed/embed.py - CPU embed · CPU-specific embedding implementation.
embed/src/pixelrag_embed/embed_cpu.py - Index assembly · Builds and persists the searchable vector index.
embed/src/pixelrag_embed/index.py
Serve & Search
HTTP search API and on-demand rendering/archival serving.
- Search API · Main request surface for retrieval and ranked results.
serve/src/pixelrag_serve/api.py - On-demand render · Triggers rendering during serving when needed.
serve/src/pixelrag_serve/render_ondemand.py - ZIM server · Offline archive serving for ZIM content.
serve/src/pixelrag_serve/zim_server.py
Clients & UI
CLI, web app, and agent-facing entrypoints.
- pixelrag CLI · Top-level command wrapper for chunking, embedding, indexing, and serving.
src/pixelrag/cli.py - pixelshot · Rendering-focused entrypoint used for visual capture workflows.
src/pixelrag/cli.py - Web app · Public site and interactive search/demo interface.
web/app/page.tsx - Agent skill · Local agent integration for visual browsing with pixelshot.
plugin/skills/pixelbrowse/SKILL.md
Training
Standalone model fine-tuning and dataset preparation project.
- Training stack · Separate fine-tuning and dataset-preparation environment.
train/train.py
Deploy & CI
Packaging, release, and service rollout.
- Deploy & CI · Service units, deployment scripts, and CI/release workflows.
deploy/deploy.sh
Connections 21
- pixelrag CLI → Index pipeline: build/index · CLI drives the end-to-end ingest and indexing pipeline.
- pixelrag CLI → Search API: serve · CLI can launch the HTTP serving layer.
- pixelshot → Render core: capture · Rendering entrypoint uses the screenshot engine.
- Agent skill → pixelshot: uses local · Agent skill relies on local pixelshot for visual access.
- Render core → CDP backend: web capture · Primary browser-capture backend for rendering web content.
- Render core → PDF backend: pdf capture · Alternative backend for document-style rendering.
- Render core → Tile strategies: tiles · Strategies control page tiling and throughput behavior.
- CDP backend → Chrome build: browser · CDP backend depends on patched Chromium artifacts.
- Source adapters → Index pipeline: normalize · Source adapters feed normalized documents into the pipeline.
- Index pipeline → Chunking: shard · Pipeline breaks rendered outputs into chunks/shards.
- Chunking → Embed runner: tiles · Chunked tiles are passed to the embedding stage.
- Embed runner → CPU embed: cpu path · Embedding runner can execute through CPU-specific implementation.
- Embed runner → Index assembly: vectors · Embeddings are assembled into the searchable index.
- Index assembly → Search API: index · Search service consumes the built FAISS index artifacts.
- Search API → On-demand render: fallback render · Serve layer can trigger rendering when needed.
- Search API → ZIM server: archive access · Serve layer also exposes archived web content paths.
- Web app → Search API: queries · Frontend calls the backend search API.
- Training stack → Embed runner: adapters · Training produces weights/adapters used by embedding runtime.
- Training stack → Search API: model assets · Training outputs can influence served retrieval models.
- Deploy & CI → Search API: rollout · Deployment manages service packaging and release.
- Deploy & CI → Web app: publish · CI and deployment also cover the web frontend.