Barbot is a virtual mixologist chat application that provides cocktail recipes and answers questions about mixology.
- Server: Python backend using FastAPI and the Anthropic API to interact with Claude's AI
- Web UI: React-based frontend that provides a chat interface similar to Claude.ai
- Authentication: JWT-based authentication system to secure the application
- Database: PostgreSQL database for persistent user storage
-
Copy the example environment file and add your Anthropic API key and a secret key for JWT:
cp .env.example .env
-
Build and start the Docker containers:
docker-compose up -d
-
Access the application at http://localhost:8081
-
Navigate to the server directory:
cd server
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv/Scripts/activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a .env file with your API keys:
ANTHROPIC_API_KEY=your-api-key-here SECRET_KEY=your-secure-random-key-here ACCESS_TOKEN_EXPIRE_MINUTES=30 DATABASE_URL=postgresql://user:password@localhost:5432/barbot
-
Run the server:
uvicorn main:app --reload
-
Install PostgreSQL on your system
-
Create a database and user:
CREATE DATABASE barbot CREATE USER barbot WITH ENCRYPTED PASSWORD 'barbot_password' GRANT ALL PRIVILEGES ON DATABASE barbot TO barbot
-
Navigate to the web directory:
cd web
-
Install dependencies:
npm install
-
Run the development server:
npm start
Once both the server and web UI are running, open your browser to interact with Barbot.
-
Register for an account or use the default credentials:
- Username: admin
- Password: adminpassword
-
After logging in, you can ask Barbot for cocktail recipes or mixology advice, and it will respond with properly formatted information.
Barbot uses JWT (JSON Web Token) authentication to secure the API:
- Registration: New users can register with a username, email, and password
- Login: Users can sign in with their credentials to receive a JWT token
- Protected Routes: The chat endpoint is protected and requires authentication
- Token Expiration: Tokens expire after a configurable period (default: 30 minutes)
- Persistent Storage: User credentials are stored in a PostgreSQL database
- PostgreSQL: User data is stored in a PostgreSQL database
- ORM: SQLAlchemy is used for database operations
- Persistence: Data is stored in a Docker volume to survive container restarts
- Schema: User model contains username, email, full name, hashed password, and disabled flag
To run the application in development mode with hot-reloading:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
After making changes to the code or dependencies, rebuild the containers:
docker-compose build
To view the logs of the running containers:
docker-compose logs -f
To access the PostgreSQL database directly:
docker exec -it barbot-db psql -U barbot -d barbot
To run backend tests:
cd server python -m pytest
To run frontend tests:
cd web npm test
- In production, you should set a strong, random SECRET_KEY
- Enable HTTPS to protect token transmission
- Configure proper CORS settings in the FastAPI server
- Set up regular database backups
- Implement rate limiting for authentication endpoints
- Consider using environment-specific database credentials