๐ A production-grade AI Knowledge Assistant โ Upload company documents, generate intelligent embeddings, and get contextual AI-powered answers. Think ChatGPT, but trained exclusively on your documents.
| Section | Link |
|---|---|
| ๐ Features | View Features |
| ๐๏ธ Architecture | View Architecture |
| โก Quick Start | Get Started |
| ๐ API Reference | View API |
| ๐ Project Structure | View Structure |
| ๐ ๏ธ Tech Stack | View Stack |
| ๐ Deployment | Deploy |
| ๐ค Contributing | Contribute |
|
NEXEAGENT RAG Knowledge Assistant is a full-stack, production-style AI application that transforms static company documents into a dynamic, conversational knowledge base. Built on the Retrieval-Augmented Generation (RAG) paradigm, it combines the power of Google Gemini AI with a ChromaDB vector database to deliver precise, document-grounded answers โ no hallucinations, no guesswork. Think of it as ChatGPT, but trained on your company's internal knowledge โ policies, manuals, reports, and more. Developed as part of the AI & Automation Internship at NEXE.AGENT |
|
| ๐๏ธ Document Management | ๐ค AI Intelligence | ๐ป Developer Experience |
|---|---|---|
| PDF, TXT, DOCX upload | Google Gemini 2.0 Flash | FastAPI + Swagger docs |
| Drag & drop interface | Context-aware answers | Hot reload dev server |
| Document indexing | Streaming AI responses | Clean REST API design |
| View & delete docs | No hallucinations | Pytest test suite |
| Metadata tracking | Source attribution | Modular architecture |
๐ค Intelligent Document Upload System
- Multi-format support: PDF, TXT, DOCX with automatic format detection
- Drag & Drop UI: Modern React-based file upload with progress indicators
- Validation: File type and size validation before processing
- Persistent storage: Files stored locally with JSON metadata tracking
- Batch processing: Upload and process multiple documents simultaneously
๐งฎ Advanced RAG Pipeline
- Smart chunking: Configurable chunk sizes (default: 800 tokens) with overlap (150 tokens)
- Gemini Embeddings: Uses
models/text-embedding-004for high-quality vector representations - ChromaDB storage: Persistent vector store with fast similarity search
- TOP-K Retrieval: Configurable result count for optimal context assembly
- Context assembly: Intelligent merging of retrieved chunks for coherent prompting
๐ฌ AI Chat Interface
- Session-based history: Persistent chat conversations per session
- Context injection: Retrieved document chunks automatically injected into prompts
- Streaming responses: Real-time token streaming for responsive UX
- Source transparency: Answers cite which documents were used
- Fallback handling: Graceful responses when no relevant documents found
๐ Modern Dashboard
- React + Vite: Lightning-fast development and build times
- Tailwind CSS: Utility-first styling with dark mode support
- Framer Motion: Smooth animations and page transitions
- Responsive layout: Works on desktop, tablet, and mobile
- Real-time stats: Document count, index status, query metrics
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ NEXEAGENT SYSTEM ARCHITECTURE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ REACT FRONTEND โ โโโโโโโบ โ FASTAPI BACKEND โ โ
โ โ โ HTTP โ โ โ
โ โ โข Upload Page โ โโโโโโโ โ โข /api/upload โ โ
โ โ โข Chat Interface โ REST โ โข /api/documents โ โ
โ โ โข Documents Page โ โ โข /api/chat โ โ
โ โ โข Settings Page โ โ โข /api/health โ โ
โ โ โข Dashboard/Home โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโผโโโโโโโ โโโโโโโโโโผโโโโโโโโ โโโโโโโโผโโโโ โ
โ โ RAG SERVICE โ โ GEMINI SERVICE โ โ VECTOR โ โ
โ โ โ โ โ โ STORE โ โ
โ โ โข Chunking โ โ โข Embeddings โ โ โ โ
โ โ โข Pipeline โ โ โข Chat/LLM โ โ ChromaDB โ โ
โ โ โข Context โ โ โข Streaming โ โ SQLite โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ DATA LAYER โ โ
โ โ ๐ data/uploads/ โ ๐๏ธ data/chroma/ โ ๐ data/metadata/ โ โ
โ โ ๐ data/chat_history/ โ ๐ data/logs/ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
INGESTION PHASE
โโโโโโโโโโโโโโโ
๐ Raw Document
โ
โผ
๐ Text Extraction (PDF/DOCX/TXT parsers)
โ
โผ
โ๏ธ Smart Chunking โโโโ chunk_size: 800 tokens
โ chunk_overlap: 150 tokens
โผ
๐งฎ Gemini Embedding Generation (text-embedding-004)
โ
โผ
๐๏ธ ChromaDB Vector Storage โโโโ Persistent SQLite backend
QUERY PHASE
โโโโโโโโโโโ
๐ฌ User Query
โ
โผ
๐งฎ Query Embedding Generation
โ
โผ
๐ Cosine Similarity Search (TOP-K=5)
โ
โผ
๐ Context Assembly (retrieved chunks)
โ
โผ
๐ค Gemini LLM โโโโ System prompt + Context + Query
โ
โผ
โ
Grounded, Accurate Answer
nexeagent-rag-knowledge-assistant/
โ
โโโ ๐ README.md # You are here
โโโ ๐ API.md # Full API documentation
โโโ ๐ .env # Root env (optional)
โ
โโโ ๐ backend/
โ โโโ ๐ run.py # Entry point โ starts Uvicorn server
โ โโโ ๐ requirements.txt # Python dependencies
โ โโโ ๐ pytest.ini # Test configuration
โ โโโ ๐ .env # Backend environment variables
โ โ
โ โโโ ๐ฆ app/
โ โ โโโ ๐ main.py # FastAPI app initialization + CORS
โ โ โโโ ๐ config.py # Settings loader (env vars)
โ โ โ
โ โ โโโ ๐ api/
โ โ โ โโโ routes/
โ โ โ โโโ ๐ chat.py # POST /api/chat endpoint
โ โ โ โโโ ๐ documents.py # GET/DELETE /api/documents
โ โ โ โโโ ๐ upload.py # POST /api/upload endpoint
โ โ โ โโโ ๐ health.py # GET /api/health
โ โ โ
โ โ โโโ ๐ง services/
โ โ โ โโโ ๐ rag_service.py # Core RAG orchestration
โ โ โ โโโ ๐ gemini_service.py # Google Gemini API client
โ โ โ โโโ ๐ embedding_service.py # Embedding generation
โ โ โ โโโ ๐ vector_store_service.py# ChromaDB operations
โ โ โ โโโ ๐ retrieval_service.py # Similarity search logic
โ โ โ โโโ ๐ query_service.py # Query processing pipeline
โ โ โ โโโ ๐ pdf_service.py # Document text extraction
โ โ โ
โ โ โโโ ๐ models/
โ โ โ โโโ ๐ schemas.py # Pydantic request/response models
โ โ โ
โ โ โโโ ๐ ๏ธ utils/
โ โ โโโ ๐ chunking.py # Text chunking strategies
โ โ โโโ ๐ file_utils.py # File I/O helpers
โ โ โโโ ๐ logger.py # Structured logging setup
โ โ
โ โโโ ๐ฆ data/
โ โ โโโ ๐ uploads/ # Raw uploaded documents
โ โ โโโ ๐๏ธ chroma/ # ChromaDB vector store files
โ โ โ โโโ chroma.sqlite3
โ โ โโโ ๐ metadata/ # Document metadata (JSON)
โ โ โโโ ๐ฌ chat_history/ # Saved chat sessions (JSON)
โ โ
โ โโโ ๐ logs/ # Application logs
โ โโโ ๐ sample_docs/
โ โ โโโ company_policy.txt # Sample document for testing
โ โโโ ๐งช tests/
โ โโโ test_api.py # API endpoint tests
โ โโโ test_chunking.py # Chunking logic tests
โ
โโโ โ๏ธ frontend/
โโโ ๐ index.html # Root HTML template
โโโ ๐ package.json # Node.js dependencies
โโโ ๐ vite.config.js # Vite build configuration
โโโ ๐ tailwind.config.js # Tailwind CSS configuration
โโโ ๐ postcss.config.js # PostCSS configuration
โ
โโโ ๐ฆ src/
โโโ ๐ App.jsx # Root React component + routing
โโโ ๐ main.jsx # React DOM entry point
โโโ ๐ index.css # Global styles + Tailwind imports
โ
โโโ ๐งฉ components/
โ โโโ ChatMessage.jsx # Individual chat bubble component
โ โโโ FileUpload.jsx # Drag & drop upload component
โ โโโ Layout.jsx # App shell with sidebar
โ โโโ LoadingSpinner.jsx # Animated loading indicator
โ โโโ Sidebar.jsx # Navigation sidebar
โ โโโ StatCard.jsx # Dashboard stat display card
โ โโโ TypingIndicator.jsx # AI "thinking" animation
โ
โโโ ๐ context/
โ โโโ ThemeContext.jsx # Dark/light mode context
โ
โโโ ๐ pages/
โ โโโ Home.jsx # Dashboard with stats overview
โ โโโ Chat.jsx # Main AI chat interface
โ โโโ Documents.jsx # Document library & management
โ โโโ Upload.jsx # File upload workflow page
โ โโโ Settings.jsx # App configuration page
โ
โโโ ๐ services/
โโโ api.js # Axios API client + all endpoints
Before you begin, ensure you have:
| Requirement | Version | Download |
|---|---|---|
| Python | 3.11+ | python.org |
| Node.js | 18+ | nodejs.org |
| Google Gemini API Key | โ | aistudio.google.com |
| Git | Latest | git-scm.com |
git clone https://github.com/YOUR_USERNAME/nexeagent-rag-knowledge-assistant.git
cd nexeagent-rag-knowledge-assistant# Navigate to backend cd backend # Create virtual environment python -m venv venv # Activate virtual environment # Windows: venv\Scripts\activate # macOS / Linux: source venv/bin/activate # Install dependencies pip install -r requirements.txt # Configure environment copy .env.example .env # Windows # cp .env.example .env # macOS/Linux
Edit backend/.env with your API key:
# โโ Google Gemini โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ GEMINI_API_KEY=your_actual_gemini_api_key_here GEMINI_MODEL=gemini-2.0-flash GEMINI_EMBEDDING_MODEL=models/text-embedding-004 # โโ RAG Configuration โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ CHUNK_SIZE=800 CHUNK_OVERLAP=150 TOP_K_RESULTS=5 # โโ Server โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ HOST=0.0.0.0 PORT=8000 DEBUG=false
Start the backend server:
python run.py
โ API running at http://localhost:8000
๐ Swagger docs at http://localhost:8000/docs
๐ ReDoc at http://localhost:8000/redoc
Open a new terminal:
# Navigate to frontend cd frontend # Install dependencies npm install # Start dev server npm run dev
โ Frontend running at http://localhost:5173
1. Open http://localhost:5173
2. Navigate to โ Upload
3. Upload the sample file: backend/sample_docs/company_policy.txt
4. Wait for indexing to complete โ
5. Navigate to โ Chat
6. Ask: "What is the refund policy?"
7. Receive a grounded AI answer from your document ๐
| Variable | Description | Default | Required |
|---|---|---|---|
GEMINI_API_KEY |
Google Gemini API authentication key | โ | โ Yes |
GEMINI_MODEL |
Chat/generation model ID | gemini-2.0-flash |
โ Yes |
GEMINI_EMBEDDING_MODEL |
Embedding model ID | models/text-embedding-004 |
โ Yes |
CHUNK_SIZE |
Token count per text chunk | 800 |
โ No |
CHUNK_OVERLAP |
Overlap tokens between chunks | 150 |
โ No |
TOP_K_RESULTS |
Number of chunks retrieved per query | 5 |
โ No |
HOST |
Backend server host | 0.0.0.0 |
โ No |
PORT |
Backend server port | 8000 |
โ No |
DEBUG |
Enable debug mode | false |
โ No |
http://localhost:8000
Check if the API is alive.
Response:
{
"status": "healthy",
"version": "1.0.0",
"timestamp": "2024-01-15T10:30:00Z"
}Upload and index a document into the RAG pipeline.
Request: multipart/form-data
| Field | Type | Description |
|---|---|---|
file |
File | PDF, TXT, or DOCX file |
Response:
{
"success": true,
"document_id": "doc_abc123",
"filename": "company_policy.txt",
"chunks_created": 14,
"message": "Document indexed successfully"
}Send a message and receive an AI-generated, document-grounded response.
Request Body:
{
"message": "What is the refund policy?",
"session_id": "session_xyz789",
"stream": false
}Response:
{
"answer": "According to the company policy document, refunds are processed within 7-10 business days...",
"sources": ["company_policy.txt"],
"session_id": "session_xyz789",
"tokens_used": 342
}Retrieve a list of all indexed documents.
Response:
{
"documents": [
{
"id": "doc_abc123",
"filename": "company_policy.txt",
"size_bytes": 24310,
"chunks": 14,
"uploaded_at": "2024-01-15T10:00:00Z",
"status": "indexed"
}
],
"total": 1
}Remove a document and its vectors from the knowledge base.
Response:
{
"success": true,
"message": "Document doc_abc123 deleted successfully"
}Retrieve metadata for a specific document.
Response:
{
"id": "doc_abc123",
"filename": "company_policy.txt",
"chunks": 14,
"status": "indexed",
"uploaded_at": "2024-01-15T10:00:00Z"
}| Technology | Version | Purpose |
|---|---|---|
| โ๏ธ React.js | 18+ | UI component framework |
| โก Vite | 5+ | Build tool & dev server |
| ๐จ Tailwind CSS | 3.x | Utility-first styling |
| ๐ญ Framer Motion | 11+ | Animations & transitions |
| ๐ Axios | 1.x | HTTP client for API calls |
| ๐ฏ Lucide React | Latest | Icon library |
| Technology | Version | Purpose |
|---|---|---|
| ๐ Python | 3.11+ | Core runtime language |
| ๐ FastAPI | 0.110+ | Async REST API framework |
| ๐ฆ Uvicorn | Latest | ASGI server |
| ๐ Pydantic | 2.x | Data validation & schemas |
| Technology | Version | Purpose |
|---|---|---|
| ๐ค Google Gemini | 2.0 Flash | LLM for chat responses |
| ๐งฎ Gemini Embeddings | text-embedding-004 | Vector generation |
| ๐๏ธ ChromaDB | Latest | Vector database |
| Technology | Purpose |
|---|---|
| ๐ Local Filesystem | Raw document storage |
| ๐๏ธ SQLite | ChromaDB backend |
| ๐ JSON | Metadata & chat history |
| Page | Route | Description |
|---|---|---|
| ๐ Home / Dashboard | / |
System stats, quick actions, overview |
| ๐ฌ Chat | /chat |
AI conversation interface with history |
| ๐ค Upload | /upload |
Drag & drop document upload |
| ๐ Documents | /documents |
Document library, index status, delete |
| โ๏ธ Settings | /settings |
API keys, model config, preferences |
# Navigate to backend cd backend # Activate virtual environment venv\Scripts\activate # Windows source venv/bin/activate # macOS/Linux # Run all tests pytest tests/ -v # Run specific test file pytest tests/test_api.py -v pytest tests/test_chunking.py -v # Run with coverage report pytest tests/ -v --cov=app --cov-report=html
Test Coverage:
| Test File | Tests | Coverage |
|---|---|---|
test_api.py |
API endpoint validation | Upload, Chat, Documents, Health routes |
test_chunking.py |
Text processing logic | Chunking strategies, overlap, edge cases |
๐ก Add your screenshots here after running the project locally.
| Dashboard | Chat Interface |
|---|---|
[dashboard-screenshot.png] |
[chat-screenshot.png] |
| Document Upload | Document Library |
|---|---|
[upload-screenshot.png] |
[documents-screenshot.png] |
Create a docker-compose.yml:
version: '3.8' services: backend: build: ./backend ports: - "8000:8000" env_file: - ./backend/.env volumes: - ./backend/data:/app/data frontend: build: ./frontend ports: - "80:80" depends_on: - backend
docker-compose up --build
| Platform | Backend | Frontend |
|---|---|---|
| Railway | โ Python/FastAPI | โ Static |
| Render | โ Python service | โ Static site |
| Vercel | โ (use separate) | โ Best for React |
| Fly.io | โ Docker support | โ Docker support |
| AWS EC2 | โ Full control | โ Full control |
# Frontend production build cd frontend npm run build # Output in: frontend/dist/ # Backend production start cd backend uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
โ ๏ธ Important security considerations for production deployment:
- ๐ Never commit
.envfiles to version control โ use.gitignore - ๐ก๏ธ CORS Configuration โ Restrict
allow_originsto your actual frontend domain in production - ๐ API Key Rotation โ Regularly rotate your Gemini API key
- ๐ File Size Limits โ Configure upload limits to prevent resource exhaustion
- ๐ซ Rate Limiting โ Add rate limiting to chat and upload endpoints
- ๐๏ธ File Type Validation โ Only allow PDF, TXT, DOCX; reject executable files
- ๐ Auth Layer โ Add JWT authentication before exposing to public internet
Planned Roadmap
โโโโโโโโโโโโโโโ
Phase 2 โ Enhanced Intelligence
โก Multi-document cross-referencing
โก Streaming responses with SSE
โก Source highlighting in responses
โก Confidence scores for answers
Phase 3 โ Enterprise Features
โก User authentication (JWT)
โก Role-based access control
โก Multi-tenant document namespacing
โก Audit logging for compliance
Phase 4 โ Scale & Performance
โก Redis for chat session caching
โก Celery for async document processing
โก PostgreSQL for metadata (replace JSON)
โก S3-compatible cloud document storage
Phase 5 โ Advanced AI
โก Model switching (OpenAI, Anthropic, local LLMs)
โก Fine-tuned domain-specific embeddings
โก Document summarization pipeline
โก Automated knowledge graph extraction
Contributions are welcome! Follow these steps:
# 1. Fork the repository on GitHub # 2. Clone your fork git clone https://github.com/YasirAwan4831/nexeagent-rag-knowledge-assistant.git # 3. Create a feature branch git checkout -b feature/amazing-feature # 4. Make your changes and commit git add . git commit -m "feat: add amazing feature" # 5. Push to your fork git push origin feature/amazing-feature # 6. Open a Pull Request on GitHub
feat: New feature
fix: Bug fix
docs: Documentation update
style: Code formatting (no logic change)
refactor: Code restructuring
test: Adding tests
chore: Build or config changes
MIT License
Copyright (c) 2026 Muhammad Yasir โ NEXE.AGENT Internship
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense and/or sell
copies of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
See the full LICENSE file for details.
| Platform | Link |
|---|---|
| ๐ Portfolio | yasirawaninfo.vercel.app |
| ๐ผ LinkedIn | linkedin.com/in/yasirawan4831 |
| youtube.com/@YasirTech-t1d | |
| ๐ GitHub | github.com/YasirAwan4831 |
| ๐ฆ X (Twitter) | x.com/yasirawan4831 |
| ๐ธ Instagram | instagram.com/yasirawan4831 |
| ๐ Linktree | yasirawan4831.github.io/futuristic-links-dashboard |
| ๐ง Email | [email protected] |
- NEXE.AGENT โ For the AI & Automation Internship opportunity
- Google Gemini โ For the powerful LLM and embedding APIs
- ChromaDB โ For the excellent open-source vector database
- FastAPI โ For the elegant Python API framework
- Shields.io โ For the beautiful README badges
- Capsule Render โ For the SVG banner animations
- Readme Typing SVG โ For the typing animation
โญ If this project helped you, please consider giving it a star!