A cutting-edge Retrieval-Augmented Generation (RAG) system that enables intelligent Q&A on your documents using state-of-the-art AI technologies
Demo • Features • Tech Stack • Getting Started • Architecture
AI Doc Chat is a modern, production-ready RAG (Retrieval-Augmented Generation) application that allows users to upload documents and ask questions about their content using advanced AI models. The system intelligently retrieves relevant document sections and generates accurate, contextual answers.
Upload PDF or TXT documents and start chatting with your data instantly:
- 📤 Drag & Drop Upload - Seamless document upload experience
- 🔍 Smart Search - Vector similarity search for precise content retrieval
- 💬 Natural Q&A - Ask questions in natural language, get intelligent answers
- ⚡ Real-time Processing - Fast document chunking and embedding generation
- 🎨 Modern UI - Beautiful glassmorphism design with smooth animations
- ✅ Document Processing - Supports PDF and TXT files with intelligent chunking
- ✅ Vector Embeddings - Utilizes Ollama's
nomic-embed-textmodel for semantic understanding - ✅ Semantic Search - Cosine similarity-based retrieval for relevant content matching
- ✅ AI-Powered Answers - Groq API with Llama 3.1 8B for natural language responses
- ✅ Multi-Document Support - Upload and query multiple documents independently
- ✅ Persistent Storage - SQLite database for document and embedding storage
- 🔐 Clean Architecture - Separation of concerns with Services, Controllers, Models, Data layers
- 🚀 High Performance - Async/await patterns throughout, optimized for scalability
- 📊 RESTful API - Well-structured endpoints with OpenAPI/Swagger documentation
- 🎨 Responsive Design - Mobile-first approach with Tailwind CSS 4.1
- ⚡ Fast Compilation - SWC for lightning-fast React builds
- 🔄 CORS Enabled - Seamless frontend-backend communication
| Technology | Version | Purpose |
|---|---|---|
| .NET | 8.0 | Latest LTS framework for high-performance web APIs |
| Entity Framework Core | 8.0 | Modern ORM with async operations and LINQ support |
| SQLite | Latest | Lightweight, embedded database for efficient storage |
| iText7 | 9.0.7 | Professional PDF processing and text extraction |
| Newtonsoft.Json | 13.0.3 | High-performance JSON serialization |
| Swagger/OpenAPI | Latest | API documentation and testing interface |
| Technology | Version | Purpose |
|---|---|---|
| React | 19.2 | Latest React with concurrent features and optimizations |
| TypeScript | 5.9 | Type-safe JavaScript for robust code quality |
| Vite | 7.2 | Next-generation frontend tooling with HMR |
| Tailwind CSS | 4.1 | Utility-first CSS framework for modern design |
| SWC | Latest | Rust-based compiler for 20x faster builds |
| ESLint | 9.39 | Code quality and consistency enforcement |
| Service | Model | Purpose |
|---|---|---|
| Ollama | nomic-embed-text | Local embedding generation for semantic search |
| Groq | llama-3.1-8b-instant | Ultra-fast LLM inference for chat responses |
| Vector Search | Cosine Similarity | Efficient similarity matching algorithm |
| RAG Pipeline | Custom | Context-aware question answering system |
┌─────────────────┐ HTTP/REST ┌──────────────────┐
│ │ ◄─────────────────► │ │
│ React Frontend │ │ ASP.NET Core │
│ (TypeScript) │ JSON/API │ API │
│ │ │ │
└─────────────────┘ └──────────────────┘
│
▼
┌─────────────────────────────────────┐
│ │
│ Application Services │
│ ┌──────────────────────────────┐ │
│ │ DocumentService │ │
│ │ - PDF/TXT Processing │ │
│ │ - Chunking Strategy │ │
│ └──────────────────────────────┘ │
│ ┌──────────────────────────────┐ │
│ │ EmbeddingService │ │
│ │ - Ollama Integration │ │
│ │ - Vector Generation │ │
│ │ - Similarity Search │ │
│ └──────────────────────────────┘ │
│ ┌──────────────────────────────┐ │
│ │ ChatService │ │
│ │ - RAG Pipeline │ │
│ │ - Groq API Integration │ │
│ │ - Context Building │ │
│ └──────────────────────────────┘ │
│ │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ │
│ Entity Framework Core + SQLite │
│ │
│ Documents Table │
│ DocumentChunks Table │
│ (with Vector Embeddings) │
│ │
└─────────────────────────────────────┘
-
Document Ingestion
- User uploads PDF/TXT file
- Document is extracted and split into semantic chunks
- Each chunk is sent to Ollama for embedding generation
- Chunks and embeddings stored in SQLite database
-
Question Processing
- User query is converted to embedding vector
- Cosine similarity calculated against all document chunks
- Top-K most relevant chunks retrieved
-
Answer Generation
- Retrieved chunks assembled into context
- Context + question sent to Groq's Llama 3.1 model
- AI generates contextual, accurate response
- Response delivered to user in real-time
- .NET SDK 8.0+ - Backend runtime
- Node.js 18+ - Frontend development
- Ollama - Local AI model runtime
- Groq API Key - Free LLM access
git clone https://github.com/yourusername/AiChatRagSystem.git
cd AiChatRagSystem# Install Ollama (if not already installed)
# Visit https://ollama.ai/ for installation instructions
# Pull the embedding model
ollama pull nomic-embed-text
# Start Ollama service (runs on http://localhost:11434)
ollama servecd AiDocChat.Api
# Update appsettings.json with your Groq API key
# Get free API key from: https://console.groq.com/keysappsettings.json:
{
"Groq": {
"ApiKey": "your-groq-api-key-here"
},
"Ollama": {
"BaseUrl": "http://localhost:11434"
}
}# Restore dependencies and run
dotnet restore
dotnet run
# API will be available at: http://localhost:5261
# Swagger UI: http://localhost:5261/swaggercd ../frontend
# Install dependencies
npm install
# Start development server
npm run dev
# Frontend will be available at: http://localhost:5173- Open http://localhost:5173 in your browser
- Upload a PDF or TXT document
- Select the document from the list
- Ask questions about the document content
- Receive AI-generated answers based on document context
AiChatRagSystem/
├── AiDocChat.Api/ # Backend ASP.NET Core API
│ ├── Controllers/ # REST API endpoints
│ │ ├── ChatController.cs # Chat Q&A endpoints
│ │ └── DocumentsController.cs # Document management
│ ├── Services/ # Business logic layer
│ │ ├── ChatService.cs # RAG + LLM integration
│ │ ├── DocumentService.cs # PDF/TXT processing
│ │ └── EmbeddingService.cs # Vector embeddings
│ ├── Models/ # Domain models
│ │ └── Document.cs # Document entity
│ ├── Data/ # Database context
│ │ └── AppDbContext.cs # EF Core DbContext
│ ├── Program.cs # Application entry point
│ └── appsettings.json # Configuration
│
├── frontend/ # React + TypeScript frontend
│ ├── src/
│ │ ├── App.tsx # Main application component
│ │ ├── main.tsx # React entry point
│ │ └── index.css # Tailwind base styles
│ ├── package.json # NPM dependencies
│ ├── vite.config.ts # Vite configuration
│ ├── tsconfig.json # TypeScript configuration
│ └── tailwind.config.js # Tailwind setup
│
└── README.md # This file
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/documents |
List all uploaded documents |
POST |
/api/documents/upload |
Upload and process new document |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/chat/ask |
Ask question about document |
Example Request:
POST /api/chat/ask
{
"documentId": "abc123",
"question": "What is the main topic of this document?"
}Example Response:
{
"success": true,
"answer": "The main topic discusses artificial intelligence..."
}- Glassmorphism Design - Modern frosted glass aesthetic
- Gradient Animations - Smooth color transitions
- Responsive Layout - Works on all device sizes
- Loading States - Clear feedback for async operations
- Error Handling - User-friendly error messages
- Drag & Drop - Intuitive file upload
- Dark Theme - Eye-friendly dark color scheme
- ✅ CORS configured for secure cross-origin requests
- ✅ API keys stored in configuration (not in code)
- ✅ Input validation on all endpoints
- ✅ Error handling without exposing sensitive info
⚠️ Production Note: Add authentication/authorization before deployment
- Async Operations - All I/O operations are async for better concurrency
- Connection Pooling - HTTP client factory for efficient connections
- Chunking Strategy - Optimal chunk size for embeddings
- Similarity Caching - Efficient vector comparison algorithms
- SWC Compiler - 20x faster than Babel for React builds
- Vite HMR - Instant hot module replacement during development
Documents are split into semantic chunks to maintain context while enabling efficient retrieval.
Each chunk is converted to a 768-dimensional vector using Ollama's nomic-embed-text model, capturing semantic meaning.
similarity = (A · B) / (||A|| × ||B||)Measures semantic similarity between query and document chunks.
Combines semantic search with LLM generation for accurate, contextual answers grounded in document content.
Contributions are welcome! Areas for improvement:
- Add support for more document formats (DOCX, PPTX)
- Implement chat history
- Add user authentication
- Deploy vector database (Qdrant, Pinecone)
- Add streaming responses
- Implement multi-language support
- Add document comparison features
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: @yourusername
- LinkedIn: Your LinkedIn
- Portfolio: yourportfolio.com
- Ollama - For providing free local AI inference
- Groq - For ultra-fast LLM API access
- Microsoft - For the excellent .NET platform
- React Team - For the amazing React 19 features
- Tailwind Labs - For the utility-first CSS framework
- Backend Lines of Code: ~1,500+
- Frontend Lines of Code: ~400+
- Technologies Used: 15+
- API Endpoints: 3
- Response Time: < 2 seconds (average)
- Supported Documents: PDF, TXT
⭐ If you find this project useful, please consider giving it a star! ⭐
Made with ❤️ using cutting-edge technologies
