A multiplayer web-based platform for playing Crime Scene tabletop games with friends, powered by AI agents to fill empty player slots.
- Guest Mode: Play immediately without account registration
- AI-Powered: Intelligent AI agents fill empty player slots using LLMs
- Real-Time Multiplayer: WebSocket-based game state synchronization
- Responsive Web UI: Works on desktop and mobile browsers
- Simple Room System: Create or join games with 6-character room codes
- Player Accounts: Optional registration to track stats and history
- Python 3.11+: Core backend language
- FastAPI: Modern async web framework
- python-socketio: WebSocket communication (Socket.IO protocol)
- LangChain: LLM integration framework
- SQLAlchemy: Async ORM for database access
- SQLite: Embedded database (WAL mode for concurrency)
- Vue 3: Progressive JavaScript framework (Composition API)
- Element-Plus: Vue 3 UI component library
- Vite: Fast build tool and dev server
- Pinia: State management
- Vue Router: Client-side routing
- socket.io-client: WebSocket client library
- Python 3.11+: Download Python
- Node.js 18+: Download Node.js
- Git: Download Git
-
Clone the repository:
git clone https://github.com/yourusername/vbrpg.git cd vbrpg -
Set up the backend:
cd backend # Create virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install dependencies pip install -r requirements.txt # Create .env file cp .env.example .env # Edit .env and add your LLM API keys (OpenAI, Anthropic, etc.) # Initialize database python -m alembic upgrade head
-
Set up the frontend:
cd ../frontend # Install dependencies npm install # Create .env file cp .env.example .env.local # Edit .env.local if needed (API URL defaults to http://localhost:8000)
-
Start the backend (from
backend/directory):source .venv/bin/activate # On Windows: .venv\Scripts\activate uvicorn src.main:app --reload --host 0.0.0.0 --port 8000
-
Start the frontend (from
frontend/directory, in a new terminal):npm run dev
-
Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Open the application in your browser
- Click "Create Room"
- Configure game settings:
- Number of players (2-6)
- Difficulty level (Easy/Medium/Hard)
- Turn time limit (30-300 seconds)
- Enable/disable AI narrator
- Click "Create" - you'll receive a 6-character room code
- Share the room code with friends
- Click "Join Room"
- Enter the 6-character room code
- Wait in the lobby until the room creator starts the game
- When the game starts, AI agents will fill any empty slots
- Your Turn: Take actions when it's your turn (investigate, question, move, examine, etc.)
- Turn Timer: Watch the countdown - you have limited time per turn
- Chat: Communicate with other players using the in-game chat
- Reconnection: If disconnected, rejoin within 5 minutes to resume your game
- Create an account to track your game statistics
- View game history and win rates
- Upgrade from guest to registered account
- Guest accounts are retained for 30 days
### Quick connectivity test (Deepseek / OpenAI-compatible providers)
From the `backend/` directory you can run a quick connectivity check to verify your configured API key and base URL:
```bash
# set (or export) these in your environment / .env
export AI_API_KEY="sk-your-deepseek-key"
export AI_API_BASE_URL="https://api.deepseek.example"
# run the connectivity test script
python3 scripts/test_deepseek_llm.py
The script will send a trivial prompt and print the response. If it fails, check your AI_API_KEY and AI_API_BASE_URL values.
vbrpg/
├── backend/
│ ├── src/
│ │ ├── api/ # REST API endpoints
│ │ ├── database.py # Database setup and session management
│ │ ├── models/ # SQLAlchemy models
│ │ ├── services/ # Business logic services
│ │ ├── websocket/ # WebSocket event handlers
│ │ ├── utils/ # Utility functions
│ │ └── main.py # FastAPI application entry point
│ ├── tests/ # Backend tests
│ │ ├── unit/ # Unit tests
│ │ └── integration/ # Integration tests
│ ├── alembic/ # Database migrations
│ ├── requirements.txt # Python dependencies
│ └── Dockerfile # Backend container
├── frontend/
│ ├── src/
│ │ ├── components/ # Vue components
│ │ ├── views/ # Page views
│ │ ├── stores/ # Pinia state stores
│ │ ├── services/ # API and WebSocket services
│ │ ├── utils/ # Utility functions
│ │ └── main.js # Vue application entry point
│ ├── tests/ # Frontend tests
│ ├── package.json # Node dependencies
│ └── Dockerfile # Frontend container
├── specs/ # Feature specifications
└── README.md # This file
### Running Tests
**Backend tests**:
```bash
cd backend
source .venv/bin/activate
pytest # Run all tests
pytest tests/unit/ # Run unit tests only
pytest tests/integration/ # Run integration tests only
pytest --cov=src # Run with coverage
Frontend tests:
cd frontend
npm run test # Run unit tests
npm run test:e2e # Run E2E tests (requires app running)Create a new migration:
cd backend
alembic revision --autogenerate -m "Description of changes"Apply migrations:
alembic upgrade headRollback:
alembic downgrade -1Backend linting:
cd backend
ruff check . # Check for issues
ruff check . --fix # Auto-fix issuesFrontend linting:
cd frontend
npm run lint # Check for issues
npm run lint:fix # Auto-fix issuesSee docs/deployment.md for detailed deployment instructions including:
- Docker Compose setup
- Environment variable configuration
- Production considerations
- Scaling strategies
- Backup procedures
- Interactive API Docs: http://localhost:8000/docs (Swagger UI)
- ReDoc: http://localhost:8000/redoc
- Detailed API Documentation: docs/api.md
Create backend/.env:
# LLM Configuration
# Preferred (new) settings for AI provider: use AI_API_KEY and AI_API_BASE_URL
# AI_API_KEY is the primary key used by the backend; it falls back to OPENAI_API_KEY for compatibility.
AI_API_KEY=your_openai_or_deepseek_api_key_here
AI_API_BASE_URL= # Optional: custom API base URL for OpenAI-compatible providers (e.g. Deepseek)
OPENAI_API_KEY=your_openai_api_key_here # optional fallback for backward compatibility
ANTHROPIC_API_KEY=your_anthropic_api_key_here
LLM_PROVIDER=openai # or "anthropic"
LLM_MODEL=gpt-4 # or "claude-3-opus-20240229"
# Database
DATABASE_URL=sqlite+aiosqlite:///./game_platform.db
# Security
SECRET_KEY=your_secret_key_here_change_in_production
SESSION_COOKIE_SECURE=false # Set to true in production with HTTPS
# Server
CORS_ORIGINS=http://localhost:5173,http://localhost:3000
LOG_LEVEL=INFO
# Game Settings
TURN_TIMEOUT_SECONDS=60
RECONNECTION_GRACE_PERIOD_MINUTES=5
GUEST_RETENTION_DAYS=30Create frontend/.env.local:
VITE_API_URL=http://localhost:8000
VITE_WS_URL=ws://localhost:8000The platform is designed to support:
- 50 concurrent game sessions
- 200 simultaneous players
- AI responses within 10 seconds (95th percentile)
- Game state sync within 1 second
- 99% uptime availability
- Input validation on all user inputs
- SQL injection prevention via SQLAlchemy ORM
- XSS protection via content sanitization
- Rate limiting on API endpoints
- Secure session cookies
- CORS configuration
Note: This is a proof-of-concept platform with basic security. For production use, consider:
- Implement authentication (JWT, OAuth)
- Add HTTPS/TLS encryption
- Enhanced rate limiting
- DDoS protection
- Security audit and penetration testing
- Single-session games: No save/resume functionality
- LLM dependency: Game terminates if LLM service fails
- Reconnection window: 5 minutes before AI replacement
- Guest data retention: 30 days
- One game type: Crime Scene (framework ready for more)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For issues, questions, or contributions:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Crime Scene game mechanics inspired by classic tabletop mystery games
- AI integration powered by OpenAI and Anthropic language models
- Built with modern web technologies and best practices