- TypeScript 88%
- CSS 10.2%
- JavaScript 0.8%
- Dockerfile 0.5%
- HTML 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
- 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> |
||
| apps | ||
| shared/types | ||
| .gitignore | ||
| docker-compose.yaml | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| postgres.Dockerfile | ||
| README.md | ||
| screenshot.png | ||
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.
The project is a pnpm monorepo:
apps/api— Express + Drizzle ORM + PostgreSQL/pgvector backend. Runs the local LLMs vianode-llama-cppand parses source withtree-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
-
Clone and install dependencies
git clone https://github.com/QuantaDude/RAG-codebase.git cd RAG-codebase pnpm install -
Configure the API's environment Create
apps/api/.env.developmentwith your local Postgres connection details:DB_HOST=localhost DB_PORT=5432 DB_USERNAME=<your_pg_user> DB_PASSWORD=<your_pg_password> DB_NAME=rag_appFor a release-style run, create
apps/api/.envinstead — it's the file read whenever a script setsBUILD=release. -
Create the database and enable pgvector in docker container
docker compose --env-file ./apps/api/.env.development up --build -dThe docker container service uses the
DB_NAMEfrom the env file above to create the database and runCREATE EXTENSION IF NOT EXISTS vector;. It uses Postgres 18 and builds pgvector from source. -
Run the database migrations
pnpm --filter ./apps/api dev:db:migratepnpm dev:db:pushis also available if you'd rather push the schema directly instead of running the migrations. -
Download the local models
pnpm setup:modelsDownloads the decoder model
Qwen3-4B-Instruct-2507, used for structural query parsing and the code-embedding modeljina-code-embeddings-0.5bas GGUF files intoapps/api/models/. -
Seed sample data
pnpm dev:db:seedThere'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.
-
Start the API and frontend
pnpm devStarts the Express server on
http://localhost:3000and the vite dev server onhttp:\\localhost:5173. -
Open the app Visit
http://localhost:5173and 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 |
