A full-stack Rock Paper Scissors game where you play against an AI powered by Groq's Llama 3.1 model. Built with Flutter (frontend) and FastAPI (backend). โญ Star this repo if you found it helpful!
๐ฎ Play Now: https://rockpaperscissor-with-groq.netlify.app
- ๐ค AI-Powered Opponent - Play against Llama 3.1 AI via Groq API
- ๐ฏ 10-Round Games - Best of 10 rounds with final winner announcement
- ๐ Live Score Tracking - Real-time score updates
- ๐ Reset Functionality - Start a new game anytime
- ๐ Cross-Platform - Works on Web, iOS, Android, Desktop
- โก Fast Response - Groq provides ultra-fast AI inference
| Component | Technology | Deployment |
|---|---|---|
| Frontend | Flutter (Dart) | Netlify |
| Backend | FastAPI (Python) | Render |
| AI Model | Llama 3.1 via Groq API | - |
| Service | Platform | URL |
|---|---|---|
| Frontend | Netlify | rockpaperscissor-with-groq.netlify.app |
| Backend | Render | rockpaperscissor-nizp.onrender.com |
rockpaperscissor/
โโโ backend/
โ โโโ server.py # FastAPI server with Groq integration
โ โโโ requirements.txt # Python dependencies
โ โโโ .env # Environment variables (not in git)
โ โโโ .env.example # Environment template
โโโ frontend/
โ โโโ lib/
โ โ โโโ main.dart # Flutter app
โ โโโ pubspec.yaml # Flutter dependencies
โ โโโ web/ # Web build output
โโโ render.yaml # Render deployment config
โโโ README.md
- Python 3.11+
- Flutter SDK
- Groq API Key (free at https://console.groq.com)
-
Navigate to backend directory:
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
.envfile:cp .env.example .env
-
Add your Groq API key to
.env:GROQ_API_KEY=your_api_key_here -
Run the server:
uvicorn server:app --reload --port 8001
-
Navigate to frontend directory:
cd frontend -
Get Flutter dependencies:
flutter pub get
-
Run on web:
flutter run -d chrome
Or run on other platforms:
flutter run -d macos # macOS flutter run -d ios # iOS Simulator flutter run -d android # Android Emulator
| Method | Endpoint | Description |
|---|---|---|
| POST | /play |
Make a move (Rock/Paper/Scissor) |
| GET | /reset |
Reset game scores |
| GET | /status |
Get current game status |
| GET | /health |
Health check |
curl -X POST https://rockpaperscissor-nizp.onrender.com/play \
-H "Content-Type: application/json" \
-d '{"text": "Rock"}'{
"user": "Rock",
"ai": "Paper",
"result": "AI Win",
"score_user": 0,
"score_ai": 1,
"turns_played": 1,
"turns_remaining": 9,
"game_over": false,
"final_result": "",
"message": ""
}- Choose your move: ๐ชจ Rock, ๐ Paper, or โ๏ธ Scissor
- AI will make its move using Llama 3.1
- Winner is determined:
- Rock beats Scissor
- Paper beats Rock
- Scissor beats Paper
- Play 10 rounds to determine the final winner
- Click Reset to play again!
| Variable | Description | Required |
|---|---|---|
GROQ_API_KEY |
Your Groq API key | Yes |
Contributions are welcome! Please feel free to submit a Pull Request.
