The Problem Large, heterogeneous codebases make it hard for engineers and AI assistants to locate definitions, understand cross‑repo dependencies, and answer ad‑hoc questions reliably. Manual search and scattered documentation increase onboarding time and error rates.

What This Does sourcebot is a self‑hosted service that indexes any Git host, provides AI‑driven Q&A, full‑text code search, and IDE‑style navigation. The UI lives in packages/web, the indexing engine in packages/backend, and the query language compiler in packages/queryLanguage. Configuration is JSON‑based (configs/*.json) and the whole stack can be launched with Docker Compose.

How It Is Wired

  1. Entry pointpackages/backend/src/index.ts starts an Express server, loads packages/backend/src/utils.ts (a hub module used by 15 other packages), and registers routes for indexing and query handling.
  2. Indexingpackages/db/src/index.ts creates a PostgreSQL connection, then packages/db/tools/scriptRunner runs migration scripts. The backend calls packages/backend/src/bitbucket.ts (the largest file, 655 LOC) to fetch repo data.
  3. Search & Query – HTTP requests hit /api/searchpackages/web/src/proto/webserver (imports 46 other modules). Queries are parsed by packages/queryLanguage/src/index.ts, which builds a protobuf request sent to the web‑server proto.
  4. Chat / Ask – UI components in packages/web/src/app/(app)/@sidebar/components/defaultSidebar invoke /api/ask, which routes through packages/web/src/features/chat/types.ts (a “hub” module with 16 dependents) into the backend’s LLM provider defined in configs/auth.json.
  5. Circular dependencies – The import graph shows 28 cycles, notably between packages/backend/src/utils.ts and packages/web/src/proto/zoekt/webserver/v1/Q.ts. These cycles increase blast radius when changing shared types.

All external effects (DB writes, network calls to code hosts, LLM API calls) originate from the backend utils and the query‑language compiler; the web layer is thin and only forwards HTTP payloads.

How To Use It

# Clone the repo
git clone https://github.com/moses-y/sourcebot
cd sourcebot

# Install dependencies (yarn workspace)
yarn install

# Build containers
docker compose -f docker-compose.yml up -d

# Create a config (example)
cat > config.json <<'EOF'
{
  "$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
  "repos": [{ "url": "https://github.com/your-org/your-repo.git" }],
  "llmProvider": { "type": "openai", "apiKey": "<redacted>" }
}
EOF

# Start the service (backend + web)
yarn workspace @sourcebot/backend start
yarn workspace @sourcebot/web dev

The server listens on http://localhost:3000; the UI is reachable at the same address. Adjust docker-compose-dev.yml if you need custom ports or a separate DB instance.

Real‑World Use A team adds a new microservice repository to config.json. After restarting the containers, Sourcebot automatically indexes the code, making its types and routes searchable. A developer can ask, “How does the createUser handler validate email?” and receives a citation‑rich answer pulling directly from packages/backend/src/utils.ts and the OpenAPI spec in docs/api-reference/sourcebot-public.openapi.json.

Code Health & Issues

Static analysis (411 findings):

  • High / cognitive_load – deep nesting (e.g., packages/backend/src/utils.ts, max depth 8).
  • High / soundness – import cycles (e.g., packages/backend/src/utils.tspackages/web/src/proto/zoekt/webserver/v1/Q.ts).
  • Medium / cognitive_load – oversized file (packages/backend/src/bitbucket.ts, 655 lines).
  • Medium / cognitive_load – high branching density (packages/web/src/ee/features/chat/mcp/externalMcpError.ts).
  • Medium / clarity – hub modules (packages/web/src/features/chat/types.ts, packages/backend/src/utils.ts).

Code‑health audit (8 findings, already prioritized):

  • HIGH – Pin GitHub Actions to commit SHAs (.github/workflows/*).
  • HIGH – Remove committed .env.development and rotate credentials.
  • HIGH – Add a test step to the existing CI workflows.
  • MEDIUM – Enable Dependabot (.github/dependabot.yml).
  • MEDIUM – Pin dev‑container base image by digest.
  • MEDIUM – Add a dependency‑vulnerability scan gate in CI.
  • MEDIUM – Install a pre‑commit secret‑scan hook.
  • LOW – Set explicit timeout-minutes on workflow jobs.

The Bottom Line Sourcebot delivers a functional, Docker‑ready code‑search and AI‑Q&A platform with a clear separation between backend indexing and a React/Next UI. The codebase is large and contains several high‑impact cycles and deep nesting that will require refactoring for long‑term maintainability. Teams comfortable managing Docker, Yarn workspaces, and secret rotation can adopt it quickly, but should address the listed security and architectural risks before production use.