A full-stack AI-powered ChatBot platform built with React, FastAPI, PostgreSQL, and OpenAI.
The platform supports conversational AI, document uploads, Retrieval-Augmented Generation (RAG), semantic search, user authentication, conversation management, and administration features.
┌─────────────────────┐
│ React Frontend │
│ (Vite + React) │
└──────────┬──────────┘
│ REST API
▼
┌─────────────────────┐
│ FastAPI Backend │
│ Authentication │
│ Chat Services │
│ File Services │
│ RAG Services │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ PostgreSQL │
│ Users │
│ Conversations │
│ Messages │
│ Documents │
│ Embeddings │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ OpenAI API │
│ GPT Models │
│ Embeddings │
└─────────────────────┘
- User Registration
- User Login
- JWT Authentication
- Role-Based Access Control
- Protected API Endpoints
- ChatGPT-style Interface
- Streaming AI Responses
- Conversation History
- Multi-Conversation Support
- Persistent Messages
- PDF Upload
- TXT Upload
- Markdown Upload
- Text Extraction
- Document Chunking
- OpenAI Embeddings
- Semantic Search
- Context-Aware Responses
- User Statistics
- Usage Tracking
- Conversation Analytics
- Admin Dashboard APIs
- FastAPI
- PostgreSQL
- SQLAlchemy ORM
- Alembic Migrations
- OpenAI Integration
- Rate Limiting
- Automated Testing
- Modular Service Architecture
| Technology | Purpose |
|---|---|
| React | UI Framework |
| Vite | Build Tool |
| JavaScript | Frontend Logic |
| Fetch API | API Communication |
| Technology | Purpose |
|---|---|
| FastAPI | API Framework |
| PostgreSQL | Database |
| SQLAlchemy | ORM |
| Alembic | Database Migrations |
| OpenAI | LLM & Embeddings |
| JWT | Authentication |
| SlowAPI | Rate Limiting |
| PyPDF | PDF Processing |
| Pytest | Testing |
project-root/
│
├── backend/
│ │
│ ├── app/
│ │ ├── api/
│ │ ├── core/
│ │ ├── db/
│ │ ├── models/
│ │ ├── schemas/
│ │ ├── services/
│ │ └── main.py
│ │
│ ├── alembic/
│ ├── tests/
│ ├── uploads/
│ ├── requirements.txt
│ └── .env
│
├── frontend/
│ │
│ ├── src/
│ │ ├── components/
│ │ ├── services/
│ │ ├── config.js
│ │ ├── App.jsx
│ │ └── main.jsx
│ │
│ ├── public/
│ ├── package.json
│ └── .env
│
└── README.md
git clone https://github.com/yourusername/enterprise-rag-chatbot.git
cd enterprise-rag-chatbotcd backend
python -m venv venv
source venv/bin/activateWindows:
venv\Scripts\activatepip install -r requirements.txtCreate:
backend/.env
DATABASE_URL=postgresql://postgres:password@localhost:5432/chatbot_db
OPENAI_API_KEY=your_openai_api_key
SECRET_KEY=change-this-secret
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60CREATE DATABASE chatbot_db;alembic upgrade headuvicorn app.main:app --reloadBackend:
http://127.0.0.1:8000
Swagger Docs:
http://127.0.0.1:8000/docs
Open Swagger UI:
http://127.0.0.1:8000/docs
Use:
POST /auth/registerRequest Body:
{
"name": "Test User",
"email": "test@example.com",
"password": "password123",
"role": "user"
}cd frontend
npm installCreate:
frontend/.env
VITE_API_BASE_URL=http://127.0.0.1:8000npm run devFrontend:
http://localhost:5173
| Method | Endpoint |
|---|---|
| POST | /auth/register |
| POST | /auth/login |
| GET | /auth/me |
| Method | Endpoint |
|---|---|
| POST | /chat/stream |
| Method | Endpoint |
|---|---|
| POST | /files/upload |
| Method | Endpoint |
|---|---|
| GET | /conversations |
| GET | /conversations/{id}/messages |
| DELETE | /conversations/{id} |
| Method | Endpoint |
|---|---|
| GET | /admin/stats |
| GET | /admin/users |
| GET | /admin/usage |
Run backend tests:
cd backend
python -m pytestRun coverage:
pytest --cov=appUpload Document
│
▼
Extract Text
│
▼
Chunk Document
│
▼
Generate Embeddings
│
▼
Store in PostgreSQL
│
▼
Semantic Search
│
▼
Retrieve Relevant Chunks
│
▼
Generate AI Response
- pgvector Integration
- Multi-Model Routing
- AI Agent Workflows
- Citation-Based Responses
- Source Attribution
- Conversation Summarization
- Docker Deployment
- Kubernetes Deployment
- CI/CD Pipelines
- Observability & Monitoring
- Multi-Tenant Architecture
Never commit:
.env
uploads/
venv/
node_modules/
Use:
.env.example
for sharing configuration templates.
MIT License
Jay Ram Singh
LinkedIn: https://www.linkedin.com/in/jayram