Skip to content

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). Give it a star๐ŸŒŸ

Notifications You must be signed in to change notification settings

Pinkisingh13/rockpaperscissor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Rock Paper Scissors AI Game

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!

๐ŸŒ Live Demo

๐ŸŽฎ Play Now: https://rockpaperscissor-with-groq.netlify.app

๐ŸŽฌ Demo

Rock Paper Scissors Demo

Flutter FastAPI Python Groq Render Netlify

โœจ Features

  • ๐Ÿค– 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

๐Ÿ› ๏ธ Tech Stack

Component Technology Deployment
Frontend Flutter (Dart) Netlify
Backend FastAPI (Python) Render
AI Model Llama 3.1 via Groq API -

๐Ÿš€ Deployment

Service Platform URL
Frontend Netlify rockpaperscissor-with-groq.netlify.app
Backend Render rockpaperscissor-nizp.onrender.com

๐Ÿ“ Project Structure

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

๐Ÿš€ Getting Started (Local Development)

Prerequisites

Backend Setup

  1. Navigate to backend directory:

    cd backend
  2. Create virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Create .env file:

    cp .env.example .env
  5. Add your Groq API key to .env:

    GROQ_API_KEY=your_api_key_here
    
  6. Run the server:

    uvicorn server:app --reload --port 8001

Frontend Setup

  1. Navigate to frontend directory:

    cd frontend
  2. Get Flutter dependencies:

    flutter pub get
  3. 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

๐ŸŒ API Endpoints

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

Example Request

curl -X POST https://rockpaperscissor-nizp.onrender.com/play \
  -H "Content-Type: application/json" \
  -d '{"text": "Rock"}'

Example Response

{
  "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": ""
}

๐ŸŽฎ How to Play

  1. Choose your move: ๐Ÿชจ Rock, ๐Ÿ“„ Paper, or โœ‚๏ธ Scissor
  2. AI will make its move using Llama 3.1
  3. Winner is determined:
    • Rock beats Scissor
    • Paper beats Rock
    • Scissor beats Paper
  4. Play 10 rounds to determine the final winner
  5. Click Reset to play again!

๐Ÿ“ Environment Variables

Variable Description Required
GROQ_API_KEY Your Groq API key Yes

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

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). Give it a star๐ŸŒŸ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published