A production-grade, fully local AI-powered knowledge system that combines a Knowledge Graph, vector database, and a single shared LLM to analyse code, answer questions from documents, summarise videos, and generate code from natural language — all running on your Mac without any cloud API keys.
| Feature | Description |
|---|---|
| 🔍 Code Analysis | Upload or paste Python/JS/TS/Java/C++ — extracts entities, generates documentation, cross-references the KG |
| 🪄 NL → Code | Describe a task in English; the LLM generates clean, commented code |
| 🎬 Video Summary | Upload an MP4; Whisper transcribes it, the LLM bullet-points the key ideas |
| 💬 Q&A Hub | Upload PDFs/docs; ChromaDB retrieves relevant chunks, LLM synthesises a grounded answer |
| 🕸️ Knowledge Graph | Interactive NetworkX + RDFLib graph; persists to kg.ttl, indexes into ChromaDB |
| 📤 File Upload | One-stop upload page — routes files to data/code, data/video, or data/docs and auto-processes them |
| 📊 Evaluation | ROUGE / BLEU / exact-match / perplexity metrics for summarisation, code-gen, and entity extraction |
┌─────────────────────────────────────────────────────────┐
│ React 18 + Vite │
│ Home · Code · NL→Code · Video · Q&A · KG · Upload · Eval│
└───────────────────────┬─────────────────────────────────┘
│ REST (Axios)
┌───────────────────────▼─────────────────────────────────┐
│ FastAPI (uvicorn) │
│ /api/upload /api/files /api/qa /api/code /api/video │
└──────┬──────────────┬─────────────────┬─────────────────┘
│ │ │
┌──────▼──────┐ ┌─────▼──────┐ ┌──────▼───────┐
│ ModelHub │ │ ChromaDB │ │ NetworkX + │
│ singleton │ │ (local) │ │ RDFLib KG │
│ Phi-3.5-mini│ │bits_docs │ │ kg.ttl │
│ MiniLM-L6v2 │ │bits_code │ │ │
│ Whisper base│ │bits_kg │ │ │
└─────────────┘ └────────────┘ └──────────────┘
| Role | Model | Size | Licence |
|---|---|---|---|
| LLM (generation) | microsoft/Phi-3.5-mini-instruct | 3.8B | MIT |
| Embeddings | sentence-transformers/all-MiniLM-L6-v2 | 22M (~80 MB) | Apache 2 |
| Speech-to-text | OpenAI Whisper base | 145 MB | MIT |
| Vector DB | ChromaDB (local persistent) | — | Apache 2 |
| KG persistence | RDFLib Turtle (.ttl) | — | BSD |
Why Phi-3.5-mini? MIT-licensed 3.8B instruction-tuned model from Microsoft. Outperforms Llama-2-7B on many benchmarks and runs efficiently on Apple Silicon (MPS) in float16. Fallbacks: Qwen2.5-Coder-1.5B → TinyLlama-1.1B.
Why MiniLM-L6-v2? Only 80 MB, loads in under 2 seconds, achieves >75 on BEIR benchmarks — far outperforming TF-IDF for semantic retrieval.
Why ChromaDB? Zero-server, fully embedded, stores vectors on disk in chroma_db/. No Docker or
external process needed.
BITS_KB/
├── backend/
│ ├── api/
│ │ └── main.py # FastAPI routes (all endpoints)
│ ├── config.py # Paths, model names, runtime constants
│ ├── services/
│ │ ├── code_service.py # Code analysis + docs generation
│ │ ├── nl_to_code_service.py # NL → code generation
│ │ ├── qa_service.py # ChromaDB retrieval + LLM answers
│ │ ├── video_service.py # Whisper + LLM summarisation
│ │ └── kg_service.py # KG stats / search / visualise
│ └── utils/
│ ├── model_hub.py # ← SINGLE shared model singleton
│ ├── kg.py # NetworkX + RDFLib + ChromaDB indexing
│ ├── code_utils.py
│ ├── metrics.py
│ └── llm.py # GeminiClient helper
├── frontend/
│ ├── src/
│ │ ├── pages/ # Home · Code · NLToCode · Video · QA · KG · Upload · Eval
│ │ ├── components/ # Layout · UI primitives
│ │ └── api/client.ts # All API calls
│ └── vite.config.ts
├── data/
│ ├── code/ # Uploaded code files
│ ├── video/ # Uploaded video files
│ └── docs/ # Uploaded documents (PDF, TXT, MD)
├── chroma_db/ # ChromaDB persistent storage (auto-created)
├── kg.ttl # RDF Turtle export of the Knowledge Graph
├── requirements.txt
└── README.md
ffmpeg in PATH for video: brew install ffmpegcd BITS_KB
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn backend.api.main:app --host 0.0.0.0 --port 8000 --reload
The first LLM request downloads Phi-3.5-mini (~7 GB). Subsequent starts are instant (HuggingFace cache).
cd frontend
npm install
npm run dev # dev server at http://localhost:5173
Open http://localhost:5173.
echo "GEMINI_API_KEY=your_key_here" > .env
ModelHub prefers Gemini when a valid key is present.
| Method | Path | Description |
|---|---|---|
GET | /api/health | Liveness check |
GET | /api/kg/stats | Node/edge counts |
GET | /api/kg/search?q=… | KG keyword/semantic search |
POST | /api/kg/visualize | Returns PNG as base64 |
POST | /api/kg/save_rdf | Persist KG → kg.ttl |
POST | /api/kg/index_chroma | Index all KG nodes into ChromaDB |
POST | /api/code/analyze | Analyse code text/file path |
POST | /api/code/upload | Upload + analyse a code file |
POST | /api/nl_to_code/generate | NL description → code |
POST | /api/qa/ask | Answer question from ChromaDB context |
POST | /api/qa/ingest | Upload doc → ingest into ChromaDB |
GET | /api/qa/documents | List indexed documents |
POST | /api/video/upload | Upload + transcribe + summarise |
POST | /api/upload | Generic upload (code / video / docs) |
GET | /api/files | List all data files by folder |
GET | /api/eval/summarization | ROUGE/BLEU metrics |
GET | /api/eval/codegen | Code-gen metrics |
GET | /api/eval/entities | Entity extraction metrics |
Interactive Swagger docs: http://localhost:8000/docs
DiGraph with typed nodes (concept, pattern, algorithm, document, code_entity)kg.ttl (Turtle format) on POST /api/kg/save_rdfbits_kg via POST /api/kg/index_chromaKGManager.semantic_search() tries ChromaDB first; falls back to keyword matchingbackend/config.py)MODELS = {
"llm": "microsoft/Phi-3.5-mini-instruct",
"llm_fallbacks": ["Qwen/Qwen2.5-Coder-1.5B-Instruct", "TinyLlama/TinyLlama-1.1B-Chat-v1.0"],
"embedding": "sentence-transformers/all-MiniLM-L6-v2",
"whisper": "base", # tiny | base | small | medium
}
RESOURCES = {
"max_entities_to_doc": 30,
"docs_total_time_budget": 45.0, # seconds
"chroma_top_k": 6,
}
| Issue | Fix |
|---|---|
| MPS errors on Apple Silicon | export PYTORCH_ENABLE_MPS_FALLBACK=1 |
| Whisper can't find ffmpeg | brew install ffmpeg |
chromadb import error | pip install chromadb>=0.5.0 |
| Port 8000 in use | lsof -ti:8000 | xargs kill |
| First startup slow (~2 min) | Normal — Phi-3.5-mini downloads ~7 GB |
| Empty LLM response | Model may be OOM; try whisper: "tiny" and TinyLlama fallback |
MIT — free for academic and commercial use.
13 commits
Python
89.2%
TypeScript
10.3%
A production-grade, fully local AI-powered knowledge system that combines a Knowledge Graph, vector database, and a single shared LLM to analyse code, answer questions from documents, summarise videos, and generate code from natural language — all running on your Mac without any cloud API keys.
| Feature | Description |
|---|---|
| 🔍 Code Analysis | Upload or paste Python/JS/TS/Java/C++ — extracts entities, generates documentation, cross-references the KG |
| 🪄 NL → Code | Describe a task in English; the LLM generates clean, commented code |
| 🎬 Video Summary | Upload an MP4; Whisper transcribes it, the LLM bullet-points the key ideas |
| 💬 Q&A Hub | Upload PDFs/docs; ChromaDB retrieves relevant chunks, LLM synthesises a grounded answer |
| 🕸️ Knowledge Graph | Interactive NetworkX + RDFLib graph; persists to kg.ttl, indexes into ChromaDB |
| 📤 File Upload | One-stop upload page — routes files to data/code, data/video, or data/docs and auto-processes them |
| 📊 Evaluation | ROUGE / BLEU / exact-match / perplexity metrics for summarisation, code-gen, and entity extraction |
┌─────────────────────────────────────────────────────────┐
│ React 18 + Vite │
│ Home · Code · NL→Code · Video · Q&A · KG · Upload · Eval│
└───────────────────────┬─────────────────────────────────┘
│ REST (Axios)
┌───────────────────────▼─────────────────────────────────┐
│ FastAPI (uvicorn) │
│ /api/upload /api/files /api/qa /api/code /api/video │
└──────┬──────────────┬─────────────────┬─────────────────┘
│ │ │
┌──────▼──────┐ ┌─────▼──────┐ ┌──────▼───────┐
│ ModelHub │ │ ChromaDB │ │ NetworkX + │
│ singleton │ │ (local) │ │ RDFLib KG │
│ Phi-3.5-mini│ │bits_docs │ │ kg.ttl │
│ MiniLM-L6v2 │ │bits_code │ │ │
│ Whisper base│ │bits_kg │ │ │
└─────────────┘ └────────────┘ └──────────────┘
| Role | Model | Size | Licence |
|---|---|---|---|
| LLM (generation) | microsoft/Phi-3.5-mini-instruct | 3.8B | MIT |
| Embeddings | sentence-transformers/all-MiniLM-L6-v2 | 22M (~80 MB) | Apache 2 |
| Speech-to-text | OpenAI Whisper base | 145 MB | MIT |
| Vector DB | ChromaDB (local persistent) | — | Apache 2 |
| KG persistence | RDFLib Turtle (.ttl) | — | BSD |
Why Phi-3.5-mini? MIT-licensed 3.8B instruction-tuned model from Microsoft. Outperforms Llama-2-7B on many benchmarks and runs efficiently on Apple Silicon (MPS) in float16. Fallbacks: Qwen2.5-Coder-1.5B → TinyLlama-1.1B.
Why MiniLM-L6-v2? Only 80 MB, loads in under 2 seconds, achieves >75 on BEIR benchmarks — far outperforming TF-IDF for semantic retrieval.
Why ChromaDB? Zero-server, fully embedded, stores vectors on disk in chroma_db/. No Docker or
external process needed.
BITS_KB/
├── backend/
│ ├── api/
│ │ └── main.py # FastAPI routes (all endpoints)
│ ├── config.py # Paths, model names, runtime constants
│ ├── services/
│ │ ├── code_service.py # Code analysis + docs generation
│ │ ├── nl_to_code_service.py # NL → code generation
│ │ ├── qa_service.py # ChromaDB retrieval + LLM answers
│ │ ├── video_service.py # Whisper + LLM summarisation
│ │ └── kg_service.py # KG stats / search / visualise
│ └── utils/
│ ├── model_hub.py # ← SINGLE shared model singleton
│ ├── kg.py # NetworkX + RDFLib + ChromaDB indexing
│ ├── code_utils.py
│ ├── metrics.py
│ └── llm.py # GeminiClient helper
├── frontend/
│ ├── src/
│ │ ├── pages/ # Home · Code · NLToCode · Video · QA · KG · Upload · Eval
│ │ ├── components/ # Layout · UI primitives
│ │ └── api/client.ts # All API calls
│ └── vite.config.ts
├── data/
│ ├── code/ # Uploaded code files
│ ├── video/ # Uploaded video files
│ └── docs/ # Uploaded documents (PDF, TXT, MD)
├── chroma_db/ # ChromaDB persistent storage (auto-created)
├── kg.ttl # RDF Turtle export of the Knowledge Graph
├── requirements.txt
└── README.md
ffmpeg in PATH for video: brew install ffmpegcd BITS_KB
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn backend.api.main:app --host 0.0.0.0 --port 8000 --reload
The first LLM request downloads Phi-3.5-mini (~7 GB). Subsequent starts are instant (HuggingFace cache).
cd frontend
npm install
npm run dev # dev server at http://localhost:5173
Open http://localhost:5173.
echo "GEMINI_API_KEY=your_key_here" > .env
ModelHub prefers Gemini when a valid key is present.
| Method | Path | Description |
|---|---|---|
GET | /api/health | Liveness check |
GET | /api/kg/stats | Node/edge counts |
GET | /api/kg/search?q=… | KG keyword/semantic search |
POST | /api/kg/visualize | Returns PNG as base64 |
POST | /api/kg/save_rdf | Persist KG → kg.ttl |
POST | /api/kg/index_chroma | Index all KG nodes into ChromaDB |
POST | /api/code/analyze | Analyse code text/file path |
POST | /api/code/upload | Upload + analyse a code file |
POST | /api/nl_to_code/generate | NL description → code |
POST | /api/qa/ask | Answer question from ChromaDB context |
POST | /api/qa/ingest | Upload doc → ingest into ChromaDB |
GET | /api/qa/documents | List indexed documents |
POST | /api/video/upload | Upload + transcribe + summarise |
POST | /api/upload | Generic upload (code / video / docs) |
GET | /api/files | List all data files by folder |
GET | /api/eval/summarization | ROUGE/BLEU metrics |
GET | /api/eval/codegen | Code-gen metrics |
GET | /api/eval/entities | Entity extraction metrics |
Interactive Swagger docs: http://localhost:8000/docs
DiGraph with typed nodes (concept, pattern, algorithm, document, code_entity)kg.ttl (Turtle format) on POST /api/kg/save_rdfbits_kg via POST /api/kg/index_chromaKGManager.semantic_search() tries ChromaDB first; falls back to keyword matchingbackend/config.py)MODELS = {
"llm": "microsoft/Phi-3.5-mini-instruct",
"llm_fallbacks": ["Qwen/Qwen2.5-Coder-1.5B-Instruct", "TinyLlama/TinyLlama-1.1B-Chat-v1.0"],
"embedding": "sentence-transformers/all-MiniLM-L6-v2",
"whisper": "base", # tiny | base | small | medium
}
RESOURCES = {
"max_entities_to_doc": 30,
"docs_total_time_budget": 45.0, # seconds
"chroma_top_k": 6,
}
| Issue | Fix |
|---|---|
| MPS errors on Apple Silicon | export PYTORCH_ENABLE_MPS_FALLBACK=1 |
| Whisper can't find ffmpeg | brew install ffmpeg |
chromadb import error | pip install chromadb>=0.5.0 |
| Port 8000 in use | lsof -ti:8000 | xargs kill |
| First startup slow (~2 min) | Normal — Phi-3.5-mini downloads ~7 GB |
| Empty LLM response | Model may be OOM; try whisper: "tiny" and TinyLlama fallback |
MIT — free for academic and commercial use.
13 commits
Python
89.2%
TypeScript
10.3%