rehab-wings-website-version

๐Ÿฆ Flappy Bird Rehab โ€” Hand Gesture Controlled Game

A hand-gesture-controlled Flappy Bird game designed for rehabilitation purposes. Available as both a desktop application (Pygame) and a web application (React + FastAPI) โ€” play anywhere on any device!

Game Preview


๐ŸŽฎ Features


๐Ÿš€ Getting Started

Prerequisites

1. Clone the Repository

git clone https://github.com/Nihith303/rehab-wings-website-version.git
cd rehab-wings-website-version

2. Set Up the Database

Create a MySQL database:

CREATE DATABASE IF NOT EXISTS rehab_wings;

The backend will automatically create the required tables (patients, game_sessions) on startup.

3. Configure Environment Variables

Create backend/.env:

DB_HOST=localhost
DB_PORT=3306
DB_NAME=rehab_wings
DB_USER=root
DB_PASSWORD=your_password_here

SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=1440

๐ŸŒ Running the Web Application

Backend (FastAPI)

cd backend
pip install -r requirements.txt
python -m uvicorn main:app --reload --port 8000

The API will be available at http://localhost:8000

API Documentation: Visit http://localhost:8000/docs for interactive Swagger UI.

Frontend (React)

cd frontend
npm install
npm run dev

The web app will be available at http://localhost:5173


๐Ÿ–ฅ๏ธ Running the Desktop Game

pip install -r requirements.txt
python game.py

Requires a webcam for hand gesture detection.


๐Ÿ› ๏ธ Tech Stack

Layer Technology
Frontend React 18, Vite 5, TailwindCSS 3, Axios
Backend FastAPI, SQLAlchemy, Uvicorn
Database MySQL 8.0
Auth bcrypt (password hashing), JWT (session tokens)
Game Engine HTML5 Canvas (web), Pygame (desktop)
Hand Tracking MediaPipe.js (web), MediaPipe + OpenCV (desktop)

๐ŸŽฏ Game Controls

Input Platform Action
Spacebar Desktop browser Flap
Click Desktop browser Flap
Tap Mobile browser Flap
Close Hand โœŠ Webcam (any) Flap

๐Ÿ“ก API Endpoints

Patients

| Method | Endpoint | Description | |โ€”โ€”โ€“|โ€”โ€”โ€”-|โ€”โ€”โ€”โ€”-| | POST | /api/patients/register | Register new patient with password | | POST | /api/patients/login | Login and receive JWT token | | POST | /api/patients/set-password | Set password for desktop-migrated patients | | GET | /api/patients/{id}/stats | Get player statistics |

Game Sessions

| Method | Endpoint | Description | |โ€”โ€”โ€“|โ€”โ€”โ€”-|โ€”โ€”โ€”โ€”-| | POST | /api/game/start | Start a game session | | POST | /api/game/end | End session, save score & duration | | GET | /api/game/check-playtime/{id} | Check remaining daily playtime |

Leaderboard

| Method | Endpoint | Description | |โ€”โ€”โ€“|โ€”โ€”โ€”-|โ€”โ€”โ€”โ€”-| | GET | /api/leaderboard | Top high scores | | GET | /api/leaderboard/daily | Daily aggregated statistics | | GET | /api/leaderboard/sessions/{id} | Session history for a player |


๐Ÿ—„๏ธ Database Schema

patients

| Column | Type | Description | |โ€”โ€”โ€“|โ€”โ€”|โ€”โ€”โ€”โ€”-| | id | INT (PK, AI) | Primary key | | name | VARCHAR(100) | Patient name | | patient_id | VARCHAR(50, UNIQUE) | Unique patient identifier | | password_hash | VARCHAR(255) | bcrypt password hash (nullable for desktop patients) | | high_score | INT | All-time high score | | created_at | TIMESTAMP | Account creation time | | updated_at | TIMESTAMP | Last update time |

game_sessions

| Column | Type | Description | |โ€”โ€”โ€“|โ€”โ€”|โ€”โ€”โ€”โ€”-| | id | INT (PK, AI) | Primary key | | patient_id | VARCHAR(50, FK) | References patients.patient_id | | session_date | DATE | Date of the session | | start_time | TIME | Session start time | | end_time | TIME | Session end time | | duration_seconds | INT | Total session duration | | score | INT | Score achieved in the session |


๐Ÿค Desktop โ†” Web Compatibility

Both the desktop and web versions share the same MySQL database (rehab_wings). This means:


๐Ÿ“„ License

This project is for rehabilitation and educational purposes.


๐Ÿ‘ค Author

Nihith โ€” GitHub