Project
DevPilot AI
Overview
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.
API routes
Parse, authenticate and delegate. No business logic.
Services
All logic, no HTTP or SQL, so IndexingService runs unchanged inside the worker.
Repositories
The only layer that emits SQL. Every user table is owner-scoped.
Providers
Ports and adapters for embeddings, LLM and VCS. Tests use a deterministic fake embedder.
Worker + queue
A Postgres table claimed with FOR UPDATE SKIP LOCKED, with heartbeat leases and reclaim.
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
- M1–M2 · Service skeleton, authDone
- M3 · Durable job queue, worker, hardened cloningDone
- M4 · Chunking, code embeddings, pgvector semantic searchDone
- Browser workspace · Sign in, import and index a repo, ask, follow citations to GitHubDone
- M5 · Hybrid retrieval (vector + full-text, RRF)Planned
- M6 · Tree-sitter AST-aware chunkingPlanned
- M7 · Chat with LLM answers, SSE streaming, citationsPlanned
- M8 · React frontendPlanned
- M9 · Test hardening and docsPlanned