https://github.com/cyprianfusi/advanced-rag-chat-app
A production-ready, full-stack Retrieval-Augmented Generation (RAG) application that enables intelligent conversations with your documents using advanced AI models. Upload files, ask natural language questions, and receive real-time, AI-generated responses complete with clear source attributions.
https://github.com/cyprianfusi/advanced-rag-chat-app
fastapi langchain llms nodejs pgvector postgresql rag rag-chatbot react
Last synced: about 2 months ago
JSON representation
A production-ready, full-stack Retrieval-Augmented Generation (RAG) application that enables intelligent conversations with your documents using advanced AI models. Upload files, ask natural language questions, and receive real-time, AI-generated responses complete with clear source attributions.
- Host: GitHub
- URL: https://github.com/cyprianfusi/advanced-rag-chat-app
- Owner: CyprianFusi
- Created: 2025-08-13T17:30:22.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-23T03:56:27.000Z (about 2 months ago)
- Last Synced: 2025-08-24T07:21:44.489Z (about 2 months ago)
- Topics: fastapi, langchain, llms, nodejs, pgvector, postgresql, rag, rag-chatbot, react
- Language: TypeScript
- Homepage:
- Size: 5.05 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Binati AInalytics
# Advanced Multi-Files RAG Chat App
_By **BINATI AInalytics**_
---
## 🚀 Advanced Multi-Files RAG Chat Application
[](https://www.python.org/downloads/)
[](https://fastapi.tiangolo.com/)
[](https://reactjs.org/)
[](https://langchain.com/)
[](https://www.postgresql.org/)
[](LICENSE)> A production-ready, full-stack Retrieval-Augmented Generation (RAG) application that enables intelligent conversations with your documents using advanced AI models.
> Upload files, ask natural language questions, and receive real-time, AI-generated responses complete with clear source attributions.# Demo


## ✨ Features
### 🎯 Core Functionality
- **Multi-Document Support** - Upload and process PDF, DOCX, TXT, CSV, and more
- **Real-time Streaming** - Smooth, typewriter-effect responses
- **Intelligent Context Management** - Handles conversation history and pronouns
- **Source Attribution** - Always shows which documents provided the answers
- **Session Management** - Persistent chat sessions with full history### 🔧 Technical Excellence
- **Multiple LLM Providers** - OpenAI, Anthropic, Google, Cohere, Hugging Face
- **Vector Database** - PostgreSQL with pgvector for semantic search
- **Semantic Chunking** - Advanced document splitting for better retrieval
- **Context Length Management** - Automatic token limit handling
- **Production Architecture** - Scalable, maintainable, and robust### 🎨 User Experience
- **Modern UI** - Clean, responsive React interface
- **File Management** - Easy upload, process, and delete documents
- **Real-time Feedback** - Processing status and error handling
- **Mobile Friendly** - Works seamlessly on all devices## 🏗️ Architecture
```mermaid
graph TB
A[React Frontend] --> B[FastAPI Backend]
B --> C[RAG Service]
C --> D[Vector Store
PostgreSQL + pgvector]
C --> E[LLM Factory
Multi-provider support]
B --> F[Document Processor]
F --> G[Multi-format Loaders]
B --> H[Chat Memory
PostgreSQL]
style A fill:#61DAFB
style B fill:#009688
style C fill:#FF6B6B
style D fill:#336791
style E fill:#9C27B0
```## 🚀 Quick Start
### Prerequisites
- Python 3.8+
- Node.js 16+
- PostgreSQL 14+ with pgvector extension
- OpenRouter API key (or other LLM provider)### 1. Clone the Repository
```bash
git clone https://github.com/CyprianFusi/advanced-rag-chat-app.git
cd advanced-rag-chat-app
```### 2. Backend Setup
```bash
cd backend# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate# Install dependencies
pip install -r requirements.txt# Set up environment variables
cp .env.example .env
# Edit .env with your database credentials and API keys
```### 3. Database Setup
```sql
-- Connect to PostgreSQL and run:
CREATE DATABASE rag_documents;
CREATE DATABASE rag_memory;-- Enable pgvector extension
\c rag_documents;
CREATE EXTENSION vector;\c rag_memory;
CREATE EXTENSION vector;
```### 4. Frontend Setup
```bash
cd ../frontend# Install dependencies
npm install# Start development server
npm start
```### 5. Start the Backend
```bash
cd ../backend
uvicorn app.server:app --reload
```### 6. Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs## 📋 Configuration
### Environment Variables
Create a `.env` file in the backend directory:
```env
# Database Configuration
PGVECTOR_CONNECTION_STRING=postgresql://user:password@localhost:5432/rag_documents
POSTGRES_MEMORY_URL=postgresql://user:password@localhost:5432/rag_memory# API Keys (choose your preferred provider)
OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here# Application Settings
DOCUMENTS_DIRECTORY=./documents
MAX_FILE_SIZE=52428800 # 50MB
DEBUG=False
LOG_LEVEL=INFO# CORS Settings
CORS_ORIGINS=["http://localhost:3000"]
```### Supported File Formats
- **Documents**: PDF, DOCX, DOC, TXT, RTF, ODT
- **Data**: CSV, XLSX, XLS
- **Web**: HTML, XML
- **Other**: MD (Markdown), PPT, PPTX## 🔧 Usage
### 1. Upload Documents
- Click "Choose Files" to select your documents
- Click "Upload" to store them on the server
- Click "Process" to extract text and create embeddings### 2. Start Chatting
- Type questions about your uploaded documents
- Get intelligent, contextually-aware responses
- Sources are automatically cited### 3. Advanced Features
- **Conversation Context**: Ask follow-up questions using pronouns
- **Multi-Document Queries**: Questions spanning multiple documents
- **Session Management**: Your chat history persists across sessions## 🎯 Example Interactions
```
👤 User: "What is this document about?"
🤖 Assistant: "Based on the uploaded document 'annual_report.pdf', this appears to be a comprehensive annual report covering financial performance, operational highlights, and strategic initiatives for fiscal year 2023..."👤 User: "What were the key financial metrics?"
🤖 Assistant: "From the annual report, the key financial metrics include:
- Revenue: $2.4B (15% growth)
- Net Income: $340M (22% growth)
- EBITDA: $580M (18% growth)
Sources: annual_report.pdf"
```## 🏭 Production Deployment
### Docker Deployment
```bash
# Build and run with Docker Compose
docker-compose up -d
```### Manual Deployment
1. **Database**: Set up PostgreSQL with pgvector
2. **Backend**: Deploy FastAPI with gunicorn
3. **Frontend**: Build and serve with nginx
4. **Environment**: Configure production environment variables
5. **Monitoring**: Set up logging and health checks### Environment-Specific Settings
```python
# Production settings in config.py
DEBUG = False
CORS_ORIGINS = ["https://yourdomain.com"]
MAX_REQUESTS_PER_MINUTE = 100
LOG_LEVEL = "WARNING"
```## 📊 Performance
- **Response Time**: < 2 seconds for most queries
- **Concurrent Users**: Supports 100+ simultaneous users
- **Document Processing**: ~1MB per second
- **Vector Search**: Sub-second retrieval from 10K+ documents## 🙏 Acknowledgments
- **LangChain** - For the excellent RAG framework
- **FastAPI** - For the high-performance web framework
- **PostgreSQL & pgvector** - For robust vector storage
- **React** - For the dynamic frontend experience
- **OpenRouter** - For multi-provider LLM access## 📞 Support
- **Documentation**: [docs/](docs/)
- **Issues**: [GitHub Issues](https://github.com/yourusername/advanced-rag-chat-app/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/advanced-rag-chat-app/discussions)
- **Email**: cyprian.fusi@gmail.com---
**⭐ Star this repo if it helped you!**
Made with ❤️ by [Cyprian Fusi](https://github.com/CyprianFusi)
[🌟 Star](https://github.com/CyprianFusi/advanced-rag-chat-app/stargazers) • [🍴 Fork](https://github.com/CyprianFusi/advanced-rag-chat-app/fork) • [📋 Issues](https://github.com/CyprianFusi/advanced-rag-chat-app/issues) • [💬 Discussions](https://github.com/CyprianFusi/advanced-rag-chat-app/discussions)