Skip to content

rex-pj/rex_game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

44 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rex Game

A web-based educational flashcard game designed for interactive learning through gamified experiences.

Rust Svelte PostgreSQL License


1. About

Rex Game is an interactive web-based flashcard learning platform that makes education fun through gamification. Originally created as a learning tool, it features multiple game modes, progress tracking, achievements, and leaderboards to encourage continuous learning.

Key Features

  • Multiple Game Modes

    • Multiple Choice Quiz
    • Flashcard Matching
    • Fill in the Blanks
  • Progress Tracking

    • Real-time scoring system
    • Session history
    • Performance analytics
    • Personal statistics dashboard
  • Gamification

    • Achievement system with unlockable badges
    • Global leaderboard
    • XP and level progression
    • Streak tracking
  • User Management

    • Secure authentication with JWT
    • Email verification
    • Password reset functionality
    • Profile customization
  • Flashcard Management

    • Custom flashcard categories
    • Rich text support (Markdown)
    • Image attachments
    • Import/Export capabilities

2. Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Client (Browser)                      β”‚
β”‚                     SvelteKit 2 + Svelte 5                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚ REST API (JSON)
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Backend Server                          β”‚
β”‚                   Rust + Axum Framework                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚              Modules (DDD Architecture)              β”‚  β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
β”‚  β”‚   Identity   β”‚    Games     β”‚   Mail       β”‚ Shared  β”‚  β”‚
β”‚  β”‚   (Auth)     β”‚  (Scoring)   β”‚ Templates    β”‚ Utils   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚ SeaORM
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    PostgreSQL Database                       β”‚
β”‚         (Users, Flashcards, Sessions, Achievements)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Module Structure (Domain-Driven Design)

backend/
β”œβ”€β”€ entities/           # Database models (SeaORM entities)
β”œβ”€β”€ migration/          # Database migrations
β”œβ”€β”€ modules/            # Business logic modules
β”‚   β”œβ”€β”€ identity/       # Authentication & authorization
β”‚   β”œβ”€β”€ games/          # Game logic & scoring
β”‚   └── mail_templates/ # Email templates
β”œβ”€β”€ shared/             # Shared utilities & infrastructure
└── src/                # API handlers & routing

3. Tech Stack

Backend

Component Technology Version
Language Rust 1.70+
Web Framework Axum 0.7
ORM SeaORM 1.1
Database PostgreSQL 15+
Authentication JWT -
Email Resend API -

Frontend

Component Technology Version
Framework SvelteKit 2.x
UI Library Svelte 5.x
Styling Bootstrap 5 5.3
Icons Font Awesome 6.x
HTTP Client Fetch API -

DevOps

  • CI/CD: GitHub Actions
  • Deployment: Google Compute Engine
  • Web Server: Nginx (reverse proxy)
  • SSL: Let's Encrypt

4. Prerequisites

Before you begin, ensure you have the following installed:


5. Getting Started

1. Clone the Repository

git clone https://github.com/rex-pj/rex_game.git
cd rex_game

2. Database Setup

Create a PostgreSQL database:

# Connect to PostgreSQL
psql -U postgres

# Create database
CREATE DATABASE rex_game_db;

# Create user (optional)
CREATE USER rex_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE rex_game_db TO rex_user;

# Exit
\q

3. Backend Setup

cd backend

# Copy environment file
cp environments/.env.example environments/.env.dev

# Edit .env.dev with your configuration
# - DATABASE_URL
# - JWT_CLIENT_SECRET (generate with: openssl rand -base64 32)
# - RESEND_API_KEY (get from https://resend.com)

# Run migrations
cargo run --bin migration

# Start the backend server
cargo run

The backend will start at http://localhost:8080

4. Frontend Setup

cd client-app

# Install dependencies
npm install

# Start development server
npm run dev

The frontend will start at http://localhost:5173

5. Access the Application

Open your browser and navigate to:


6. Project Structure

rex_game/
β”œβ”€β”€ backend/                    # Rust backend
β”‚   β”œβ”€β”€ entities/              # Database entities (SeaORM models)
β”‚   β”œβ”€β”€ environments/          # Environment configuration files
β”‚   β”‚   β”œβ”€β”€ .env.example      # Environment template
β”‚   β”‚   β”œβ”€β”€ .env.dev          # Development config
β”‚   β”‚   └── .env.prod         # Production config
β”‚   β”œβ”€β”€ migration/            # Database migrations
β”‚   β”œβ”€β”€ modules/              # Business logic modules
β”‚   β”‚   β”œβ”€β”€ identity/         # Authentication module
β”‚   β”‚   β”œβ”€β”€ games/            # Game & scoring module
β”‚   β”‚   └── mail_templates/   # Email templates
β”‚   β”œβ”€β”€ shared/               # Shared utilities
β”‚   β”‚   β”œβ”€β”€ domain/           # Domain logic
β”‚   β”‚   └── infrastructure/   # Infrastructure (DB, email, etc.)
β”‚   └── src/                  # API layer
β”‚       β”œβ”€β”€ handlers/         # Request handlers
β”‚       β”œβ”€β”€ middlewares/      # Auth, CORS, etc.
β”‚       └── routings/         # Route definitions
β”‚
β”œβ”€β”€ client-app/                # SvelteKit frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ atoms/        # Basic elements
β”‚   β”‚   β”‚   β”œβ”€β”€ molecules/    # Composite components
β”‚   β”‚   β”‚   └── organisms/    # Complex components
β”‚   β”‚   β”œβ”€β”€ lib/              # Utilities & stores
β”‚   β”‚   β”‚   β”œβ”€β”€ api/          # API client functions
β”‚   β”‚   β”‚   β”œβ”€β”€ models/       # TypeScript types
β”‚   β”‚   β”‚   └── stores/       # Svelte stores
β”‚   β”‚   └── routes/           # SvelteKit routes
β”‚   β”‚       β”œβ”€β”€ (app)/        # Authenticated routes
β”‚   β”‚       └── (auth)/       # Public routes
β”‚   └── static/               # Static assets
β”‚
β”œβ”€β”€ docs/                      # Documentation
β”‚   β”œβ”€β”€ DEPLOYMENT.md         # Deployment guide
β”‚   β”œβ”€β”€ IMPROVEMENTS_SUMMARY.md
β”‚   └── RATE_LIMITING_IMPLEMENTATION.md
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── deploy.yml        # CI/CD pipeline
β”‚
└── README.md                 # This file

7. Documentation

Document Description
Deployment Guide Complete guide for deploying to production
API Documentation REST API endpoints reference
Database Schema Database structure and relationships
Contributing Guide How to contribute to the project

8. Environment Variables

Backend Configuration

Create backend/environments/.env.dev with the following:

# Database
DATABASE_URL=postgres://postgres:admin@localhost:5432/rex_game_db

# JWT (generate with: openssl rand -base64 32)
JWT_CLIENT_SECRET=your-generated-secret-here

# CORS
CORS_ALLOW_ORIGINS=http://localhost:5173,https://localhost:5173

# Email - Resend (https://resend.com)
EMAIL_PROVIDER=resend
RESEND_API_KEY=re_xxxxxxxxxx
EMAIL_FROM_NAME=Rex Game
EMAIL_FROM_ADDRESS=onboarding@resend.dev

# Platform URLs
PLATFORM_URL=http://localhost:5173
SIGNUP_VERIFICATION_URL=http://localhost:5173/account/confirm?token=[token]
RESET_PASSWORD_URL=http://localhost:5173/account/reset-password?token=[token]

For production configuration, see Deployment Guide.


9. Running Tests

# Backend tests
cd backend
cargo test

# Frontend tests
cd client-app
npm test

10. Building for Production

Backend

cd backend
cargo build --release

The binary will be at backend/target/release/rex_game

Frontend

cd client-app
npm run build

The build output will be in client-app/build/


11. Deployment

For detailed deployment instructions, see Deployment Guide.

Quick deployment options:

  • Google Cloud Platform (recommended, includes free tier)
  • AWS EC2
  • DigitalOcean Droplets
  • Any VPS with Ubuntu 22.04+

12. Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Rust naming conventions and best practices
  • Write tests for new features
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

13. Authors


14. Acknowledgments

  • Built with ❀️ for educational purposes
  • Inspired by the desire to make learning fun
  • Thanks to the Rust and Svelte communities

15. Support

For issues, questions, or suggestions:


16. Roadmap

  • Mobile app (React Native)
  • Multiplayer mode
  • AI-generated flashcards
  • Voice recognition for language learning
  • Integration with popular learning platforms
  • Teacher dashboard for classroom use

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published