8000
Skip to content

jameslovespancakes/Astraea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Astraea - AI Game Generator

Astraea is an AI-powered educational game generator that creates interactive HTML5 games from natural language prompts. Perfect for teachers who want to create custom learning games without coding.

โœจ Features

  • ๐Ÿค– Multi-Model AI Pipeline - Uses Falcon-7B for concept generation, BLIP-2 for image analysis, and Gemini-1.5 for code generation
  • ๐ŸŽจ Asset Integration - Automatically incorporates available game assets (sprites, tiles, backgrounds)
  • ๐ŸŽฏ Real-time Leaderboards - Live scoring and competition via WebSockets
  • ๐Ÿ‘จโ€๐Ÿซ Teacher Dashboard - Manage game sessions and track student progress
  • ๐ŸŽฎ Instant Preview - Test games before sharing with students

๐Ÿ—๏ธ Project Structure

Astraea/
โ”œโ”€โ”€ backend/          # Python Flask API with AI models
โ”‚   โ”œโ”€โ”€ assets/       # Game assets (sprites, tiles, backgrounds)
โ”‚   โ”œโ”€โ”€ prompts/      # System prompts for AI models
โ”‚   โ””โ”€โ”€ scripts/      # Game libraries (Phaser, Howler, etc.)
โ”œโ”€โ”€ frontend/         # Next.js web application
โ”‚   โ”œโ”€โ”€ components/   # React components
โ”‚   โ”œโ”€โ”€ pages/        # Next.js pages
โ”‚   โ””โ”€โ”€ services/     # API and WebSocket clients
โ””โ”€โ”€ README.md         # This file

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • CUDA-compatible GPU (12GB+ VRAM recommended)
  • Gemini API Key (Get one here)
  • Hugging Face Token (Get one here)

1. Backend Setup

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

# Configure environment
cp .env.example .env
# Edit .env and add your API keys

# Start backend
python server.py

Backend runs on http://localhost:3001

2. Frontend Setup

cd frontend

# Install dependencies
npm install

# Configure environment
cp .env.example .env.local
# Edit .env.local if needed (defaults work for local development)

# Start frontend
npm run dev

Frontend runs on http://localhost:3000

๐Ÿ“ Environment Variables

Backend (.env)

GEMINI_API_KEY=your_gemini_api_key_here
HF_TOKEN=your_huggingface_token_here
PORT=3001
HOST=0.0.0.0
CORS_ORIGINS=http://localhost:3000,http://localhost:3001

Frontend (.env.local)

NEXT_PUBLIC_API_URL=http://localhost:3001/api
NEXT_PUBLIC_WS_URL=http://localhost:3001

๐ŸŽฏ Usage

For Teachers

  1. Create a Game

    • Navigate to "Game Creator"
    • Enter a prompt like "Create a math game where students catch falling numbers that add up to 10"
    • Wait for generation (~30-60 seconds)
    • Preview and test the game
  2. Start a Session

    • Create a session from your generated game
    • Share the session code with students
  3. Monitor Progress

    • View real-time leaderboard
    • Track student scores

For Students

  1. Enter session code on home page
  2. Enter your name
  3. Play the game
  4. Scores automatically submit to leaderboard

๐Ÿค– AI Pipeline

User Prompt
    โ†“
[Falcon-7B] โ†’ Game Concept & Mechanics
    โ†“
[BLIP-2] โ†’ Analyze Available Assets
    โ†“
[Gemini-1.5] โ†’ Generate Complete Game Code
    โ†“
HTML5 Game

๐Ÿ“ฆ Technology Stack

Backend

  • Flask - Web framework
  • Flask-SocketIO - WebSocket support
  • PyTorch - Deep learning
  • Transformers - Hugging Face models
  • Gemini API - Code generation

Frontend

  • Next.js 14 - React framework
  • TailwindCSS - Styling
  • Socket.io-client - Real-time updates
  • React Query - Data fetching

Game Libraries (Auto-injected)

  • Phaser 3 - Game engine
  • Howler.js - Audio
  • Matter.js - Physics

๐Ÿ”ง Development

Backend Development

cd backend
python server.py

Models auto-load on first request (takes ~2-3 minutes).

Frontend Development

cd frontend
npm run dev

Hot reload enabled by default.

๐Ÿ“„ License

MIT License - See LICENSE file for details

๐Ÿค Contributing

Contributions welcome! Please open an issue or PR.

๐Ÿ› Troubleshooting

"CUDA out of memory"

  • Close other GPU applications
  • Reduce max_new_tokens in game_generator_multi.py
  • Use smaller models

"Connection refused" on frontend

  • Ensure backend is running on port 3001
  • Check CORS_ORIGINS in backend config

Models fail to load

  • Verify HF_TOKEN is valid
  • Check internet connection
  • Ensure sufficient disk space (~20GB for models)

๐Ÿ“ง Support

For issues or questions, please open a GitHub issue.


Built with โค๏ธ for educators

About

An AI Generative Pipeline for 2D Educational Games

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

0