Skip to content

vedanthirekar/Yanck

Repository files navigation

Yanck - RAG Chatbot Platform

Build custom AI chatbots trained on your documents in minutes. Modern UI powered by Next.js + ShadCN, intelligent backend with Flask + Google Gemini.

πŸš€ Features

  • Modern UI: Beautiful, responsive interface with ShadCN UI components
  • 4-Step Wizard: Easy chatbot creation process
  • Document Upload: Support for PDF, DOCX, and TXT files
  • RAG Pipeline: Retrieval-Augmented Generation with FAISS + Google Gemini
  • Real-time Chat: Interactive messaging interface
  • Dashboard: Manage all your chatbots in one place
  • AI-Powered: Smart system prompt generation
  • TypeScript: Full type safety across the frontend

πŸ“‹ Technology Stack

Frontend

  • Next.js 14 - React framework with App Router
  • TypeScript - Type-safe development
  • Tailwind CSS - Modern utility-first styling
  • ShadCN UI - Beautiful, accessible components
  • React Hook Form + Zod - Form handling and validation

Backend

  • Flask 3.0 - Python web framework
  • LangChain - RAG pipeline orchestration
  • Google Gemini API - Large language model
  • FAISS - Vector similarity search
  • Sentence Transformers - Local embeddings
  • SQLite - Database

πŸ› οΈ Prerequisites

  • Node.js 18+ and npm
  • Python 3.9+
  • Google Gemini API Key (Get one here)
  • 2GB+ RAM (for embedding model)

⚑ Quick Start

1. Clone the Repository

git clone <your-repo-url>
cd Yanck-mvp

2. Backend Setup

# Install Python dependencies
pip install -r requirements.txt

3. Configure Backend Environment

# Create .env file
cp .env.example .env

Edit .env and add your Gemini API key:

# Flask Configuration
FLASK_ENV=development
FLASK_SECRET_KEY=your-secret-key-here  # Change this!

# Gemini API (REQUIRED)
GEMINI_API_KEY=your-gemini-api-key-here

# Model Configuration (Optional - defaults provided)
EMBEDDING_MODEL=all-MiniLM-L6-v2
CHUNK_SIZE=500
CHUNK_OVERLAP=50

# File Upload (Optional - defaults provided)
MAX_FILE_SIZE_MB=50
MAX_FILES_PER_CHATBOT=10
UPLOAD_FOLDER=./data/uploads

# Vector Store (Optional - defaults provided)
VECTOR_STORE_PATH=./data/vector_stores

# Database (Optional - defaults provided)
DATABASE_PATH=./data/chatbots.db

4. Initialize Database

python init_db.py

5. Start Flask Backend

python run.py

Backend will run on http://localhost:5000

6. Frontend Setup

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Create .env.local file
echo "NEXT_PUBLIC_API_URL=http://localhost:5000/api" > .env.local

# Start Next.js dev server
npm run dev

Frontend will run on http://localhost:3000

7. Open Your Browser

Visit http://localhost:3000 and start creating chatbots!

πŸ“– Usage

Create a Chatbot

  1. Click "Create Chatbot" from the landing page or dashboard
  2. Step 1: Set name and system prompt (or use AI generation)
  3. Step 2: Upload your documents (PDF, DOCX, TXT)
  4. Step 3: Test your chatbot with sample questions
  5. Step 4: Deploy and start chatting!

Manage Chatbots

  • Dashboard: View all your chatbots
  • Search: Filter chatbots by name or description
  • Delete: Remove chatbots with confirmation
  • Chat: Click any chatbot to start a conversation

Chat Interface

  • Ask questions about your uploaded documents
  • View conversation history
  • See which documents are loaded
  • Get AI-powered responses based on your content

Project Structure

rag-chatbot-platform/
β”œβ”€β”€ app.py                  # Flask application factory
β”œβ”€β”€ run.py                  # Application entry point
β”œβ”€β”€ init_db.py             # Database initialization script
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ .env.example          # Example environment configuration
β”œβ”€β”€ .env                  # Your environment configuration (not in git)
β”‚
β”œβ”€β”€ models/               # Data models and managers
β”‚   β”œβ”€β”€ database.py       # Database utilities
β”‚   β”œβ”€β”€ embedding_manager.py
β”‚   └── vector_store_manager.py
β”‚
β”œβ”€β”€ services/             # Business logic
β”‚   β”œβ”€β”€ chatbot_service.py
β”‚   β”œβ”€β”€ document_service.py
β”‚   └── query_service.py
β”‚
β”œβ”€β”€ routes/               # API and web routes
β”‚   β”œβ”€β”€ api_routes.py     # REST API endpoints
β”‚   └── web_routes.py     # Web page routes
β”‚
β”œβ”€β”€ templates/            # HTML templates
β”‚   β”œβ”€β”€ base.html
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ create_step1.html
β”‚   β”œβ”€β”€ create_step2.html
β”‚   β”œβ”€β”€ create_step3.html
β”‚   β”œβ”€β”€ create_step4.html
β”‚   └── chat.html
β”‚
β”œβ”€β”€ static/               # Static assets
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── styles.css
β”‚   └── js/
β”‚       β”œβ”€β”€ wizard.js
β”‚       └── chat.js
β”‚
└── data/                 # Application data (created on first run)
    β”œβ”€β”€ chatbots.db       # SQLite database
    β”œβ”€β”€ uploads/          # Uploaded documents
    └── vector_stores/    # FAISS vector indices

API Endpoints

Chatbot Management

  • POST /api/chatbot - Create new chatbot
  • GET /api/chatbot/<id>/status - Get chatbot status
  • DELETE /api/chatbot/<id> - Delete chatbot

Document Management

  • POST /api/chatbot/<id>/documents - Upload documents

Query

  • POST /api/chatbot/<id>/query - Submit query to chatbot

Configuration Options

Embedding Models

You can change the embedding model in .env:

# Faster, smaller (384 dimensions) - Default
EMBEDDING_MODEL=all-MiniLM-L6-v2

# Higher quality, larger (768 dimensions)
EMBEDDING_MODEL=all-mpnet-base-v2

Text Chunking

Adjust how documents are split:

CHUNK_SIZE=500        # Characters per chunk
CHUNK_OVERLAP=50      # Overlap between chunks

File Upload Limits

MAX_FILE_SIZE_MB=50           # Max size per file
MAX_FILES_PER_CHATBOT=10      # Max files per chatbot

Troubleshooting

"GEMINI_API_KEY not set" Error

Make sure you've set your Gemini API key in the .env file:

GEMINI_API_KEY=your-actual-api-key-here

"Failed to load embedding model" Error

This usually means insufficient memory. Try:

  • Closing other applications
  • Using a smaller model: EMBEDDING_MODEL=all-MiniLM-L6-v2

"File too large" Error

Reduce file size or increase the limit in .env:

MAX_FILE_SIZE_MB=100

Port Already in Use

Change the port in .env or via environment variable:

FLASK_PORT=8000

Testing

Run the test suite:

# Run all tests
python -m pytest

# Run specific test file
python -m pytest test_chatbot_service.py

# Run with verbose output
python -m pytest -v

Development

Running in Debug Mode

Debug mode is enabled by default when FLASK_ENV=development:

FLASK_ENV=development
python run.py

Adding New Features

  1. Update models in models/
  2. Add business logic in services/
  3. Create routes in routes/
  4. Add templates in templates/
  5. Update tests

Security Considerations

  • Never commit .env file - It contains sensitive API keys
  • Change FLASK_SECRET_KEY in production
  • Validate all file uploads - The app checks file types and sizes
  • Use HTTPS in production
  • Implement authentication for production use

Production Deployment

For production deployment, consider:

  1. Use a production WSGI server (Gunicorn, uWSGI)

    pip install gunicorn
    gunicorn -w 4 -b 0.0.0.0:5000 app:app
  2. Use PostgreSQL instead of SQLite

  3. Implement user authentication

  4. Add rate limiting

  5. Use cloud storage for uploaded files (AWS S3, etc.)

  6. Set up monitoring (Sentry, CloudWatch)

  7. Use environment-specific configs

License

[Your License Here]

Support

For issues and questions, please open an issue on GitHub.

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors