A conversational AI application built with modern web technologies, featuring intelligent chat responses and weather information services.
This project implements a full-stack chatbot application that leverages OpenAI's language models to provide human-like conversations. The system includes user management, persistent chat storage, and integrated weather services.
The application provides several key functionalities:
- User authentication system with secure registration and login
- Intelligent conversation handling using OpenAI's GPT models
- Weather information retrieval for global cities
- Conversation history persistence across user sessions
- Real-time chat interface with responsive design
Backend Architecture
- FastAPI framework for REST API development
- SQLAlchemy ORM for database operations
- PostgreSQL for data persistence
- Alembic for database schema management
Frontend Development
- Streamlit framework for user interface
- Interactive chat components
- Real-time response handling
External Services
- OpenAI API for natural language processing
- OpenWeatherMap API for meteorological data
Before installation, ensure your development environment includes:
- Python version 3.8 or newer
- PostgreSQL database server (version 13 recommended)
- Active internet connection for API services
- Git version control system
You will need to obtain API keys from the following services:
- OpenAI Platform - Register at https://platform.openai.com for GPT access
- OpenWeatherMap - Create account at https://openweathermap.org for weather data
git clone <your-repository-url>
cd <project-directory>python3 -m venv chatbot_env
source chatbot_env/bin/activate # Linux/Mac
chatbot_env\Scripts\activate # Windows
pip install -r requirements.txtAccess your PostgreSQL instance and execute:
CREATE DATABASE chatbot_db;
CREATE USER app_user WITH PASSWORD 'secure_password';
GRANT ALL ON DATABASE chatbot_db TO app_user;Create .env file with your credentials:
OPENAI_API_KEY=<your-openai-key>
WEATHER_API_KEY=<your-weather-key>
DATABASE_URL=postgresql://app_user:secure_password@localhost:5432/chatbot_db
alembic upgrade headcd app
uvicorn main:app --host 0.0.0.0 --port 8000streamlit run streamlit_app.py --server.port 8501Access the application at http://localhost:8501
- Navigate to the application URL
- Create a new user account or sign in
- Begin conversation by typing in the message field
- Select conversation topics using the dropdown menu
For weather information:
- Set topic to "weather"
- Enter city name in message field
- Receive current weather conditions
- All conversations are automatically saved
- Previous chats can be continued in new sessions
- Context is maintained across message exchanges
When extending functionality:
alembic revision --autogenerate -m "feature description"
alembic upgrade head- Models: Database table definitions
- Routes: API endpoint implementations
- Services: External API integrations
- Schemas: Data validation structures
Database Issues
- Verify PostgreSQL service is running
- Check connection string format
- Confirm user permissions are correct
API Problems
- Validate API key formats and activation
- Monitor usage quotas and limits
- Check network connectivity
Port Conflicts
- Modify FastAPI port:
uvicorn main:app --port 8001 - Change Streamlit port:
streamlit run app.py --server.port 8502
The application follows a layered architecture pattern:
- Presentation Layer: Streamlit UI components
- API Layer: FastAPI route handlers
- Business Logic: Service implementations
- Data Layer: SQLAlchemy models and PostgreSQL
To contribute to this project:
- Fork the repository
- Create feature branch from main
- Implement changes with tests
- Submit pull request with description
For technical support or questions:
- Review troubleshooting section
- Check existing issues in repository
- Create new issue with detailed problem description
Project maintained by Advay Parab
Last updated: $(date +%Y-%m-%d)