Skip to main content
Glama
README.md
# Software Development Practitioner RAG + MCP Knowledge Base

Offline Hybrid RAG (**SQLite FTS5 BM25 + ChromaDB `ONNXMiniLM_L6_V2` dense vectors + Reciprocal Rank Fusion**) and stdio JSON-RPC 2.0 MCP documentation server synthesizing **battle-tested software engineering wisdom from veteran practitioners, university courses, engineering books, and open-source security/architecture guides**.

## Why This Exists

AI coding agents often hallucinate premature abstractions, ship N+1 database queries, forget timeouts and idempotency keys, introduce `IDOR`/SQLi/XSS/path-traversal bugs, write brittle mock-heavy or `sleep()`-flaky tests, or misuse `useEffect` and database migrations. This repository turns proven engineering knowledge into a fast, 100% offline, bilingual (**English + Vietnamese**) RAG MCP server so agents retrieve real practitioner standards before writing code.

## Repository Layout

- `docs/` — **12 curated practitioner guides** (`00_` through `11_`, including a **50-item Pitfall & Pre-Delivery QA Catalog** in `10_` and **Free Courses & Books Compendium** in `11_`). Works standalone right after cloning.
- `AGENTS.md` — System working rules directing AI coding agents to query `software-dev-lessons` before guessing architectures, schemas, queries, auth flows, or tests.
- `fetch_sources.py` — Optional reproducible downloader to pull curated YouTube transcripts/chapters, playlists, free web books/guides (`Google SWE`, `Google SRE`, `Martin Fowler`, `Use The Index, Luke!`, `MIT Missing Semester`, `12-Factor`, `React.dev`, `Kent C. Dodds`, `Refactoring.Guru`, `Google AIP`, `OWASP`), and companion GitHub repositories locally into `raw_sources/` (gitignored).
- `ingest.py` — Builds `data/lessons.sqlite3` (FTS5 + structured `pitfalls` table) and `data/chroma/` (`software_dev_lessons`) from `docs/` (and `raw_sources/` if fetched locally).
- `dev_rag.py` — Standalone CLI + bilingual (Vietnamese/English) Hybrid RAG + stdio JSON-RPC 2.0 MCP server (`4` read-only tools).
- `smoke_test.py` — End-to-end verification suite (CLI search, pitfalls, section reads, and strict stdio MCP handshake/tool validation).

## Quick Setup

```bash
# 1. Install dependencies (Python >= 3.10)
pip install -e .

# 2. (Optional) Fetch full upstream YouTube transcripts, web books & companion GitHub repos locally
python fetch_sources.py

# 3. Build local SQLite FTS5 + Chroma vector index (works out-of-the-box with `docs/`)
python ingest.py

# 4. Query via CLI (English or Vietnamese)
python dev_rag.py search "database index composite b-tree explain analyze n+1"
python dev_rag.py search "cach chong loi bao mat sql injection idor va jwt trong api"
python dev_rag.py pitfalls "IDOR"
python dev_rag.py read databases-data-modeling-and-query-performance --section "Index"
python dev_rag.py stats

# 5. Verify RAG + MCP protocol health
python smoke_test.py
```

## Register as an MCP Server

Add this server block to your MCP client config (e.g. `mcp_config.json`):

```json
{
  "mcpServers": {
    "software-dev-lessons": {
      "type": "stdio",
      "command": "python",
      "args": ["-B", "/path/to/DevDocs/dev_rag.py", "mcp"],
      "env": {
        "PYTHONUTF8": "1",
        "ANONYMIZED_TELEMETRY": "False"
      },
      "timeoutMs": 120000
    }
  }
}
```

### Exposed MCP Tools

- `search_dev_lessons(query, topic=None, tier="all", limit=6)`
- `read_dev_lesson(doc_id, section=None, offset=0, limit=16000)`
- `get_dev_pitfalls(symptom_or_topic, limit=8)`
- `list_dev_topics_and_courses(tier="curated")`

## Security & Third-Party Attribution

- Runs **100% offline** at query time with read-only SQLite access and telemetry disabled (see [SECURITY.md](SECURITY.md)).
- Third-party transcripts, web articles, and external repositories (`MIT Missing Semester`, `MIT 6.824`, `CMU 15-445`, `Martin Kleppmann`, `John Ousterhout`, `Martin Fowler`, `Dave Farley`, `Sandi Metz`, `ArjanCodes`, `CodeAesthetic`, `ByteByteGo`, `Hussein Nasser`, `Markus Winand`, `Kent C. Dodds`, `Google SWE & SRE Books`, `OWASP CheatSheetSeries`, `donnemartin/system-design-primer`, `12factor.net`, `React.dev`, `Refactoring.Guru`, `freeCodeCamp`) are **not redistributed** inside this Git repository—see `docs/11_free_courses_youtube_and_books_compendium.md` and `fetch_sources.py` for direct source links.