Skip to content

Latest commit

ย 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Codebase QA Assistant

An AI-powered codebase companion that lets you understand a GitHub repository through natural-language questions.

Python Streamlit LangChain FAISS Supabase Groq


๐Ÿš€ Live Demo

Streamlit App: Live App

GitHub: prachishr/codebase-qa-assistant

๐Ÿš€ Overview

Codebase QA Assistant turns a public GitHub repository into a searchable knowledge base and lets users ask questions about its implementation, documentation, architecture, and available Git information.

Instead of sending an entire repository to an LLM, the application ingests the repository, creates meaningful code/document chunks, generates embeddings, retrieves relevant context, and then uses an LLM to generate a grounded answer with source files.

The application also includes Supabase Authentication and PostgreSQL-backed private conversation history, so each authenticated user has their own chat history.


โœจ What It Does

  • ๐Ÿ” Authentication โ€” Email/password signup and login with Supabase Auth
  • ๐Ÿ™ GitHub Analysis โ€” Clone and process public repositories
  • ๐Ÿงฉ AST-aware Code Chunking โ€” Preserve meaningful functions, methods, and classes
  • ๐Ÿ“š Documentation Ingestion โ€” Process Markdown and text documentation
  • ๐ŸŒณ Git Information โ€” Extract available commit metadata
  • ๐Ÿค— Local Embeddings โ€” sentence-transformers/all-MiniLM-L6-v2
  • โšก FAISS Retrieval โ€” Fast local vector similarity search
  • ๐Ÿ”Ž Hybrid Retrieval Logic โ€” Project overview, keywords, exact code symbols, and semantic search
  • ๐Ÿค– RAG with Groq โ€” Generate repository-grounded answers
  • ๐Ÿ“„ Source References โ€” Show the files used for an answer
  • ๐Ÿ’ฌ Persistent Chats โ€” Save and reopen previous conversations
  • ๐Ÿ‘ค User-specific History โ€” Conversations are isolated by authenticated user ID
  • โ˜๏ธ Streamlit Deployment โ€” Designed for Streamlit Community Cloud

๐Ÿ—๏ธ Architecture

flowchart TD
    A[User] --> B[Supabase Auth]
    B --> C[Authenticated User ID]
    C --> D[Streamlit Application]

    D --> E[GitHub Repository URL]
    E --> F[Repository Ingestion]

    F --> G[Source Code]
    F --> H[Documentation]
    F --> I[Git Information]

    G --> J[Tree-sitter AST Chunking]
    H --> K[Text Splitting]
    I --> K

    J --> L[Repository Chunks]
    K --> L

    L --> M[Hugging Face Embeddings]
    M --> N[FAISS Vector Index]

    D --> O[User Question]
    O --> P[Retrieval Layer]
    N --> P
    P --> Q[Relevant Repository Context]
    Q --> R[Groq LLM]
    R --> S[Grounded Answer + Sources]

    D --> T[database.py]
    T --> U[PostgreSQL]
    U --> V[Conversations]
    U --> W[Messages]
Loading

End-to-end flow

GitHub URL
   โ†“
Repository Ingestion
   โ†“
Code / Docs / Git Information
   โ†“
AST-aware + Text Chunking
   โ†“
Hugging Face Embeddings
   โ†“
FAISS Vector Index
   โ†“
User Question
   โ†“
Retrieval
   โ†“
Relevant Repository Context
   โ†“
Groq LLM
   โ†“
Grounded Answer + Sources

Conversation persistence runs alongside the application:

Supabase Auth
   โ†“
User ID
   โ†“
database.py
   โ†“
PostgreSQL
   โ†“
Private Conversations + Messages

๐Ÿง  RAG Pipeline

The application follows a Retrieval-Augmented Generation (RAG) approach.

1. Ingestion

The repository is cloned locally using GitPython. Relevant source-code files, documentation, and available Git commit information are extracted.

2. Chunking

Code and documentation are processed differently.

Code: Tree-sitter parses supported languages and extracts meaningful AST structures such as functions, methods, classes, and related definitions.

Documentation: Markdown and text files are split using a recursive text splitter.

The root README.md receives higher source priority because it commonly contains project-level information.

3. Embeddings

Each chunk is converted into a vector using:

sentence-transformers/all-MiniLM-L6-v2

The model runs locally, so embedding generation does not require a Hugging Face API key.

4. Retrieval

For each question, the retrieval layer can use:

  • Project overview retrieval
  • Keyword matching
  • Exact code-symbol/function matching
  • FAISS semantic similarity search
  • Duplicate reduction
  • Source prioritization

5. Generation

The retrieved chunks are combined into a context and sent to the Groq LLM.

Current model:

openai/gpt-oss-20b

The model is instructed to answer using the supplied repository context and avoid inventing unsupported information.


๐Ÿ” Authentication & Private Chat History

Supabase is used for authentication, while PostgreSQL is used for persistent application data.

User
 โ†“
Supabase Auth
 โ†“
Unique User ID
 โ†“
Streamlit Session
 โ†“
database.py
 โ†“
PostgreSQL

Each conversation is associated with the authenticated user's ID.

The database contains two main tables:

conversations
โ”œโ”€โ”€ id
โ”œโ”€โ”€ user_id
โ”œโ”€โ”€ title
โ”œโ”€โ”€ repository_url
โ””โ”€โ”€ created_at

messages
โ”œโ”€โ”€ id
โ”œโ”€โ”€ conversation_id
โ”œโ”€โ”€ role
โ”œโ”€โ”€ content
โ”œโ”€โ”€ source_files
โ””โ”€โ”€ created_at

A conversation can contain multiple messages:

User
 โ””โ”€โ”€ Conversation
      โ”œโ”€โ”€ User Message
      โ”œโ”€โ”€ Assistant Message
      โ”œโ”€โ”€ User Message
      โ””โ”€โ”€ Assistant Message

Database queries filter by user_id, so one authenticated user cannot retrieve another user's conversation history through the application's database operations.

Supabase + PostgreSQL

Supabase is the backend platform hosting the project's PostgreSQL database.

The project uses two connections:

  • Supabase Python client โ†’ Authentication and user identity
  • psycopg2 โ†’ Direct PostgreSQL connection for conversations/messages

So:

Supabase Auth
     โ†“
   User ID
     โ†“
PostgreSQL
     โ†“
Chat History

๐Ÿ› ๏ธ Tech Stack

Technology Role
Python Core application
Streamlit Web UI and deployment
GitPython Repository cloning and Git operations
Tree-sitter AST-based code parsing
Tree-sitter Language Pack Multi-language parser support
LangChain Document/vector-store integration
Sentence Transformers Local embedding generation
Hugging Face Embedding model ecosystem
FAISS Vector similarity search
Groq LLM inference
Supabase Auth User authentication
PostgreSQL Persistent conversation storage
psycopg2 PostgreSQL connectivity
python-dotenv Local environment configuration

Core AI Components

Embedding model

sentence-transformers/all-MiniLM-L6-v2

LLM

openai/gpt-oss-20b

๐Ÿ“‚ Project Structure

Codebase-QA-Assistant/
โ”‚
โ”œโ”€โ”€ app.py                  # Streamlit UI, authentication and app flow
โ”œโ”€โ”€ ingestion.py            # Repository ingestion
โ”œโ”€โ”€ chunking.py             # AST-aware and text-based chunking
โ”œโ”€โ”€ vector_store.py         # Embeddings + FAISS index
โ”œโ”€โ”€ retrieval.py            # Repository retrieval logic
โ”œโ”€โ”€ RAG.py                  # Context building + LLM generation
โ”œโ”€โ”€ database.py             # PostgreSQL operations
โ”‚
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ README.md               # Project documentation
โ”œโ”€โ”€ .gitignore              # Ignored files and secrets
โ”‚
โ””โ”€โ”€ .env                    # Local secrets (not committed)

Generated locally during analysis

repo/
faiss_index/
repo_state.json

These generated resources are intentionally excluded from Git.


โš™๏ธ Local Setup

1. Clone

git clone https://github.com/prachishr/codebase-qa-assistant.git
cd codebase-qa-assistant

2. Create a virtual environment

python -m venv .venv

Windows:

.venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

Create .env:

GROQ_API_KEY=your_groq_api_key
SUPABASE_URL=your_supabase_project_url
SUPABASE_KEY=your_supabase_key
DB_PASSWORD=your_database_password

Never commit .env, API keys, or database passwords.

5. Run

streamlit run app.py

Open:

http://localhost:8501

๐Ÿ”‘ Supabase Configuration

For authentication, create a Supabase project and enable email/password authentication.

Configure the authentication Site URL / Redirect URLs for your local and deployed Streamlit application.

For local development:

http://localhost:8501

For production, use the deployed Streamlit application URL.

The application's Supabase credentials should be provided through environment variables locally and Streamlit Secrets when deployed.


โ˜๏ธ Deployment

The application is designed to run on Streamlit Community Cloud.

Typical deployment flow:

GitHub
  โ†“
Streamlit Community Cloud
  โ†“
Install requirements.txt
  โ†“
Configure Secrets
  โ†“
Run app.py

Example Streamlit secrets:

GROQ_API_KEY = "your_groq_api_key"
SUPABASE_URL = "your_supabase_project_url"
SUPABASE_KEY = "your_supabase_key"
DB_PASSWORD = "your_database_password"

๐Ÿ’ฌ Example Questions

After analyzing a repository, users can ask:

What is this project about?
Explain the project architecture.
How does the loadRules function work?
How does contextMessages work?
Which file handles authentication?
What are the installation instructions?
Which technologies are used in this repository?
Where is the database connection created?

โšก Why These Technologies?

Choice Why
RAG Grounds LLM answers in the actual repository
Tree-sitter / AST Preserves meaningful code structures during chunking
MiniLM embeddings Lightweight local semantic representation
FAISS Fast, local vector similarity search
Groq Fast LLM inference
PostgreSQL Reliable persistent relational storage
Supabase Auth Managed authentication and stable user identities
Streamlit Simple Python-based application and deployment

Why FAISS instead of ChromaDB?

ChromaDB was initially explored for vector storage, but the Windows environment encountered a cygrpc DLL loading issue caused by an Application Control policy.

FAISS provided a simpler local vector-search implementation without the problematic gRPC dependency, so the project was moved to FAISS.


๐Ÿ”’ Security

  • Authentication is handled by Supabase Auth.
  • Conversation queries use the authenticated user's ID.
  • API keys and database credentials are stored outside source code.
  • .env and Streamlit secrets are excluded from Git.
  • Generated repository/vector files are excluded from Git.
  • Database operations verify conversation ownership where required.

The application currently analyzes public GitHub repositories. Private repository access through GitHub OAuth/token integration is not yet implemented.


โš ๏ธ Current Limitations

  • Public GitHub repositories are currently supported.
  • Repository cloning uses depth=1 for faster ingestion and deployment reliability.
  • Full Git history is therefore not currently available.
  • Very large repositories may require additional processing time.
  • The repository and FAISS workspace currently use local application paths.
  • Concurrent multi-user repository analysis would benefit from per-user workspace isolation.

๐Ÿ”ฎ Future Improvements

  • GitHub OAuth and private repository support
  • Full Git history analysis
  • Per-user repository and FAISS workspace isolation
  • Hybrid keyword + vector retrieval with reranking
  • Repository dependency visualization
  • More programming language support
  • Streaming LLM responses
  • Background repository indexing
  • Persistent vector indexes
  • Improved code/source highlighting

๐Ÿ“Œ Project Highlights

This project demonstrates practical implementation of:

Generative AI โ€ข RAG โ€ข LLMs โ€ข Semantic Search โ€ข Embeddings โ€ข Vector Search โ€ข AST Parsing โ€ข Code Intelligence โ€ข GitHub Analysis โ€ข PostgreSQL โ€ข Authentication โ€ข Multi-user Data Isolation โ€ข Streamlit Deployment


๐Ÿ‘ฉโ€๐Ÿ’ป Author

Prachi Sharma

GitHub:
https://github.com/prachishr/codebase-qa-assistant


โญ Support

If you found this project useful, consider giving the repository a โญ on GitHub.

About

A repository-aware AI assistant that uses RAG to understand and answer questions about GitHub codebases.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages