A professional chatbot application with JWT authentication built using FastAPI, Streamlit, and OpenAI GPT-3.5.
- π Secure JWT Authentication - Protected API endpoints
- π€ AI-Powered Chat - OpenAI GPT-3.5 Turbo integration
- π¨ Modern UI - Beautiful Streamlit frontend interface
- π¬ Real-time Chat - Interactive conversation experience
- π‘οΈ Error Handling - Robust error management
- π± Responsive Design - Works on all devices
Secure chat interface with authentication
| Technology | Purpose |
|---|---|
| FastAPI | Backend API & Authentication |
| Streamlit | Frontend User Interface |
| OpenAI | AI Chat Integration |
| JWT | Token-based Authentication |
| Bcrypt | Password Hashing |
| Pydantic | Data Validation |
- Python 3.8 or higher
- OpenAI API Key
- Clone the repository:
git clone https://github.com/yourusername/secure-ai-chatbot.git
cd secure-ai-chatbot- Create virtual environment:
python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Setup environment variables:
# Copy template
cp .env.example .env
# Windows
copy .env.example .env- Configure your OpenAI API Key:
Edit the
.envfile and add your API key:
OPENAI_API_KEY=sk-your-openai-api-key-hereTerminal 1 - Start Backend Server:
uvicorn main:app --reload --port 8000Terminal 2 - Start Frontend Interface:
streamlit run frontend.py- Backend API Docs: http://localhost:8000/docs
- Frontend Chat: http://localhost:8501
| Field | Value |
|---|---|
| Username | admin |
| Password | admin123 |
Note: Change these credentials in production
Secure authentication interface
secure-ai-chatbot/
βββ main.py # FastAPI backend with authentication
βββ frontend.py # Streamlit frontend interface
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore file
βββ README.md # Project documentation
βββ screenshots/ # Demo images
βββ chat_demo.png
βββ login_screen.png
βββ chat_interface.png
βββ settings_panel.png
- JWT Token Authentication
- Bcrypt Password Hashing
- Protected API Endpoints
- Secure Session Management
- Input Validation
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check |
/token |
POST | Authentication endpoint |
/chat |
POST | AI chat endpoint |
/users/me/ |
GET | User profile endpoint |
# Procfile
web: uvicorn main:app --host 0.0.0.0 --port $PORTFROM python:3.9
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]- Response Time: < 2 seconds
- Authentication: JWT token-based
- Scalability: Ready for production
- Security: Industry-standard practices
-
Authentication Error
- Check
.envfile contains valid API key - Verify username/password credentials
- Check
-
Module Not Found
pip install -r requirements.txt
-
Port Already in Use
# Change port uvicorn main:app --reload --port 8001
# Enable debug logging
export DEBUG=True
uvicorn main:app --reload --log-level debug- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - Modern Python web framework
- Streamlit - Frontend framework
- OpenAI - AI model provider
- JWT - Authentication standard
For support, email [mtalharana093@gmail.com] or open an issue on GitHub.
β If you find this project helpful, please consider giving it a star on GitHub!
Built with β€οΈ by Talha Rana

