Skip to content

ramprasanth0/Insight-Engine

Repository files navigation

🧠 Insight Engine

Insight Engine is a high-performance RAG (Retrieval-Augmented Generation) application built to chat with documentation. It utilizes an "Offline Ingestion, Online Retrieval" architecture to provide accurate, context-aware answers while minimizing hallucinations.


πŸ‘€ Preview

Demo

Dark Mode

Landing Chat
Dark Landing Dark Chat

Light Mode

Landing Chat
Light Landing Light Chat

πŸš€ Key Features

🎨 UI & Experience

  • Dark/Light Theme Toggle - Switch themes with the toggle in the top-right corner
  • Sound Toggle - Mute/unmute UI sounds (future feature)
  • Premium Aesthetic - Cyberpunk-inspired design with dynamic glow effects
  • Dot-Matrix Typography - Custom "Digital Decoding" title animation
  • Responsive Layout - Centered initial view, transitioning to chat-history on interaction
  • Interactive Components - Built with shadcn/ui for accessible, smooth interactions

πŸ” Search Controls

  • Namespace Selection - Filter by Next.js or React.js documentation
  • Web Search Toggle - Enable Tavily web search for broader context

πŸ€– Intelligent Core

  • Agentic Tool Calling - Autonomous decision making with Google's mcpToTool integration
  • Robust Failover - Automatic retry logic handling rate limits (switches models on 429 errors)
  • Smart Ingestion - Recursive globbing to discover documentation
  • Context-Aware Splitting - LangChain recursive splitters for semantic integrity
  • Parallel Processing - Batch & Throttle system respecting Gemini Free Tier limits
  • Semantic Search - Pinecone serverless vectors with Cosine Similarity

πŸ—οΈ Architecture

The system uses a Hybrid Agentic Architecture combining offline vectorization with an online autonomous agent.

graph TD
    subgraph "Offline: Ingestion Engine"
        Docs[Markdown Docs] -->|Glob| Splitter[Recursive Splitter]
        Splitter -->|Chunks| Embed[Gemini Embeddings]
        Embed -->|Vectors| PineconeDB[(Pinecone Vector DB)]
    end

    subgraph "Online: Query Engine"
        User[User Query] -->|POST /api/chat| Agent[Gemini Agent]
        
        %% RAG Flow
        Agent -->|1. Retrieve| PineconeDB
        PineconeDB -->|Context| Agent
        
        %% Agentic Flow
        Agent -->|2. Decide| Decision{Need Web Info?}
        Decision -->|Yes| MCP[MCP Client]
        MCP -->|Call Tool| Tavily[Tavily Search API]
        Tavily -->|Results| MCP
        MCP -->|Context| Agent
        Decision -- No --> Answer
        
        %% Response
        Agent -->|3. Synthesize| Answer[Final Response]
        Answer -->|Stream| User
    end
    
    style Agent fill:#8e2de2,stroke:#333,stroke-width:2px,color:#fff
    style MCP fill:#f953c6,stroke:#333,stroke-width:2px,color:#fff
    style PineconeDB fill:#00b09b,stroke:#333,color:#fff
Loading

πŸ› οΈ Tech Stack

Category Technology
Framework Next.js 16 (App Router)
Styling Tailwind CSS v4, shadcn/ui, lucide-react
Language TypeScript (Strict Mode)
AI Models Gemini 2.0-flash (Agentic), text-embedding-004 (Embeddings)
Vector DB Pinecone (Serverless)
Web Search Tavily API (via MCP)
Agent Tools @modelcontextprotocol/sdk, Google GenAI mcpToTool
Utilities dotenv, glob, @langchain/textsplitters

πŸ“‚ Project Structure

β”œβ”€β”€ src
β”‚   β”œβ”€β”€ app              # Next.js App Router pages
β”‚   β”œβ”€β”€ components       # UI Components (shadcn/ui + custom)
β”‚   β”‚   β”œβ”€β”€ top-controls.tsx      # Theme & mute toggles
β”‚   β”‚   β”œβ”€β”€ namespace-buttons.tsx # Doc namespace selection
β”‚   β”‚   β”œβ”€β”€ web-search-toggle.tsx # Web search toggle
β”‚   β”‚   β”œβ”€β”€ chat-box.tsx          # Chat message display
β”‚   β”‚   └── chat-input.tsx        # Input with send button
β”‚   β”œβ”€β”€ hooks            # Custom React hooks
β”‚   β”‚   └── use-title-animation.ts # Digital decoding effect
β”‚   └── lib              # Utility functions & API clients
β”œβ”€β”€ scripts
β”‚   β”œβ”€β”€ ingest.ts        # Documentation ingestion pipeline
β”‚   └── test-chat.ts     # CLI script for testing chat API
β”œβ”€β”€ public
β”‚   └── screenshots      # Preview images & demo
└── docs                 # Place your .md/.mdx documentation here

βš™οΈ Setup & Installation

1. Clone & Install

git clone https://github.com/your-username/insight-engine.git
cd insight-engine
npm install

2. Environment Secrets

Create a .env.local file in the root:

# Google AI Studio (Gemini)
GEMINI_API_KEY=AIzaSy...

# Pinecone Vector DB
PINECONE_API_KEY=pcsk_...

# Tavily Web Search (optional)
TAVILY_API_KEY=tvly-...

3. Prepare Data

Place your .md or .mdx files inside a docs/ folder at the root.


πŸƒβ€β™‚οΈ How to Run

Ingestion (Offline)

Hydrate your vector database with your documentation.

npx tsx scripts/ingest.ts

Development Server (Online)

Start the web application.

npm run dev

Visit http://localhost:3000 to interact with Insight Engine.

Testing

To test the chat API directly without the UI:

npx tsx scripts/test-chat.ts

πŸ’¬ RAG Pipeline

Agentic RAG Process:

  1. Vectorization - User input is embedded (text-embedding-004)
  2. Retrieval - Queries Pinecone namespaces for documentation context
  3. Agentic Loop - Gemini analyzes context and decides if web search is needed
  4. Tool Execution - If needed, calls tavily_search via MCP to fetch real-time info
  5. Synthesis - Combines docs + web info to generate grounded answer
  6. Streaming - Response is streamed token-by-token to the UI

RAG Pipeline


πŸŽ›οΈ Controls

Control Description
πŸŒ™ Theme Toggle Switch between dark and light mode
πŸ”Š Mute Toggle Mute/unmute UI sounds (placeholder)
🌐 Web Search Enable Tavily web search for queries
πŸ“š Namespace Buttons Filter by Next.js or React.js docs

πŸ“ License

MIT License - see LICENSE for details.

About

An intelligent research buddy that chats with your docs and connects to the web. Built with Next.js, Gemini, and Pinecone.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors