A full-stack chat application featuring a RAG (Retrieval-Augmented Generation) powered chatbot that answers questions about HR policies. The application consists of a Flask backend API and a Next.js frontend client.
- π€ RAG-based Chatbot: Uses Retrieval-Augmented Generation to answer questions based on HR policy documents
- π Vector Search: Leverages ChromaDB for semantic search and document retrieval
- π¨ Modern Frontend: Next.js 16 with React 19, TypeScript, and Tailwind CSS
- ποΈ Clean Architecture: Implements controller-service pattern for maintainable code structure
- π Environment-based Configuration: Secure configuration management using environment variables
- π Health Check Endpoint: Monitor application health status
- π RESTful API: Well-structured API endpoints for chat interactions
chat-application/
βββ chat-bot-langchain-latest/ # Backend Flask API
β βββ app/
β β βββ config/ # Application configuration
β β βββ controllers/ # Request controllers
β β βββ models/ # Pydantic models
β β βββ routes/ # API routes
β β βββ services/ # Business logic & RAG agent
β βββ chroma_db/ # ChromaDB persistent storage
β βββ main.py # Application entry point
β βββ pyproject.toml # Python dependencies
β βββ docker-compose.yml # Docker configuration
β
βββ chat-client/ # Frontend Next.js client
βββ app/ # Next.js app directory
βββ public/ # Static assets
βββ package.json # Node.js dependencies
βββ tsconfig.json # TypeScript configuration
- Framework: Flask 3.1.2+
- LLM: OpenAI GPT-4.1-mini
- Vector Database: ChromaDB
- Embeddings: OpenAI text-embedding-3-large
- Language Chain: LangChain
- Validation: Pydantic
- Python: 3.13+
- Framework: Next.js 16.1.1
- UI Library: React 19.2.3
- Language: TypeScript 5+
- Styling: Tailwind CSS 4
- Package Manager: Bun
- Python 3.13 or higher
- Node.js 20+ (or Bun)
- OpenAI API Key
- Git
- Navigate to the backend directory:
cd chat-bot-langchain-latest- Install dependencies using
uv(recommended) orpip:
# Using uv
uv pip install -e .
# Or using pip
pip install -e .- Create a
.envfile in the backend directory:
OPENAI_API_KEY=your_openai_api_key_here
PORT=5000
FLASK_ENV=development- (Optional) Set up ChromaDB using Docker:
docker-compose -f chroma-docker-compose.yml up -d- Navigate to the frontend directory:
cd chat-client- Install dependencies:
# Using bun (recommended)
bun install
# Or using npm
npm installcd chat-bot-langchain-latest
python main.pyThe backend API will be available at http://localhost:5000
cd chat-client
bun dev
# or
npm run devThe frontend will be available at http://localhost:3000
POST /api/v1/ask
Content-Type: application/json
{
"question": "What is the leave policy for employees?"
}Response:
{
"answer": "Based on the HR policy document...",
"status": "success"
}GET /api/v1/healthResponse:
{
"status": "healthy",
"message": "Service is running"
}- Document Processing: HR policy PDFs are split into chunks and converted to vector embeddings
- Vector Storage: Embeddings stored in ChromaDB for fast similarity search
- Query Processing: User questions are converted to embeddings
- Retrieval: System finds the top 3 most relevant document chunks
- Generation: GPT-4.1-mini generates answer using retrieved context
cd chat-bot-langchain-latest
docker-compose up -dcd chat-bot-langchain-latest
docker-compose -f chroma-docker-compose.yml up -dcd chat-bot-langchain-latest
python testing/testing.pyOPENAI_API_KEY: Your OpenAI API key (required)PORT: Server port (default: 5000)FLASK_ENV: Environment mode (development/production)
Configure API endpoint in your frontend code to point to the backend URL.
- OpenAI API Key Error: Ensure
OPENAI_API_KEYis set in your.envfile - ChromaDB Connection Error: Check if
chroma_dbdirectory has proper permissions - Port Already in Use: Change the
PORTin your.envfile - Module Not Found: Ensure all dependencies are installed using
uv pip install -e .orpip install -e .
Backend:
- New Route: Add route in
app/routes/ - New Controller: Create controller in
app/controllers/ - New Service: Add business logic in
app/services/ - New Model: Define schema in
app/models/schema.py
Frontend:
- Add new pages in
app/directory - Create components as needed
- Update API calls to match backend endpoints
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue on the repository.
Sudip Das
- GitHub: @dassudip2001
Note: This project was created as part of the IBM SkillsBuild Winter Certification Program β Applied Artificial Intelligence.