Skip to content

iamdainwi/codemind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeMind β€” AI-Powered Code Knowledge Base

Upload your codebase, ask questions in plain English, and get cited answers.
Built with Endee vector database at its core.

CodeMind Dashboard CodeMind Agentic Q&A


✨ Features

# Feature Description Endee Usage
1 Ingest Codebase Upload ZIP or individual code files. System chunks, embeds, and indexes everything. index.upsert() β€” store code chunk vectors with metadata
2 RAG Chat Ask questions about your code in plain English, get cited answers. index.query() β€” retrieve relevant chunks for context
3 Semantic Search Describe what you're looking for, find relevant files by meaning. index.query() β€” similarity search across all chunks
4 Recommendations Select a file, see similar files from the codebase. index.query() β€” mean-vector similarity + filtering
5 Agentic Q&A Complex questions: agent decomposes β†’ multi-search β†’ synthesize. index.query() Γ— N β€” multiple searches per sub-question

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        FRONTEND                                 β”‚
β”‚          Next.js 15 (App Router) + Tailwind + shadcn/ui         β”‚
β”‚                                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚     Public Routes         β”‚  β”‚     Protected Routes       β”‚  β”‚
β”‚  β”‚  / (Landing Page)         β”‚  β”‚  /dashboard                β”‚  β”‚
β”‚  β”‚  /login (Auth Forms)      β”‚  β”‚  Requires valid JWT token  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                β”‚ AuthContext (State & Token)  β”‚                 β”‚
β”‚                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Upload Panel β”‚  β”‚   Tab Bar    β”‚  β”‚   File Card          β”‚   β”‚
β”‚  β”‚ β€’ Drag & Dropβ”‚  β”‚ Ask|Search|  β”‚  β”‚ β€’ Recommendations    β”‚   β”‚
β”‚  β”‚ β€’ File List  β”‚  β”‚ Agent        β”‚  β”‚ β€’ Similar files      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚         β”‚                 β”‚                      β”‚              β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
β”‚                   β”‚  Next.js API Routes (proxy w/ Auth)         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚ HTTP / SSE (Bearer Token)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   β”‚          BACKEND                            β”‚
β”‚                   β”‚     FastAPI (Python)                        β”‚
β”‚                   β”‚                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ main.py β€” Routes                                          β”‚  β”‚
β”‚  β”‚  POST /auth/register POST /auth/login  GET /auth/me       β”‚  β”‚
β”‚  β”‚  ──────────────────────────────────────────────────────── β”‚  β”‚
β”‚  β”‚  POST /ingest  POST /ask  POST /agent                     β”‚  β”‚
β”‚  β”‚  GET  /search  GET  /recommend  GET  /files               β”‚  β”‚
β”‚  β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜  β”‚
β”‚     β”‚                β”‚                β”‚                  β”‚      β”‚
β”‚  β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”  β”‚
β”‚  β”‚ingestionβ”‚  β”‚   rag.py    β”‚  β”‚  agent.py  β”‚      β”‚ auth.py β”‚  β”‚
│  │  .py    │  │ Embed→Search│  │ Decompose→ │      │ JWT Gen │  │
│  │ Chunk→  │  │  →Prompt→   │  │ MultiSearch│      │ Bcrypt  │  │
│  │ Embed→  │  │  Ollama     │  │ →Synthesize│      │ Verify  │  │
β”‚  β”‚ Store   β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜  β”‚
β”‚  β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β”‚               β”‚                   β”‚      β”‚
β”‚     β”‚                β”‚               β”‚      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”‚
β”‚  β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”   β”‚     MongoDB     β”‚ β”‚
β”‚  β”‚   endee_client.py (SDK Wrapper)      β”‚   β”‚ β€’ User profiles β”‚ β”‚
β”‚  β”‚   (Filters data by user_id)          β”‚   β”‚ β€’ Hashed PWs    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                      β”‚                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚ HTTP
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚   Endee Vector DB β”‚      β”‚  Ollama (local)  β”‚
             β”‚   localhost:8080  β”‚      β”‚  localhost:11434 β”‚
             β”‚   384-dim cosine  β”‚      β”‚  codellama/llama3β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Layer Technology Purpose
Vector DB Endee (Docker) Store & search code embeddings
Embeddings all-MiniLM-L6-v2 (384-dim) Convert code to vectors
LLM Ollama (codellama / llama3) Generate answers from context
Backend FastAPI (Python 3.11+) API server with SSE streaming
Frontend Next.js 15 + Tailwind + shadcn/ui Dark-themed developer UI

πŸš€ Setup

Prerequisites

  • Docker β€” for Endee vector DB
  • Python 3.11+ β€” for backend
  • Node.js 18+ β€” for frontend
  • Ollama β€” for local LLM

Environment Variables (.env)

Before starting, create a .env file in the backend/ directory:

# MongoDB & Auth
MONGO_URL=mongodb://localhost:27017
MONGO_DB=codemind
JWT_SECRET=your-super-secret-key-change-me
JWT_ALGORITHM=HS256
JWT_EXPIRY_HOURS=72

# Endee Vector DB
ENDEE_HOST=http://localhost:8080
ENDEE_AUTH_TOKEN=
ENDEE_INDEX_NAME=codemind
ENDEE_DIM=384

# LLM & Embeddings
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=codellama
EMBEDDING_MODEL=all-MiniLM-L6-v2

1. Start Endee & MongoDB

# Start Endee Server
docker run -p 8080:8080 -v endee-data:/data endeeio/endee-server:latest

# Start MongoDB (if not installed locally)
docker run -p 27017:27017 -d mongo

2. Start Ollama

ollama pull codellama    # or: ollama pull llama3
ollama serve             # if not already running

3. Backend

cd backend
python -m venv .venv

# On Mac/Linux:
source .venv/bin/activate
# On Windows:
# .\venv\Scripts\activate

pip install -r requirements.txt

# Verify Endee connection
python test_endee.py

# Start API server
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

4. Frontend

cd frontend
pnpm install
pnpm run dev

Open http://localhost:3000

Troubleshooting

  • Endee not reachable (ConnectionRefusedError): Ensure Docker is running and the Endee container is started on port 8080.
  • Ollama model not found: Run ollama pull codellama to download the model before starting the server. If using a different model, update OLLAMA_MODEL in your .env.
  • MongoDB connection failed: Ensure MongoDB is running locally on port 27017, or update MONGO_URL to point to a cloud cluster like MongoDB Atlas.
  • Port conflicts: If ports 3000 (frontend), 8000 (backend), or 8080 (Endee) are in use, stop conflicting services or update your environment variables and API proxy targets accordingly.

πŸ“ Project Structure

codemind/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py              # FastAPI routes
β”‚   β”œβ”€β”€ config.py            # All configuration
β”‚   β”œβ”€β”€ endee_client.py      # Endee SDK wrapper
β”‚   β”œβ”€β”€ ingestion.py         # File parsing β†’ chunking β†’ embedding β†’ storing
β”‚   β”œβ”€β”€ rag.py               # RAG pipeline (search β†’ prompt β†’ stream)
β”‚   β”œβ”€β”€ agent.py             # Agentic pipeline (decompose β†’ multi-search β†’ synthesize)
β”‚   β”œβ”€β”€ test_endee.py        # End-to-end Endee validation
β”‚   └── requirements.txt
└── frontend/
    β”œβ”€β”€ app/
    β”‚   β”œβ”€β”€ page.tsx          # Main two-panel layout
    β”‚   β”œβ”€β”€ layout.tsx        # Root layout with dark theme
    β”‚   └── api/              # 6 proxy routes β†’ backend
    └── components/
        β”œβ”€β”€ UploadPanel.tsx   # File upload + indexed files list
        β”œβ”€β”€ ChatPanel.tsx     # RAG chat with streaming
        β”œβ”€β”€ SearchPanel.tsx   # Semantic search results
        β”œβ”€β”€ AgentPanel.tsx    # Agentic Q&A with live steps
        └── FileCard.tsx      # File recommendations

πŸ” How Endee Powers Every Feature

Ingestion

Each code file is split into 60-line chunks with 10-line overlap, embedded using all-MiniLM-L6-v2, and stored via index.upsert() with metadata {file_path, language, chunk_index, text}.

RAG Chat

User question β†’ model.encode() β†’ index.query(top_k=6) β†’ retrieved chunks become LLM context β†’ Ollama generates cited answer.

Semantic Search

Query β†’ embed β†’ index.query(top_k=8) β†’ return ranked chunks with similarity scores. No LLM involved.

Recommendations

Select a file β†’ retrieve all its chunks β†’ compute mean embedding β†’ index.query() β†’ filter out same file β†’ return top-4 similar files.

Agentic Q&A

Complex question β†’ Ollama decomposes into 3 sub-questions β†’ index.query() for each sub-question β†’ deduplicate chunks β†’ Ollama synthesizes comprehensive answer with citations.


πŸ“ API Reference

(Data routes require a valid JWT token in the Authorization: Bearer <token> header)

Method Endpoint Description Auth
POST /auth/register Create user account No
POST /auth/login Login, get JWT No
GET /auth/me Get current user info Yes
POST /ingest Upload code file or ZIP Yes
POST /ask RAG Q&A (SSE stream) Yes
POST /agent Agentic Q&A (SSE stream) Yes
GET /search?q=...&top_k=8 Semantic search Yes
GET /recommend?file_path=...&top_k=4 File recommendations Yes
GET /files List all indexed files Yes
GET /health Health check No

All responses follow: {"success": true, "data": {...}, "error": null}


Demonstrating Semantic Search, RAG, Recommendations, and Agentic AI, all powered by the Endee vector database.

About

An intelligent codebase Q&A system powered by Endee vector database that allows you to upload code, ask questions in plain English, and get context-aware, cited answers. Implements RAG, semantic search, file recommendations, and agentic AI for complex queries.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages