Skip to content

ahmdeltoky03/RAGGuide_

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

165 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 RAGGuide_ (Mini RAG App)

RAGGuide_ is a powerful Retrieval-Augmented Generation (RAG) system designed for:

  • Question Answering (Q&A) β€” providing accurate, context-aware responses to user queries.
  • Rule Compliance Evaluation (Judge Mode) β€” analyzing reports or documents against specified rules and offering structured feedback.

It combines FastAPI, PostgreSQL/pgvector, and Streamlit to create a smart, document-aware conversational system that bridges reasoning and data-driven understanding.

Images

✨ Key Features

  • πŸ’¬ Q&A Mode – Ask natural-language questions and get accurate, polite, and concise answers.

  • βš–οΈ Judge Mode – Verify if uploaded reports or ideas comply with specific rules or policies and receive improvement suggestions.

  • 🧩 RAG Architecture – Combines vector retrieval with generative reasoning.

  • πŸš€ FastAPI Backend – High-performance and modular REST API.

  • 🎨 Streamlit Frontend – User-friendly web interface for uploading, processing, and querying documents.

  • 🐳 Docker Ready – Fully containerized for easy deployment.

  • πŸ“Š Monitoring – Integrated Prometheus and Grafana dashboards for performance insights.

Requirements

  • Python 3.9+
  • PostgreSQL (with pgvector extension) or Qdrant
  • Docker
  • Conda (recommended for local development)
  • VS Code (for editing and debugging)

🧩 Installation Steps

Install Dependencies

sudo apt update
sudo apt install libpq-dev gcc python3-dev

Install Python Using Miniconda

  1. Download Miniconda from here

  2. Create New Environment using :

    $ conda create -n mini-rag-app-2 python=3.9
  3. Activate New Environment using :

    $ conda activate mini-rag-app-2
  4. Install packages in requirements.txt:

    $ pip install -r requirements.txt

Setup Your Environment Variables

$ cp .env.example .env
  • Then open docker/env/.env.app and configure your keys:
    COHERE_API_KEY="your_cohere_key"
    OPEN_API_KEY="your_openai_key"
    POSTGRES_USERNAME="postgres"
    POSTGRES_PASSWORD="postgres_password"

Run Docker Compose Services

$ cd docker
$ sudo docker compose up
  • update .env with your credentials.

Run the FastAPI Backend (Locally)

  $ uvicorn main:app --reload --host 0.0.0.0 --port 5000

Access the API documentation here: http://localhost:8000/docs

πŸ’» Run the Streamlit Interface

  $ streamlit run app.py

🌐 Open in your browser: http://localhost:8501

πŸ“Š Grafana Performance Dashboard

  • You can monitor application metrics, performance, and API usage using the integrated Grafana dashboard.

Grafana Dashboard

(Example view of RAGGuide’s system performance using Grafana and Prometheus integration.)

🧱 Project Structure

RAGGuide_/
β”œβ”€β”€ app.py                          # Streamlit frontend entrypoint
β”‚
β”œβ”€β”€ src/                            # Backend (FastAPI + RAG core logic)
β”‚   β”œβ”€β”€ main.py                     # FastAPI app entrypoint
β”‚   β”œβ”€β”€ .env                        # Environment variables for backend
β”‚   β”œβ”€β”€ .env.example                # Example environment file
β”‚   β”œβ”€β”€ requirements.txt            # Backend dependencies
β”‚   β”œβ”€β”€ .gitignore                  # Ignore rules specific to backend development
β”‚   β”‚
β”‚   β”œβ”€β”€ assets/                     # Static assets or processed data
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/                # Core application controllers (business logic)
β”‚   β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ BaseController.py       # Common controller base class
β”‚   β”‚   β”œβ”€β”€ DataController.py       # Handles document ingestion and management
β”‚   β”‚   β”œβ”€β”€ NLPController.py        # Handles text processing, embeddings, and NLP tasks
β”‚   β”‚   β”œβ”€β”€ ProcessController.py    # Document preprocessing and cleaning
β”‚   β”‚   └── ProjectController.py    # Manages project-level configurations and workflows
β”‚   β”‚
β”‚   β”œβ”€β”€ helpers/                    # General-purpose helpers and configurations
β”‚   β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── config.py               # Global configuration and environment loader
β”‚   β”‚
β”‚   β”œβ”€β”€ models/                     # Database and Pydantic models
β”‚   β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚   β”œβ”€β”€ db_schemes/             # Alembic schemas and DB structure
β”‚   β”‚   β”œβ”€β”€ enum/                   # Enum definitions for model constants
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ AssetModel.py
β”‚   β”‚   β”œβ”€β”€ BaseDataModel.py
β”‚   β”‚   β”œβ”€β”€ ChunkModel.py
β”‚   β”‚   └── ProjectModel.py
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/                     # FastAPI routes (API endpoints)
β”‚   β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚   β”œβ”€β”€ schemes/                # Request/response schemas for routes
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ base.py
β”‚   β”‚   β”‚   β”œβ”€β”€ data.py
β”‚   β”‚   β”‚   └── nlp.py
β”‚   β”‚
β”‚   β”œβ”€β”€ stores/                     # Data and model storage layer
β”‚   β”‚   β”œβ”€β”€ llm/                    # Large Language Model integration layer
β”‚   β”‚   β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚   β”‚   β”œβ”€β”€ providers/          # Specific LLM providers (OpenAI, Cohere, etc.)
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ColHereProvider.py
β”‚   β”‚   β”‚   β”‚   └── OpenAllProvider.py
β”‚   β”‚   β”‚   β”œβ”€β”€ templates/          # Prompt templates and LLM configuration files
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ LLMinums.py         # Enum for LLM provider types
β”‚   β”‚   β”‚   β”œβ”€β”€ LLMInterface.py     # Abstract interface for all LLMs
β”‚   β”‚   β”‚   └── LLMProviderFactory.py # Factory pattern for dynamic provider selection
β”‚   β”‚   β”‚
β”‚   β”‚   └── vectordb/               # Vector database layer (for retrieval)
β”‚   β”‚       β”œβ”€β”€ __pycache__/
β”‚   β”‚       β”œβ”€β”€ providers/          # Specific vector DB providers
β”‚   β”‚       β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚       β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚       β”‚   β”œβ”€β”€ PGVectorProvider.py
β”‚   β”‚       β”‚   └── OdrantDBProvider.py
β”‚   β”‚       β”œβ”€β”€ __init__.py
β”‚   β”‚       β”œβ”€β”€ VectorDBEnumspy      # Enum definitions for vector DB backends
β”‚   β”‚       β”œβ”€β”€ VectorDBInterface.py # Interface for all vector DB integrations
β”‚   β”‚       └── VectorDBProviderFactory.py # Factory for vector DB providers
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/                      # Utility functions and performance metrics
β”‚   β”‚   β”œβ”€β”€ __pycache__/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── metrics.py              # App-level metrics and monitoring logic
β”‚
β”œβ”€β”€ docker/                         # Docker deployment and orchestration
β”‚   β”œβ”€β”€ env/                        # Environment configuration files
β”‚   β”‚   β”œβ”€β”€ .env.app
β”‚   β”‚   β”œβ”€β”€ .env.example.app
β”‚   β”‚   β”œβ”€β”€ .env.example.grafana
β”‚   β”‚   β”œβ”€β”€ .env.example.postgres
β”‚   β”‚   β”œβ”€β”€ .env.example.postgres-exporter
β”‚   β”‚   β”œβ”€β”€ .env.grafana
β”‚   β”‚   β”œβ”€β”€ .env.postgres
β”‚   β”‚   └── .env.postgres-exporter
β”‚   β”‚
β”‚   β”œβ”€β”€ minirag/                    # FastAPI build context and Alembic migrations
β”‚   β”‚   β”œβ”€β”€ alembic.ini
β”‚   β”‚   β”œβ”€β”€ alembic.ini.example
β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   └── entrypoint.sh
β”‚   β”‚
β”‚   β”œβ”€β”€ nginx/                      # Reverse proxy configuration
β”‚   β”‚   └── default.conf
β”‚   β”‚
β”‚   β”œβ”€β”€ prometheus/                 # Prometheus configuration for metrics
β”‚   β”‚   └── prometheus.yml
β”‚   β”‚
β”‚   β”œβ”€β”€ docker-compose.yml          # Multi-container setup (FastAPI, Streamlit, Postgres, Grafana)
β”‚   β”œβ”€β”€ .gitignore
β”‚   └── README.md
β”‚
β”œβ”€β”€ assets/                         # Data assets or sample files
β”‚
β”œβ”€β”€ Images/                         # Screenshots and monitoring visuals
β”‚   β”œβ”€β”€ fastapi-grafana.jpg         # Grafana dashboard showing API metrics
β”‚   └── streamlit_interface.jpg     # Streamlit user interface screenshot
β”‚
β”œβ”€β”€ .gitignore                      # Root-level ignore configuration
β”œβ”€β”€ LICENSE                         # MIT License
└── README.md                       # Project documentation

πŸ“¬ Postman Collection

🀝 Contributing

Contributions are always welcome..

To contribute to RAGGuide_:

  1. Fork the repository.
  2. Create a new branch for your feature or fix:
    git checkout -b feature/your-feature-name
  3. Commit your changes:
    git commit -m "Add new feature or fix issue"
  4. Push to your branch:
    git push origin feature/your-feature-name
  5. Open a Pull Request with a clear description of your changes.

πŸ“œ License

This project is licensed under the MIT License.
See the LICENSE file for details.

🌟 Note

RAGGuide_ was created to serve as both an educational and deployable Retrieval-Augmented Generation (RAG) system.
It provides a flexible foundation for building intelligent, retrieval-augmented applications that combine reasoning, context awareness, and document understanding.

πŸ“§ Contact

For questions, collaborations, or contribution opportunities, feel free to reach out:

About

RAGGuide_ – An intelligent RAG-based system enabling document-grounded chat through πŸ’¬ Q&A and βš–οΈ Judge modes for smart reasoning and rule compliance.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages