No description
  • TypeScript 88%
  • CSS 10.2%
  • JavaScript 0.8%
  • Dockerfile 0.5%
  • HTML 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Abhirup Bhattacharyya f97fba3faf
chore: containerize database in docker
- Postgres is now a docker service.
- The database initialization is now automated by docker compose.
- Update README.md

Signed-off-by: Abhirup Bhattacharyya <abhirup27022001@outlook.com>
2026-11-20 20:06:48 +05:30
apps chore: containerize database in docker 2026-11-20 20:06:48 +05:30
shared/types docs: overhaul README and add shared types package 2026-09-12 10:46:28 +05:30
.gitignore feat(api): configure environment-specific database setup 2026-09-06 11:17:40 +05:30
docker-compose.yaml chore: containerize database in docker 2026-11-20 20:06:48 +05:30
package.json pnpm project scaffolding, and database, SBERT & LLM models setup 2026-09-04 16:48:07 +05:30
pnpm-lock.yaml WIP: add ZIP file upload and parsing 2026-09-24 22:41:34 +05:30
pnpm-workspace.yaml docs: overhaul README and add shared types package 2026-09-12 10:46:28 +05:30
postgres.Dockerfile chore: containerize database in docker 2026-11-20 20:06:48 +05:30
README.md chore: containerize database in docker 2026-11-20 20:06:48 +05:30
screenshot.png chore: containerize database in docker 2026-11-20 20:06:48 +05:30

RAG-codebase

A RAG (retrieval-augmented generation) system for searching a codebase in natural language. A query is parsed for structural constraints (kind, parameters, return type) by a local decoder LLM, embedded semantically by a local code-embedding model, and matched against indexed code chunks with pgvector cosine similarity.

CodeBuddy UI

The project is a pnpm monorepo:

  • apps/api — Express + Drizzle ORM + PostgreSQL/pgvector backend. Runs the local LLMs via node-llama-cpp and parses source with tree-sitter.
  • apps/web — React + Vite chat UI for sending queries to the API.

Prerequisites

  • Atleast 3.5 GB available VRAM.
  • Node.js (LTS, 20+ recommended)
  • pnpm
  • Docker
  • A few GB of free disk space for the local GGUF models pulled in the setup step below

Getting it running locally

  1. Clone and install dependencies

    git clone https://github.com/QuantaDude/RAG-codebase.git
    cd RAG-codebase
    pnpm install
    
  2. Configure the API's environment Create apps/api/.env.development with your local Postgres connection details:

    DB_HOST=localhost
    DB_PORT=5432
    DB_USERNAME=<your_pg_user>
    DB_PASSWORD=<your_pg_password>
    DB_NAME=rag_app
    

    For a release-style run, create apps/api/.env instead — it's the file read whenever a script sets BUILD=release.

  3. Create the database and enable pgvector in docker container

    docker compose --env-file ./apps/api/.env.development up --build -d
    

    The docker container service uses the DB_NAME from the env file above to create the database and run CREATE EXTENSION IF NOT EXISTS vector;. It uses Postgres 18 and builds pgvector from source.

  4. Run the database migrations

    pnpm --filter ./apps/api dev:db:migrate
    

    pnpm dev:db:push is also available if you'd rather push the schema directly instead of running the migrations.

  5. Download the local models

    pnpm setup:models
    

    Downloads the decoder model Qwen3-4B-Instruct-2507, used for structural query parsing and the code-embedding model jina-code-embeddings-0.5b as GGUF files into apps/api/models/.

  6. Seed sample data

    pnpm dev:db:seed
    

    There's no upload/ingestion UI yet (see the 2nd iteration above), so this is currently the only way to get searchable data into the database — it inserts a handful of sample functions and embeds them.

  7. Start the API and frontend

    pnpm dev
    

    Starts the Express server on http://localhost:3000 and the vite dev server on http:\\localhost:5173.

  8. Open the app Visit http://localhost:5173 and upload a C++ or TypeScript project or you can also query the seeded sample functions from the chat box.

Things I would like to add

Iteration What it covers Status
1st Search through existing embedded/indexed code via the UI: query → query endpoint → structural meaning via a decoder transformer + semantic meaning via a code-embedding model → narrow down chunks → pgvector cosine similarity search → return the code body with the highest similarity score. Done
2nd Guest user + zip project upload, showing chunk-embedding progress to the user. In Progress
3rd User accounts. ⬜ Not started — schema and route stubs exist, no working register/login logic yet
4th Add the option to share a chat with guest viewers. ⬜ Not started
5th Git support, incremental embedding/indexing. ⬜ Not started
6th Infer if the query asked for an explaination, try to explain the piece of code using qwen. ⬜ Not started
7th (maybe) Change the monolithic pipeline to distributed queue workers — each worker does chunking + encoding, or querying. ⬜ Not started
8th (optional) Add the option to remove a GitHub repo's code from the database. ⬜ Not started