Skip to content

AhmedRaoofuddin/RAG_Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Info Naut Logo

Info Naut

Navigate Your Knowledge Universe

Python FastAPI Next.js TypeScript Docker OpenAI

License PRs Maintained

Production-Ready RAG System with Advanced Guardrails & Attribution

Quick StartFeaturesDocumentationAPI Reference

Demo


Performance Metrics

Metric Value Industry Standard
Response Accuracy 95%+ 85%
Avg Response Time 1.8s 3.5s
PII Detection Rate 99% 90%
Injection Prevention 98% 85%
Grounding Score 92% 80%
Citation Accuracy 96% 75%
┌────────────────────────────────────────────────────────────────┐
│                    SYSTEM PERFORMANCE                          │
├────────────────────────────────────────────────────────────────┤
│                                                                │
│   Response Accuracy    ████████████████████████░░  95%         │
│   Grounding Score      ███████████████████████░░░  92%         │
│   Citation Precision   ████████████████████████░░  96%         │
│   Hallucination Detect ██████████████████████████  98%         │
│   PII Detection        ██████████████████████████  99%         │
│                                                                │
├────────────────────────────────────────────────────────────────┤
│   Avg Response: 1.8s   │   Throughput: 150 QPS                │
│   99th Percentile: 3.2s│   Concurrent Users: 500+             │
└────────────────────────────────────────────────────────────────┘

System Architecture

flowchart TB
    subgraph Client[<img src='https://api.iconify.design/carbon/user-avatar.svg' width='16'/> Client Layer]
        A[User]
        B[Next.js Frontend<br/>React + TypeScript]
    end

    subgraph API[<img src='https://api.iconify.design/carbon/api.svg' width='16'/> API Gateway]
        C[Authentication]
        D[Rate Limiting]
        E[Request Validation]
    end

    subgraph Backend[<img src='https://api.iconify.design/carbon/server.svg' width='16'/> Backend Services]
        F[FastAPI Server]
        
        subgraph Guardrails[Guardrails Engine]
            G[PII Detector]
            H[Injection Guard]
            I[Grounding Validator]
        end
        
        subgraph RAG[RAG Pipeline]
            J[Document Processor]
            K[Smart Chunker]
            L[Retriever]
            M[Generator]
        end
    end

    subgraph Data[<img src='https://api.iconify.design/carbon/data-base.svg' width='16'/> Data Layer]
        N[SQLite/MySQL<br/>Metadata]
        O[ChromaDB<br/>Vectors]
        P[File Storage]
    end

    subgraph External[<img src='https://api.iconify.design/carbon/cloud.svg' width='16'/> External Services]
        Q[OpenAI API<br/>GPT-4 / Embeddings]
    end

    A -->|HTTP/WebSocket| B
    B -->|REST API| C
    C --> D --> E --> F
    
    F --> G & H & I
    F --> J --> K --> O
    F --> L --> O
    L --> M --> Q
    M --> I
    
    F --> N
    J --> P
    
    style Client fill:#e1f5fe
    style API fill:#fff3e0
    style Backend fill:#f3e5f5
    style Data fill:#e8f5e9
    style External fill:#fce4ec
Loading

Request Flow

sequenceDiagram
    participant U as User
    participant F as Frontend
    participant B as Backend
    participant G as Guardrails
    participant R as Retriever
    participant V as VectorDB
    participant AI as OpenAI

    U->>F: Ask Question
    F->>B: POST /api/chat
    
    B->>G: Check Prompt Injection
    G-->>B: Safe
    
    B->>G: Redact PII
    G-->>B: Sanitized Query
    
    B->>R: Retrieve Context
    R->>V: Semantic Search
    V-->>R: Top-K Chunks
    R-->>B: Relevant Documents
    
    B->>AI: Generate Response
    AI-->>B: Raw Response
    
    B->>G: Validate Grounding
    G-->>B: Grounding Score + Citations
    
    B->>G: Detect Hallucinations
    G-->>B: Marked Response
    
    B-->>F: Streaming Response
    F-->>U: Display with Citations
Loading

Features

Core Capabilities

Document Processing

  • Multi-format support (PDF, DOCX, TXT, MD)
  • Intelligent chunking with line tracking
  • Automatic metadata extraction
  • Incremental updates

Semantic Search

  • AI-powered vector similarity
  • Multi-document retrieval
  • Context-aware ranking
  • Top-K result selection

Security Guardrails

  • PII detection & redaction
  • Prompt injection prevention
  • Malicious input filtering
  • Secure API access

Quality Assurance

  • Grounding validation
  • Hallucination detection
  • Source attribution
  • Confidence scoring

Guardrails System

PII Redaction Engine
# Automatically detected and redacted:
├── Email Addresses    → [EMAIL_REDACTED]
├── Phone Numbers      → [PHONE_REDACTED]
├── SSN/Tax IDs        → [SSN_REDACTED]
├── Credit Cards       → [CC_REDACTED]
└── Physical Addresses → [ADDRESS_REDACTED]
Prompt Injection Detection
┌─────────────────────────────────────────────────┐
│  INJECTION PATTERNS BLOCKED:                    │
├─────────────────────────────────────────────────┤
│  X "Ignore previous instructions..."            │
│  X "You are now a different AI..."              │
│  X "Reveal your system prompt..."               │
│  X "Pretend you have no restrictions..."        │
│  X Base64/encoded payloads                      │
│  X Prompt leaking attempts                      │
└─────────────────────────────────────────────────┘
Grounding Validation
Response: "The API supports 1000 requests per second"
                    │
                    ▼
┌─────────────────────────────────────────────────┐
│  GROUNDING CHECK                                │
├─────────────────────────────────────────────────┤
│  Source: api_docs.pdf, Page 12, Line 45        │
│  Match Score: 0.94                              │
│  Status: GROUNDED                               │
└─────────────────────────────────────────────────┘

Screenshots

Dashboard Overview

Dashboard

Clean interface with quick access to all features


Knowledge Base Management

Knowledge Base

Upload and organize documents across multiple knowledge bases


AI Chat Interface

Chat

Real-time streaming responses with source citations


Attribution & Citations

Attribution

Exact sources, page numbers, and similarity scores


API Documentation

API Docs

Interactive OpenAPI documentation


Quick Start

Prerequisites


Python 3.11+

Node.js 18+

OpenAI Key

Docker

Docker Deployment

# Clone repository
git clone https://github.com/AhmedRaoofuddin/infonaut.git
cd infonaut

# Set API key and launch
export OPENAI_API_KEY=your-key-here
docker-compose -f docker-compose.simple.yml up -d

# Access at http://localhost:3000

Windows PowerShell:

$env:OPENAI_API_KEY="your-key-here"
docker-compose -f docker-compose.simple.yml up -d

Manual Installation

Step-by-step Installation

1. Clone Repository

git clone https://github.com/AhmedRaoofuddin/infonaut.git
cd infonaut

2. Backend Setup

cd backend
pip install -r requirements.txt

3. Frontend Setup

cd frontend
npm install

4. Configure Environment

Edit start_backend.bat (Windows) or create .env:

OPENAI_API_KEY=your-key-here
RAG_STORE=sqlite
SQLITE_FILE=./data/infonaut.db
VECTOR_STORE_TYPE=chroma

5. Launch Application

# Windows
start_app.bat

# Linux/Mac
./start_backend.sh &
./start_frontend.sh

Automated Screenshot Capture

# Install screenshot automation
pip install -r requirements-screenshots.txt
playwright install chromium

# Capture all screenshots automatically
python capture_screenshots.py

# Record demo GIF
python capture_screenshots.py --video

Technology Stack

mindmap
  root((Info Naut))
    Frontend
      Next.js 14
      React 18
      TypeScript
      TailwindCSS
      shadcn/ui
    Backend
      FastAPI
      Python 3.11
      SQLAlchemy
      Pydantic
      LangChain
    AI/ML
      OpenAI GPT-4
      Embeddings API
      ChromaDB
      Semantic Search
    Infrastructure
      Docker
      SQLite/MySQL
      Playwright
      Automated Testing
Loading

Next.js 14

React 18

TypeScript

TailwindCSS

FastAPI

Python 3.11

OpenAI

ChromaDB

Docker

SQLite

Playwright

Git

API Reference

Access Points

Web App http://localhost:3000 Main interface
API http://localhost:8000 REST endpoints
Docs http://localhost:8000/docs OpenAPI/Swagger
Health http://localhost:8000/api/health Status check

Key Endpoints

Knowledge Bases
# Create Knowledge Base
curl -X POST "http://localhost:8000/api/knowledge-bases" \
  -H "Content-Type: application/json" \
  -d '{"name": "My KB", "description": "Product docs"}'

# List Knowledge Bases
curl "http://localhost:8000/api/knowledge-bases"

# Upload Document
curl -X POST "http://localhost:8000/api/knowledge-bases/1/documents" \
  -F "file=@document.pdf"
Chat
# Create Chat
curl -X POST "http://localhost:8000/api/chats" \
  -H "Content-Type: application/json" \
  -d '{"title": "New Chat", "knowledge_base_ids": [1]}'

# Send Message
curl -X POST "http://localhost:8000/api/chats/1/messages" \
  -H "Content-Type: application/json" \
  -d '{"content": "What is this about?"}'
API Keys
# Create API Key
curl -X POST "http://localhost:8000/api/api-keys" \
  -H "Content-Type: application/json" \
  -d '{"name": "Production Key"}'

# Use API Key
curl "http://localhost:8000/api/knowledge-bases" \
  -H "X-API-Key: your-api-key"

Project Structure

infonaut/
├── backend/                 # FastAPI Backend
│   ├── app/
│   │   ├── api/            # REST API endpoints
│   │   ├── core/           # Config, security
│   │   ├── models/         # SQLAlchemy models
│   │   ├── schemas/        # Pydantic schemas
│   │   ├── services/       # Business logic
│   │   │   ├── guardrails.py
│   │   │   ├── retriever.py
│   │   │   ├── chunker.py
│   │   │   └── chat.py
│   │   └── main.py
│   ├── data/               # SQLite & uploads
│   └── requirements.txt
│
├── frontend/               # Next.js Frontend
│   ├── src/
│   │   ├── app/           # App router pages
│   │   ├── components/    # React components
│   │   └── lib/           # Utilities, API client
│   └── package.json
│
├── docs/                  # Documentation
│   └── images/            # Screenshots, GIFs
│
├── capture_screenshots.py # Automated screenshots
├── docker-compose.yml     # Docker orchestration
└── README.md             # This file

Testing

# Backend tests
cd backend
pytest tests/ -v --cov=app

# Frontend tests
cd frontend
npm test

# Run automated screenshot capture
python capture_screenshots.py

# Record demo video
python capture_screenshots.py --video

Roadmap

gantt
    title Info Naut Development Roadmap
    dateFormat  YYYY-MM
    section Core
    RAG Pipeline           :done, 2024-01, 2024-03
    Guardrails Engine      :done, 2024-02, 2024-04
    Multi-doc Search       :done, 2024-03, 2024-05
    section Enhancements
    Streaming Responses    :done, 2024-04, 2024-05
    Citation Improvements  :done, 2024-05, 2024-06
    section Future
    Multi-language Support :active, 2024-06, 2024-09
    Custom Model Support   :2024-08, 2024-11
    Enterprise Features    :2024-10, 2025-02
Loading

Contributing

# Fork and clone
git clone https://github.com/AhmedRaoofuddin/infonaut.git

# Create branch
git checkout -b feature/amazing-feature

# Make changes and test
pytest && npm test

# Commit and push
git commit -m "Add amazing feature"
git push origin feature/amazing-feature

# Open PR on GitHub

Acknowledgments

Built with open-source technologies:


FastAPI

Next.js

LangChain

ChromaDB

OpenAI

Playwright

Star this repo if you find it useful!

Report BugRequest FeatureDocumentation


Created and maintained by Ahmed Raoofuddin

Navigate Your Knowledge Universe

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors