A multi-tenant embeddable AI Chatbot Platform (SaaS) with RAG capabilities, built with React and FastAPI.
- π’ Multi-tenant Architecture: Each organization has isolated data and chatbots
- π€ Multiple Chatbots per Tenant: Create and manage multiple chatbots
- π Knowledge Ingestion: URLs, PDFs, PowerPoints, text, and Q&A pairs
- π RAG Pipeline: Chunk β Embed β Vector Store β Retrieve β Generate
- π¬ Two Embed Modes: Chat bubble script and iframe embed
- π Admin Dashboard: Analytics, conversation history, and management
- π Secure Authentication: JWT + refresh tokens with RBAC (admin/editor)
- β‘ Rate Limits & Billing: Usage tracking and quota management
- π¨ Customizable Appearance: Theme colors, bot names, avatars
- FastAPI (Python 3.11+)
- PostgreSQL with SQLAlchemy + Alembic
- ChromaDB/FAISS for vector storage
- Google Gemini for embeddings + LLM
- React 18 with TypeScript
- Vite for build tooling
- TailwindCSS for styling
- React Query for data fetching
- Zustand for state management
- Recharts for analytics charts
βββ backend/
β βββ app/
β β βββ api/ # API routes
β β βββ core/ # Config, security, logging
β β βββ db/ # Database models
β β βββ schemas/ # Pydantic schemas
β β βββ services/ # Business logic
β β βββ main.py # FastAPI app
β βββ alembic/ # Database migrations
β βββ static/ # Widget scripts
β βββ requirements.txt
β
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ lib/ # API client
β β βββ store/ # Zustand stores
β β βββ types/ # TypeScript types
β βββ package.json
β
βββ README.md
- Python 3.11+
- Node.js 18+
- PostgreSQL 14+
- Google Gemini API key
- Create and activate virtual environment:
cd backend
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Configure environment:
# Copy example and edit with your values
cp env.example .envRequired environment variables:
DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/chatbot_platform
SECRET_KEY=your-32-char-secret-key
JWT_SECRET_KEY=your-32-char-jwt-secret
GEMINI_API_KEY=your-gemini-api-key
- Create database:
# In PostgreSQL
CREATE DATABASE chatbot_platform;- Run migrations:
alembic upgrade head- Start the server:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000- Install dependencies:
cd frontend
npm install- Start development server:
npm run devThe frontend runs at http://localhost:3000 and proxies API requests to the backend.
Visit http://localhost:3000/register to create an account and organization.
- Go to Chatbots β Create Chatbot
- Configure name, system prompt, appearance
- Save the chatbot
- Open chatbot β Knowledge Base
- Add URLs, upload PDFs/PPTs, or add Q&A pairs
- Wait for ingestion to complete
- Go to chatbot settings β Get Embed Code
- Copy the script and add to your website:
<!-- Chat Bubble -->
<script>
(function() {
var script = document.createElement('script');
script.src = 'http://your-domain.com/widget.js';
script.setAttribute('data-chatbot-id', 'YOUR_CHATBOT_ID');
script.async = true;
document.body.appendChild(script);
})();
</script>Or use iframe:
<iframe
src="http://your-domain.com/embed/chat/YOUR_CHATBOT_ID"
width="400"
height="600"
frameborder="0"
></iframe>Once the backend is running, visit:
- Swagger UI:
http://localhost:8000/api/docs - ReDoc:
http://localhost:8000/api/redoc
| Endpoint | Description |
|---|---|
POST /api/auth/register |
Register new user & tenant |
POST /api/auth/login |
Login and get tokens |
GET /api/chatbots |
List chatbots |
POST /api/chatbots |
Create chatbot |
POST /api/chatbots/{id}/knowledge/url |
Ingest URL |
POST /api/chatbots/{id}/knowledge/file |
Upload PDF/PPT |
POST /api/embed/chat/{id} |
Chat endpoint for widget |
GET /api/admin/dashboard |
Dashboard stats |
The platform supports multiple vector databases through an adapter interface:
# In backend/app/core/config.py
VECTOR_DB_TYPE=chroma # or 'faiss'To add a new adapter (e.g., Pinecone):
- Create
backend/app/services/vector_stores/pinecone.py - Implement the
VectorStoreAdapterinterface - Add to factory in
vector_store.py
- Set environment variables
- Use
gunicornwithuvicornworkers:
gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker- Build the frontend:
npm run build-
Deploy the
distfolder -
Configure API URL in production
Use a managed PostgreSQL service:
- Render PostgreSQL
- Heroku Postgres
- Supabase
- AWS RDS
| Setting | Description | Default |
|---|---|---|
system_prompt |
Instructions for the AI | "You are a helpful assistant." |
temperature |
Response creativity (0-2) | 0.7 |
max_tokens |
Max response length | 1000 |
theme_color |
Widget color | #6366f1 |
allowed_domains |
CORS whitelist | [] (all) |
| Plan | Message Limit | Features |
|---|---|---|
| Free | 1,000/month | Basic |
| Pro | 10,000/month | Priority support |
| Enterprise | Custom | SLA, dedicated |
- Passwords hashed with bcrypt
- JWT tokens with short expiry
- Refresh token rotation
- Rate limiting per tenant/session
- Domain allowlisting for embeds
- SQL injection protection via ORM
MIT License - see LICENSE file for details.