Your personal AI-powered virtual bartender
A 90's inspired retro video game-style web application where you chat with Arthur, a PS1-style 3D bartender who crafts custom cocktails right before your eyes using Three.js and AI.
Watch our video demonstrating Arthur's capabilities here.
Barline is an immersive virtual bartending experience that combines:
- AI-Powered Conversations: Chat naturally with Arthur, your virtual bartender, powered by Google Gemini
- Real-Time 3D Rendering: Watch your drink come to life with realistic liquid physics, ice cubes, and garnishes
- Smart Cocktail Generation: Create custom drinks, search by ingredients, or get personalized recommendations
- Personal Cocktail Library: Save your favorite recipes with detailed ingredients and instructions
- Retro Aesthetic: Nostalgic 90's video game style with PS1-era low-poly graphics
- Real-time WebSocket communication with Arthur
- Natural language drink requests and conversations
- Context-aware responses using RAG (Retrieval-Augmented Generation)
- Intelligent action routing: create, search, or suggest drinks
- 10 Different Glass Types: Martini, rocks, highball, shot, hurricane, zombie, and more
- Realistic Liquid Physics: Animated pour with color mixing and surface effects
- Dynamic Garnishes: Mint leaves, lemon wedges, cherries with gravity animations
- Ice Cube System: Staggered falling animations with bobbing physics
- PS1-Style Graphics: Low-poly bartender character in a retro sci-fi bar environment
- Sound Effects: Synchronized pour and ice sounds
- Save drinks to your personal shelf
- Browse your collection with visual cards
- View detailed recipes with ingredients and instructions
- Duplicate detection to keep your shelf organized
- Secure email/password authentication via Supabase
- Automatic JWT token refresh (every 4 minutes)
- Session management with logout confirmation
| Technology | Purpose |
|---|---|
| Three.js | 3D graphics rendering and scene management |
| TypeScript | Type-safe application development |
| Vite | Fast build tool and dev server |
| Tween.js | Smooth animations for liquid and physics |
| WebSocket | Real-time bidirectional communication |
| Technology | Purpose |
|---|---|
| Python+ | Core backend language |
| FastAPI | Modern async web framework |
| Uvicorn | ASGI server for FastAPI |
| Pydantic | Data validation and serialization |
| Technology | Purpose |
|---|---|
| Supabase (PostgreSQL) | Primary database with auth |
| pgvector | Vector database for semantic search |
| Supabase Storage | Asset storage for RAG documents |
| Technology | Purpose |
|---|---|
| Google Gemini API | LLM for conversational AI (gemini-2.0-flash) |
| scikit-learn | Cosine similarity for RAG retrieval |
| Custom Agent Engine | RAG + Few-Shot + Chain-of-Thought orchestration |
| Technology | Purpose |
|---|---|
| Docker | Containerization |
| docker-compose | Multi-container orchestration |
| pnpm | Fast, disk-efficient package manager |
Barline uses a sophisticated multi-layered AI system for intelligent cocktail creation:
User Message β Prompt Selection β RAG Augmentation β Few-Shot Examples β Gemini API β Structured Output
Components:
-
Prompt System (
apps/backend/src/infra/agent_core/prompt.py)- Composable prompt builder with RAG support
- Modular segments for system instructions, task descriptions, and examples
-
Prompt Prototypes (
apps/backend/src/infra/agent_core/prototypes.py)- Pre-built templates:
action_generation,retrieval_augmented,chat_style, etc. - Chain-of-Thought (CoT) structured prompts for better reasoning
- Pre-built templates:
-
RAG Strategy (
apps/backend/src/infra/agent_core/rag.py)- Vector similarity search over cocktail knowledge base
- Top-K retrieval (default: 5 chunks) for context augmentation
- Reduces hallucinations by 2-4x
-
Few-Shot Learning (
apps/backend/src/infra/agent_core/examples/)- Example-driven action selection (create, search, suggest)
- Reduces invalid JSON by 2-5x
- Improves action selection accuracy by 1.5-2.5x
-
Agentic Engine (
apps/backend/src/infra/agent_core/engine.py)- Fast heuristic template selection
- Structured JSON output via Pydantic schemas
- Streaming support for real-time responses
Performance Multipliers:
- RAG: 2-4x reduction in hallucinations, 1.5-3x higher task success
- Few-Shot: 2-5x reduction in invalid JSON, 1.5-2.5x better action selection
- Chain-of-Thought: 1.5-3x better on complex reasoning
- Combined: 2-4x end-to-end task success, 2-5x reduction in bad responses
Backend Recipe β DrinkMapper β Three.js Scene Update β Animations (Liquid/Ice/Garnish)
- Backend sends
DrinkRecipeSchemawith glass type, garnish, ingredients drinkMapper.tsconverts to frontendCocktailConfigGlassLoaderswitches to appropriate glass modelLiquidHandlercalculates color and animates pourIceLoaderdrops ice cubes with staggered timing (150ms delays)GarnishLoaderadds garnish after ice settles- Sound effects synchronized with animations
Client β [USER]: message β Server β Agent Engine β Stream Response β Client UI Update
- Client maintains conversation history (last 50 messages)
- Server validates JWT token on connection
- Streaming responses with
stream_start,stream_delta,stream_endevents - Agent metadata includes action type, reasoning, and created cocktails
- Node.js (v18+) and pnpm
- Python 3.11+
- Supabase account (supabase.com)
- Google Gemini API key (ai.google.dev)
pnpm installcd apps/frontend
pnpm installcd apps/backend
pip3 install -e .
# Or using the requirements file:
pip3 install -r ../../requirements.txtCreate apps/backend/.env:
# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key-here
SUPABASE_JWT_SECRET=your-jwt-secret-here
# Google Gemini
GEMINI_API_KEY=your-gemini-api-key
# App Settings
APP_NAME=Arthur API
APP_VERSION=1.0.0
DEBUG=false
# CORS (for local dev)
CORS_ORIGINS=http://localhost:5173cd apps/backend
uvicorn src.main:app --reload --port 8000Backend will be available at: http://localhost:8000
cd apps/frontend
pnpm devFrontend will be available at: http://localhost:5173
Create apps/backend/.env (same as above)
cd infra
docker-compose upServices will be available at:
- Frontend:
http://localhost:5173 - Backend:
http://localhost:8000
cd infra
docker-compose down| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:5173 | Main application UI |
| Backend API | http://localhost:8000 | REST API endpoints |
| API Docs (Swagger) | http://localhost:8000/docs | Interactive API documentation |
| API Docs (ReDoc) | http://localhost:8000/redoc | Alternative API docs |
| Variable | Description | Example |
|---|---|---|
SUPABASE_URL |
Your Supabase project URL | https://abc123.supabase.co |
SUPABASE_KEY |
Supabase anonymous key | eyJhbG... |
SUPABASE_JWT_SECRET |
JWT secret from Supabase settings | your-secret-key |
GEMINI_API_KEY |
Google Gemini API key | AIza... |
| Variable | Default | Description |
|---|---|---|
APP_NAME |
Arthur API |
Application name |
APP_VERSION |
1.0.0 |
API version |
DEBUG |
false |
Enable debug logging |
CORS_ORIGINS |
http://localhost:5173 |
Allowed CORS origins (comma-separated) |
Endpoint: ws://localhost:8000/api/v1/chat/ws?token=<access_token>
Message Types:
user- User message to Arthurstream_start- Response stream beginsstream_delta- Partial response chunkstream_end- Complete response with agent action metadataerror- Error message
Example Message Flow:
// Client sends
{
"content": "Make me a refreshing summer cocktail",
"conversation_history": "[USER]: Hello\n[ASSISTANT]: Hi! ..."
}
// Server streams back
{ "type": "stream_start" }
{ "type": "stream_delta", "content": "I'd be " }
{ "type": "stream_delta", "content": "happy to " }
{
"type": "stream_end",
"content": "I'd be happy to make you a Mojito!",
"agent_action": {
"action_type": "create_drink",
"reasoning": "User requested refreshing summer drink",
"created_cocktail": { /* DrinkRecipeSchema */ }
}
}| Glass ID | Type | Best For |
|---|---|---|
zombie_glass_0 |
Tall tiki glass | Tropical drinks, zombies |
cocktail_glass_1 |
Classic cocktail | Martinis, cosmopolitans |
rocks_glass_2 |
Short tumbler | Old fashioned, whiskey |
hurricane_glass_3 |
Curved tropical | PiΓ±a coladas, hurricanes |
pint_glass_4 |
Beer pint | Beer, hard cider |
seidel_Glass_5 |
Beer stein | German beers, oktoberfest |
shot_glass_6 |
Small shot | Shots, shooters |
highball_glass_7 |
Tall mixed drink | Mojitos, Tom Collins |
margarita_glass_8 |
Wide bowl | Margaritas, daiquiris |
martini_glass_9 |
V-shaped | Classic martinis |
- Liquid System: Color mixing, animated fills, realistic surface materials
- Ice Physics: Gravity-based falling, bobbing motion, glass-specific positioning
- Garnishes: GLTF models for mint, lemon, cherry with coordinated timing
- Audio: Pour and ice SFX synchronized with animations
- Lighting: Atmospheric fog and PS1-style lighting
- Environment: Retro sci-fi bar with wood floor textures
CodeJam-15/
βββ apps/
β βββ backend/ # Python FastAPI backend
β β βββ src/
β β β βββ api/v1/ # Route handlers (auth, chat, cocktails)
β β β βββ core/ # Config and dependencies
β β β βββ domain/ # Pydantic models and schemas
β β β βββ infra/ # Infrastructure layer
β β β β βββ agent_core/ # RAG + LLM agent engine
β β β β β βββ engine.py
β β β β β βββ prompt.py
β β β β β βββ prototypes.py
β β β β β βββ rag.py
β β β β β βββ examples/ # Few-shot examples
β β β β βββ repositories/ # Database access
β β β βββ services/ # Business logic
β β β βββ main.py # FastAPI app entry
β β βββ Dockerfile
β β βββ pyproject.toml
β β
β βββ frontend/ # Three.js/TypeScript frontend
β β βββ src/
β β β βββ api/ # Backend API client
β β β βββ assets/ # Audio, textures
β β β βββ components/ # UI components (login, shelf)
β β β βββ models/ # GLTF 3D models
β β β βββ scene/ # Three.js scene components
β β β β βββ BarLoader.ts
β β β β βββ CharacterLoader.ts
β β β β βββ GlassLoader.ts
β β β β βββ LiquidHandler.ts
β β β β βββ IceLoader.ts
β β β β βββ GarnishLoader.ts
β β β βββ ui/ # SVG icons and UI elements
β β β βββ utils/ # Helpers and mappers
β β β βββ websocket/ # WebSocket client
β β β βββ main.ts # App entry point
β β βββ Dockerfile
β β βββ package.json
β β
β βββ test/ # Testing utilities
β
βββ infra/
β βββ docker-compose.yml # Docker orchestration
β
βββ packages/
β βββ utils-py/ # Shared Python utilities
β βββ utils-ts/ # Shared TypeScript utilities
β
βββ requirements.txt # Python dependencies
βββ package.json # Root package file
# WebSocket test
cd apps/test
python test_websocket.py
# Backend tests
cd apps/backend
python test_few_shot_examples.py# Frontend
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build
# Backend
uvicorn src.main:app --reload # Start with hot reload
uvicorn src.main:app --port 8000 # Specify port
# Docker
docker-compose up # Start all services
docker-compose up -d # Start in detached mode
docker-compose down # Stop all services
docker-compose logs -f backend # View backend logsCore Tables:
cocktail- Cocktail recipesingredient- Ingredient master data with ABV and colorsgarnish- Garnish types and assetsglass- Glass types and 3D modelsuser_cocktails- User's saved cocktails (junction table)cocktail_ingredient- Cocktail ingredients with quantitiescocktail_garnish- Cocktail garnishescocktail_to_glass- Cocktail glass pairings
- Three.js - 3D graphics library
- FastAPI - Modern Python web framework
- Supabase - Open source Firebase alternative
- Google Gemini - Advanced AI language model
- Vite - Next generation frontend tooling
- PS1-style character model
- Retro sci-fi bar environment
- GLTF glass and garnish models
- 90's video game aesthetics
- Classic bartending experiences
- Retro UI/UX design patterns
Built with β€οΈ By Albert, Edward, Ellie and Nathan
Drink responsibly. Barline is for entertainment purposes only.