# samik930/github_codebase_ai architecture

> Architecture diagram of the GitHub repository samik930/github_codebase_ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samik930/github_codebase_ai
- Repository: https://github.com/samik930/github_codebase_ai

## Overview

Codebase Copilot lets users index a GitHub repository and then ask questions answered from its code. The main flow downloads useful repository files, filters/redacts sensitive content, chunks and indexes them, then retrieves hybrid search results and generates an answer. The UI also exposes repository status, statistics, source viewing, and theme selection. Sampled code supports the ingestion and query wiring shown; source-viewing details and some implementation internals were not sampled, so their connections are omitted.

Main entry points: [`client/src/App.jsx`](https://github.com/samik930/github_codebase_ai/blob/main/client/src/App.jsx) (App shell), [`server/src/controllers/controller.js`](https://github.com/samik930/github_codebase_ai/blob/main/server/src/controllers/controller.js) (Request controllers), [`server/src/rag/retrieve.js`](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/retrieve.js) (Hybrid retrieval), [`server/src/rag/ingest1.js`](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/ingest1.js) (Document ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App shell<br/>[App.jsx]"]
  node_ingest_ui["Ingest card<br/>[IngestCard.jsx]"]
  node_chat_ui["Chat interface<br/>[ChatInterface.jsx]"]
  node_header["Header and theme<br/>[Header.jsx]"]
  node_theme_picker["Theme picker<br/>[ThemePicker.jsx]"]
  node_repo_stats["Repository stats<br/>[RepoStats.jsx]"]
  node_source_viewer["Source viewer<br/>[SourceViewer.jsx]"]
end

subgraph group_api["API orchestration"]
  node_server["Express server<br/>[index.js]"]
  node_routes["API routes<br/>[routes.js]"]
  node_controller["Request controllers<br/>[controller.js]"]
end

subgraph group_ingest["Repository indexing"]
  node_github["GitHub downloader<br/>[downloadRepo.js]"]
  node_ingestion["Document ingestion<br/>[ingest1.js]"]
  node_guard["Sensitive-data guard<br/>[sensitiveGuard.js]"]
  node_qdrant[("Vector collection")]
  node_bm25["BM25 index<br/>[bm25.js]"]
  node_bm25_file[("BM25 index file<br/>[bm25-index.json]")]
end

subgraph group_query["Question answering"]
  node_retrieve["Hybrid retrieval<br/>[retrieve.js]"]
  node_rewriter["Query rewriting<br/>[queryRewriter.js]"]
  node_generate["Answer generation<br/>[generate.js]"]
end

node_user(("User"))
node_gemini{{"Google Gemini"}}
node_github_service{{"GitHub API"}}

node_user -->|"uses"| node_app
node_app -->|"renders"| node_ingest_ui
node_app -->|"renders when indexed"| node_chat_ui
node_app -->|"renders"| node_header
node_header -->|"selects theme"| node_theme_picker
node_app -->|"shows indexed stats"| node_repo_stats
node_app -->|"provides source view"| node_source_viewer
node_ingest_ui -->|"POST /api/ingest"| node_server
node_chat_ui -->|"POST /api/query"| node_server
node_server -->|"dispatches API"| node_routes
node_routes -->|"dispatches requests"| node_controller
node_controller -->|"loads repository files"| node_github
node_github -->|"fetches repository data"| node_github_service
node_controller -->|"ingests files"| node_ingestion
node_ingestion -->|"filters and redacts"| node_guard
node_ingestion -->|"embeds chunks"| node_gemini
node_ingestion -->|"upserts vectors"| node_qdrant
node_ingestion -->|"builds index"| node_bm25
node_bm25 -->|"writes index"| node_bm25_file
node_controller -->|"checks query intent"| node_guard
node_controller -->|"retrieves documents"| node_retrieve
node_retrieve -->|"rewrites query"| node_rewriter
node_rewriter -->|"generates search query"| node_gemini
node_retrieve -->|"searches vectors"| node_qdrant
node_retrieve -->|"runs sparse search"| node_bm25
node_retrieve -->|"loads index"| node_bm25_file
node_retrieve -->|"embeds query"| node_gemini
node_controller -->|"generates answer"| node_generate
node_generate -->|"generates response"| node_gemini

click node_app "https://github.com/samik930/github_codebase_ai/blob/main/client/src/App.jsx"
click node_ingest_ui "https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/IngestCard.jsx"
click node_chat_ui "https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/ChatInterface.jsx"
click node_header "https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/Header.jsx"
click node_theme_picker "https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/ThemePicker.jsx"
click node_repo_stats "https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/RepoStats.jsx"
click node_source_viewer "https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/SourceViewer.jsx"
click node_server "https://github.com/samik930/github_codebase_ai/blob/main/server/src/index.js"
click node_routes "https://github.com/samik930/github_codebase_ai/blob/main/server/src/routes/routes.js"
click node_controller "https://github.com/samik930/github_codebase_ai/blob/main/server/src/controllers/controller.js"
click node_github "https://github.com/samik930/github_codebase_ai/blob/main/server/src/github/downloadRepo.js"
click node_ingestion "https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/ingest1.js"
click node_guard "https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/sensitiveGuard.js"
click node_bm25 "https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/bm25.js"
click node_bm25_file "https://github.com/samik930/github_codebase_ai/blob/main/server/data/bm25-index.json"
click node_retrieve "https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/retrieve.js"
click node_rewriter "https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/queryRewriter.js"
click node_generate "https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/generate.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_ingest_ui,node_chat_ui,node_header,node_theme_picker,node_repo_stats,node_source_viewer,node_user toneBlue
class node_server,node_routes,node_controller toneAmber
class node_github,node_ingestion,node_guard,node_qdrant,node_bm25,node_bm25_file,node_github_service toneMint
class node_retrieve,node_rewriter,node_generate toneRose
class node_gemini toneIndigo
```

## Components

### Web client

- [App shell](https://github.com/samik930/github_codebase_ai/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Ingest card](https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/IngestCard.jsx): `client/src/components/IngestCard.jsx`
- [Chat interface](https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/ChatInterface.jsx): `client/src/components/ChatInterface.jsx`
- [Header and theme](https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/Header.jsx): `client/src/components/Header.jsx`
- [Theme picker](https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/ThemePicker.jsx): `client/src/components/ThemePicker.jsx`
- [Repository stats](https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/RepoStats.jsx): `client/src/components/RepoStats.jsx`
- [Source viewer](https://github.com/samik930/github_codebase_ai/blob/main/client/src/components/SourceViewer.jsx): `client/src/components/SourceViewer.jsx`

### API orchestration

- [Express server](https://github.com/samik930/github_codebase_ai/blob/main/server/src/index.js): `server/src/index.js`
- [API routes](https://github.com/samik930/github_codebase_ai/blob/main/server/src/routes/routes.js): `server/src/routes/routes.js`
- [Request controllers](https://github.com/samik930/github_codebase_ai/blob/main/server/src/controllers/controller.js): `server/src/controllers/controller.js`

### Repository indexing

- [GitHub downloader](https://github.com/samik930/github_codebase_ai/blob/main/server/src/github/downloadRepo.js): `server/src/github/downloadRepo.js`
- [Document ingestion](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/ingest1.js): `server/src/rag/ingest1.js`
- [Sensitive-data guard](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/sensitiveGuard.js): `server/src/rag/sensitiveGuard.js`
- **Vector collection**
- [BM25 index](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/bm25.js): `server/src/rag/bm25.js`
- [BM25 index file](https://github.com/samik930/github_codebase_ai/blob/main/server/data/bm25-index.json): `server/data/bm25-index.json`

### Question answering

- [Hybrid retrieval](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/retrieve.js): `server/src/rag/retrieve.js`
- [Query rewriting](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/queryRewriter.js): `server/src/rag/queryRewriter.js`
- [Answer generation](https://github.com/samik930/github_codebase_ai/blob/main/server/src/rag/generate.js): `server/src/rag/generate.js`

### Other components

- **User**
- **Google Gemini**
- **GitHub API**

## Connections

- User → App shell: uses
- App shell → Ingest card: renders
- App shell → Chat interface: renders when indexed
- App shell → Header and theme: renders
- Header and theme → Theme picker: selects theme
- App shell → Repository stats: shows indexed stats
- App shell → Source viewer: provides source view
- Ingest card → Express server: POST /api/ingest
- Chat interface → Express server: POST /api/query
- Express server → API routes: dispatches API
- API routes → Request controllers: dispatches requests
- Request controllers → GitHub downloader: loads repository files
- GitHub downloader → GitHub API: fetches repository data
- Request controllers → Document ingestion: ingests files
- Document ingestion → Sensitive-data guard: filters and redacts
- Document ingestion → Google Gemini: embeds chunks
- Document ingestion → Vector collection: upserts vectors
- Document ingestion → BM25 index: builds index
- BM25 index → BM25 index file: writes index
- Request controllers → Sensitive-data guard: checks query intent
- Request controllers → Hybrid retrieval: retrieves documents
- Hybrid retrieval → Query rewriting: rewrites query
- Query rewriting → Google Gemini: generates search query
- Hybrid retrieval → Vector collection: searches vectors
- Hybrid retrieval → BM25 index: runs sparse search
- Hybrid retrieval → BM25 index file: loads index
- Hybrid retrieval → Google Gemini: embeds query
- Request controllers → Answer generation: generates answer
- Answer generation → Google Gemini: generates response
