~/localhost

Project

DevPilot AI

In developmentBackend · Code intelligence

Overview

Real search in DevPilot's local browser workspace over the indexed BrainTumorClassifier repository. Recording from the DevPilot repository.

Ask questions about a GitHub repository and get answers grounded in its actual source.

DevPilot indexes public GitHub repositories and lets you search them in natural language. Results come back as ranked source chunks with citations to the exact files and line ranges. The backend is a layered FastAPI service with a durable Postgres job queue, a separate indexing worker and pgvector semantic search. A browser workspace served by the API lets you sign in, import a public repository, index it and follow each citation to the indexed commit on GitHub.

Milestone 4 of 9: semantic search with citations, plus a browser workspace served by the API. LLM answers and hybrid retrieval are planned.

Problem

Generic chat assistants answer questions about a codebase from memory and rarely say where an answer came from. DevPilot grounds every result in the repository's real source and points to the lines it used.

Role

Sole engineer

Stack

API
Python 3.12FastAPIPydantic v2structlog
Data
PostgreSQL 16pgvector (HNSW)SQLAlchemy 2 (async)Alembic
ML
sentence-transformersjina-embeddings-v2-base-code
Security
Argon2idPyJWT (HS256)
Quality & ops
pytestmypy (strict)ruffDocker ComposeGitHub Actions

Architecture

Clean layering in one direction only. Providers sit behind ports, so models and services can be swapped by configuration.

  1. API routes

    Parse, authenticate and delegate. No business logic.

  2. Services

    All logic, no HTTP or SQL, so IndexingService runs unchanged inside the worker.

  3. Repositories

    The only layer that emits SQL. Every user table is owner-scoped.

  4. Providers

    Ports and adapters for embeddings, LLM and VCS. Tests use a deterministic fake embedder.

  5. Worker + queue

    A Postgres table claimed with FOR UPDATE SKIP LOCKED, with heartbeat leases and reclaim.

  6. Postgres + pgvector

    Chunks and embeddings in separate tables. HNSW index, cosine similarity.

Engineering

Engineering decisions

  • Postgres as the job queue

    Indexing takes minutes. SKIP LOCKED gives a durable, restartable queue without adding Redis.

  • Separate worker process

    An out-of-memory error while embedding a large repo must not take down the API.

  • HNSW over IVFFlat

    HNSW builds incrementally, which suits repositories that keep arriving. IVFFlat needs training data and retuning.

  • Embeddings split from chunks

    You can re-embed with a new model without touching chunk text, and the ANN index stays on a narrow table.

  • Discard clones after indexing

    Persisted working trees grow without bound and buy nothing.

Challenges & solutions

  • Cloning arbitrary repositories safely

    Only https://github.com/owner/repo URLs are accepted, validated with urllib.parse. git runs with shell=False, a scrubbed environment, https-only protocol and a timeout. Clones are shallow and blobless into a temp directory that is always removed.

  • Keeping the index clean and cheap

    Discovery filters skip dependency and build folders, secrets, lockfiles and binaries (null-byte sniff). Re-indexing is skipped when HEAD is unchanged, and only changed files are re-chunked.

  • Authentication that can't be used to enumerate accounts

    One generic 401 for an unknown email or a wrong password, with equal work in both paths. JWT decoding pins the algorithm.

Results & roadmap

Results & outcomes

No retrieval-quality metrics yet: the evaluation harness exists but hasn't been run, so none are shown.

  • Automated tests

    144

    Source: Counted in the public repository: 19 test files, 78 unit and 66 integration tests against real Postgres

  • Milestones complete

    4 / 9

    Source: Project README roadmap

  • Retrieval eval harness

    Built

    Source: 15 hand-labeled queries, recall@1/5/10 and MRR. Not yet run.

Roadmap

  1. M1–M2 · Service skeleton, authDone
  2. M3 · Durable job queue, worker, hardened cloningDone
  3. M4 · Chunking, code embeddings, pgvector semantic searchDone
  4. Browser workspace · Sign in, import and index a repo, ask, follow citations to GitHubDone
  5. M5 · Hybrid retrieval (vector + full-text, RRF)Planned
  6. M6 · Tree-sitter AST-aware chunkingPlanned
  7. M7 · Chat with LLM answers, SSE streaming, citationsPlanned
  8. M8 · React frontendPlanned
  9. M9 · Test hardening and docsPlanned

Links