Skip to main content

Universal RAG system for project documentation

Project description

DocRAG Kit

Tests Python License

Universal RAG (Retrieval-Augmented Generation) system for project documentation. Quickly add AI-powered semantic search to any project.

Features

  • 🚀 Quick Setup - Initialize RAG system in any project with one command
  • 📚 Universal - Works with any documentation (Markdown, code, configs)
  • 🔌 MCP Integration - Seamless integration with Kiro AI via Model Context Protocol
  • 🌍 Multilingual - Supports Russian and English questions and answers
  • 🎯 Project Templates - Predefined templates for Symfony, iOS, and general projects
  • 🔒 Secure - API keys stored safely in .env files

Installation

Requirements

  • Python >= 3.10 (3.11 recommended)
  • pip >= 21.0

From PyPI (when published)

pip install docrag-kit

From Source

git clone https://github.com/dexiusprime-oss/docrag-kit.git
cd docrag-kit
pip install -e .

Troubleshooting Installation

If you encounter dependency conflicts with onnxruntime or pulsar-client:

# Use Python 3.11
python3.11 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install docrag-kit

For more solutions, see docs/TROUBLESHOOTING.md

Quick Start

1. Initialize RAG System

Navigate to your project directory and run:

docrag init

This will:

  • Start an interactive configuration wizard
  • Ask for your LLM provider (OpenAI or Gemini)
  • Request your API key
  • Configure directories and file types to index
  • Create .docrag/ directory with configuration

2. Index Your Documentation

docrag index

This will:

  • Scan configured directories for documentation
  • Split documents into chunks
  • Create embeddings using your chosen LLM provider
  • Store vectors in local ChromaDB database

3. Connect to Kiro AI

docrag mcp-config

This will display the MCP server configuration to add to Kiro.

4. Start Searching

Once configured in Kiro, you can ask questions about your project:

  • "What is the architecture of this project?"
  • "How do I configure the database?"
  • "What APIs are available?"

Configuration

After initialization, your project will have:

your-project/
├── .docrag/
│   ├── config.yaml      # Configuration file
│   ├── mcp_server.py    # MCP server for Kiro
│   ├── vectordb/        # Vector database (gitignored)
│   └── .gitignore       # Excludes vectordb and .env
└── .env                 # API keys (gitignored)

Configuration File

.docrag/config.yaml contains all settings:

project:
  name: "my-project"
  type: "symfony"  # symfony, ios, general, custom

llm:
  provider: "openai"  # openai, gemini
  embedding_model: "text-embedding-3-small"
  llm_model: "gpt-4o-mini"
  temperature: 0.3

indexing:
  directories:
    - "docs/"
    - "src/"
  extensions:
    - ".md"
    - ".txt"
    - ".py"
  exclude_patterns:
    - "node_modules/"
    - ".git/"

chunking:
  chunk_size: 1000
  chunk_overlap: 200

retrieval:
  top_k: 5

Commands

docrag init

Initialize DocRAG in current project with interactive wizard.

docrag index

Index project documents and create vector database.

docrag reindex

Rebuild vector database from scratch (useful after documentation changes).

docrag config

Display current configuration.

docrag config --edit

Open configuration file in default editor.

docrag mcp-config

Display MCP server configuration for Kiro integration.

docrag doctor

Diagnose installation and configuration issues. Checks:

  • DocRAG initialization
  • Configuration files
  • API keys
  • Vector database
  • Python environment
  • Required packages
  • MCP configuration

docrag --version

Display version information.

docrag --help

Display help information.

Supported File Types

  • Markdown: .md
  • Text: .txt
  • Python: .py
  • PHP: .php
  • Swift: .swift
  • JSON: .json
  • YAML: .yaml, .yml
  • Config: .conf, .config, .ini

LLM Providers

OpenAI

Google Gemini

Project Templates

Symfony

Optimized for Symfony PHP framework projects with expert knowledge of:

  • Symfony components and bundles
  • Doctrine ORM
  • Twig templates
  • PHP best practices

iOS

Optimized for iOS development projects with expert knowledge of:

  • Swift programming language
  • UIKit and SwiftUI
  • iOS SDK and frameworks
  • Xcode and development tools

General Documentation

General-purpose template for any project type.

Custom

Provide your own custom prompt template.

Security

⚠️ CRITICAL WARNING: Never commit your .env file to git!

Your .env file contains sensitive API keys that provide access to paid services. If exposed, they can be used by others, potentially costing you money or compromising your accounts.

Automatic Security Features

DocRAG Kit automatically protects your API keys by:

  • Creating .docrag/.gitignore to exclude sensitive files (vectordb/, .env, *.pyc)
  • Checking if .env is in your root .gitignore
  • Offering to add .env to .gitignore if missing
  • Creating .env.example template without real keys
  • Displaying security warnings after initialization

Best Practices

  1. Always keep .env in .gitignore

    • DocRAG Kit checks this during initialization
    • Verify with: grep .env .gitignore
  2. Use .env.example as a template

    • Share .env.example with your team (no real keys)
    • Team members copy it to .env and add their own keys
  3. Never share API keys

    • Don't paste them in public issues or forums
    • Don't commit them to public repositories
    • Don't share them in chat or email
  4. Rotate keys if exposed

    • If you accidentally commit .env, revoke keys immediately
    • Generate new keys from provider dashboard
    • Update your .env file

What to Do If You Accidentally Commit API Keys

If you accidentally commit your .env file or API keys to git:

  1. Revoke the exposed keys immediately:

  2. Generate new API keys from the provider dashboard

  3. Update your .env file with the new keys

  4. Remove keys from git history:

    # Using git filter-branch (for small repos)
    git filter-branch --force --index-filter \
      "git rm --cached --ignore-unmatch .env" \
      --prune-empty --tag-name-filter cat -- --all
    
    # Or use BFG Repo-Cleaner (recommended for large repos)
    # https://rtyley.github.io/bfg-repo-cleaner/
    bfg --delete-files .env
    
  5. Force push to remote (if already pushed):

    git push origin --force --all
    git push origin --force --tags
    
  6. Notify team members to re-clone the repository

Pre-commit Hook (Recommended)

Add a pre-commit hook to prevent accidentally committing .env:

# Create .git/hooks/pre-commit
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
if git diff --cached --name-only | grep -q "^\.env$"; then
    echo "ERROR: Attempting to commit .env file!"
    echo "This file contains sensitive API keys."
    echo "Add .env to .gitignore and try again."
    exit 1
fi
EOF

# Make it executable
chmod +x .git/hooks/pre-commit

Security Checklist

Before pushing to git, verify:

  • .env is in .gitignore
  • .env is not staged for commit (git status)
  • .env.example exists (without real keys)
  • .docrag/.gitignore excludes vectordb/ and .env
  • No API keys in configuration files
  • Pre-commit hook is installed (optional but recommended)

MCP Integration

DocRAG Kit provides two MCP tools for Kiro AI:

search_docs

Search project documentation using semantic search.

Parameters:

  • question (string, required): Question to search for
  • include_sources (boolean, optional): Include source files in response

Example:

Question: "How do I configure the database?"
Response: "To configure the database, edit the .env file..."

list_indexed_docs

List all indexed documents in the project.

Returns: List of all source files in the vector database.

Documentation

Quick Links

Examples

See docs/EXAMPLES.md for detailed usage examples including:

  • Symfony project setup
  • iOS project setup
  • General documentation project
  • Example questions and answers
  • Configuration examples

MCP Integration

See docs/MCP_INTEGRATION.md for complete integration guide:

  • Getting MCP configuration
  • Manual and automatic setup
  • Testing MCP server
  • Troubleshooting connection issues

Troubleshooting

See docs/TROUBLESHOOTING.md for detailed solutions to:

  • Installation issues
  • API key problems
  • Indexing errors
  • MCP connection issues
  • Performance optimization

Quick fixes:

Database Not Found

docrag index

API Key Errors

# Check .env file
cat .env
# Should show: OPENAI_API_KEY=sk-... or GOOGLE_API_KEY=...

MCP Connection Issues

# Verify MCP server exists
ls .docrag/mcp_server.py

# Test manually
python .docrag/mcp_server.py

Development

Setup Development Environment

git clone https://github.com/yourusername/docrag-kit.git
cd docrag-kit
pip install -e ".[dev]"

Run Tests

pytest

Run Property-Based Tests

pytest tests/property/

Code Formatting

black src/ tests/

Type Checking

mypy src/

Requirements

  • Python >= 3.8
  • OpenAI API key or Google Gemini API key
  • 100MB+ disk space for vector database

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

Documentation

Community

Changelog

0.1.0 (Initial Release)

  • Initial release with core functionality
  • Support for OpenAI and Gemini providers
  • MCP integration for Kiro AI
  • Interactive setup wizard
  • Project templates (Symfony, iOS, General)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docrag_kit-0.1.1.tar.gz (57.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docrag_kit-0.1.1-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file docrag_kit-0.1.1.tar.gz.

File metadata

  • Download URL: docrag_kit-0.1.1.tar.gz
  • Upload date:
  • Size: 57.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for docrag_kit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 919a145f92139d1d7857de5f991bdd4267fde50ed4846dc0f532d364fb3f37ec
MD5 cbd51412c2110362a9f1d3d5e4ffff78
BLAKE2b-256 e5b35624f6deff0d16929073b6b67c65f55e5b6b5dbf927d6756582cf77cd74a

See more details on using hashes here.

File details

Details for the file docrag_kit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: docrag_kit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for docrag_kit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9516de85515724578a30f243d127a6b71c2395f509087ff52b9ed86bef8fda1
MD5 f3d4151573ae470c3c884f31f7892219
BLAKE2b-256 14867f770bb18e87e4bd030bdcdd936a148b55e53a1d5afd1d51478ae9088b6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page