An intelligent chatbot system for analyzing tourism data in Switzerland, powered by OpenAI.
- Interactive chat interface built with Streamlit
- Backend API powered by FastAPI
- Data analysis and visualization capabilities
- Support for querying tourism statistics
- Real-time data visualization with Plotly
- Session management and chat history
- Fast dependency management with uv
- Docker containerization for easy deployment
- Python 3.11+
- FastAPI
- Streamlit
- PostgreSQL
- OpenAI
- Plotly
- Pandas
- uv (fast Python package installer)
- Docker & Docker Compose
The easiest way to get started with the Tourism Data Chatbot is using Docker:
- Clone the repository:
git clone https://github.com/jahua/chatbot.git
cd chatbot- Create a
.envfile:
cp .env.example .env
# Edit .env with your configuration- Build and start the containers:
docker-compose up -dThis will start all required services:
- Backend API server
- Frontend Streamlit application
- PostgreSQL database
The application will be available at:
- Frontend: http://localhost:8501
- Backend API: http://localhost:8080
- Clone the repository:
git clone https://github.com/jahua/chatbot.git
cd chatbot- Run the setup script:
python setup_env.py- Activate the virtual environment:
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Run the setup script again (inside the virtual environment):
python setup_env.py- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Clone the repository:
git clone https://github.com/jahua/chatbot.git
cd chatbot- Create and activate virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
cp .env.example .env
# Edit .env with your configurationIf you've set up with Docker, the application is already running. To stop it:
docker-compose downTo update and restart:
git pull
docker-compose up -d --buildTo start both the backend and frontend with a single command:
./start.sh- Start the backend server:
./run_server.py
# or
python run_server.py- Start the frontend application:
./run_frontend.py
# or
python run_frontend.pyThe application will be available at:
- Frontend: http://localhost:8501
- Backend API: http://localhost:8080
This project uses uv, a fast Python package installer and resolver. Benefits include:
- Up to 10-100x faster package installations
- Reliable dependency resolution
- Optimized for CI/CD pipelines
- Compatible with pip and requirements.txt
To use uv manually:
# Install a package
uv pip install package-name
# Install from requirements.txt
uv pip install -r requirements.txt
# Create a virtual environment
uv venv .venvuv run uvicorn app.main:app
uv run streamlit run app.py
chatbot/
├── app/ # Backend application
│ ├── core/ # Core functionality
│ ├── db/ # Database models and connection
│ ├── llm/ # LLM integration
│ ├── models/ # Data models
│ ├── schemas/ # Pydantic schemas
│ └── services/ # Business logic
├── frontend/ # Streamlit frontend
├── docker/ # Docker configuration
├── tests/ # Test suite
├── .env # Environment variables
├── docker-compose.yml # Docker compose configuration
├── Dockerfile # Docker image definition
├── pyproject.toml # Project configuration
├── requirements.txt # Python dependencies
├── setup_env.py # Environment setup script
├── run_server.py # Backend server runner
├── run_frontend.py # Frontend runner
├── start.sh # Complete startup script
└── README.md # Project documentation
The application is containerized using Docker for easy deployment and consistent environments across different systems.
- Backend Container: Runs the FastAPI server
- Frontend Container: Runs the Streamlit interface
- Database Container: PostgreSQL for data storage
The docker-compose.yml file defines the multi-container setup with proper networking, volume mounting, and environment variable passing. Key features include:
- Volume mounts for persistent data
- Automatic database initialization
- Health checks for service dependencies
- Environment variable configuration
- Port mapping for service access
To build the images separately:
# Build backend
docker build -f docker/backend.Dockerfile -t tourism-chatbot-backend .
# Build frontend
docker build -f docker/frontend.Dockerfile -t tourism-chatbot-frontend .For production deployment, additional security measures are recommended:
- Use proper secrets management instead of environment files
- Set up SSL/TLS termination
- Configure proper database credentials
- Implement authentication for the API
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.