WordGame - Verbumix Code Structure Documentation
Project Overview
WordGame (Verbumix) is a Hungarian word guessing game similar to Wordle, built with FastAPI backend and HTML/CSS/JavaScript frontend. The application features multiple game categories, user authentication, multiplayer rooms, leaderboards, and premium membership.
Tech Stack:
- Backend: FastAPI (Python)
- Frontend: HTML, Tailwind CSS, HTMX, JavaScript
- Database/Auth: Supabase
- Payment: Paddle
File Structure
wordGame/
├── main.py # Main FastAPI application, core game logic
├── database.py # Supabase client configuration
├── room.py # Multiplayer room management
├── gameChange.py # Game category selection router
├── paddle.py # Paddle payment webhook handler
├── slang.py # Slang word import utility
├── static/ # Static assets (CSS, JS, images)
└── templates/ # Jinja2 HTML templates
├── base.html # Base layout with navigation and game logic
├── login.html # Login form
├── register.html # Registration form
├── forgot-password.html # Password recovery request form
├── reset-password.html # Password reset form with token extraction
├── jatek-valaszto.html # Game category selection screen
├── jatek.html # Main game interface (Wordle-style)
├── rangletra.html # Leaderboard display
└── premium.html # Premium membership page (Paddle integration)
Python Files Detailed Breakdown
1. database.py - Supabase Configuration
| Variable/Function |
Type |
Description |
SUPABASE_URL |
Constant |
Supabase project URL |
SUPABASE_KEY |
Constant |
Supabase publishable API key |
supabase |
Client |
Supabase client instance for database operations |
Purpose: Centralized database connection configuration used by all other modules.
2. main.py - Main Application (277 lines)
Imports & Setup
| Variable/Function |
Type |
Description |
app |
FastAPI |
Main application instance |
templates |
Jinja2Templates |
Template renderer for HTML files |
KATEGORIA_NEVEK |
Dict |
Category name mappings (szleng, matek, gamer) |
Routes & Functions
| Route/Function |
Method |
Path |
Description |
index |
GET |
/ |
Home page, displays base.html with user context |
ellenoriz_tipp |
POST |
/ellenorzes |
Core game logic - validates guess against answer word |
rangletra |
GET |
/rangletra |
Displays leaderboard for selected category |
premium_oldal |
GET |
/premium |
Shows premium membership offer page |
login_page |
GET |
/login |
Displays login form |
register_page |
GET |
/register |
Displays registration form |
auth_register |
POST |
/auth/register |
Handles user registration via Supabase Auth |
auth_login |
POST |
/auth/login |
Handles user login, sets access_token cookie |
auth_logout |
GET |
/auth/logout |
Logs out user, deletes cookie |
forgot_password_page |
GET |
/forgot-password |
Displays password recovery form |
auth_forgot_password |
POST |
/auth/forgot-password |
Sends password reset email |
reset_password_page |
GET |
/reset-password |
Displays new password form |
auth_reset_password |
POST |
/auth/reset-password |
Updates user password with token |
get_current_user |
Async |
(helper) |
Extracts and validates user from access_token cookie |
ment_rangletra_pont |
Sync |
(helper) |
Saves score to leaderboard table |
Key Variables in Game Logic (ellenoriz_tipp)
| Variable |
Type |
Description |
tipp |
str |
User's guess (uppercased) |
megfejtes |
str |
Answer word from database |
statuszok |
list |
Array of "szurke"/"zold"/"sarga" for each letter |
megfejtes_szamlalo |
Counter |
Letter frequency counter for handling duplicates |
Game Logic Flow
- Fetch answer word from
szavak table by category
- Compare guess length to answer length
- First pass: Mark exact matches (green/zold)
- Second pass: Mark correct letters in wrong position (yellow/sarga)
- Generate HTML grid with colored cells
- If all green, show victory message
3. room.py - Multiplayer Room Management (138 lines)
| Route/Function |
Method |
Path |
Description |
generate_room_code |
Sync |
(helper) |
Generates random 6-character room code |
letrehoz_szoba |
POST |
/szoba/letrehozas |
Creates new room, adds owner as member |
csatlakozik_szoba |
POST |
/szoba/csatlakozas |
Join existing room by code |
szoba_statusz |
GET |
/szoba/statusz/{szoba_id} |
Returns current room member list (polled every 3s) |
Database Tables Used
| Table |
Purpose |
szobak |
Stores room data (id, tulajdonos_id, kod) |
szoba_tagok |
Stores room members (szoba_id, user_id) |
profilok |
User profiles (checked for is_premium to allow >4 members) |
Key Variables
| Variable |
Type |
Description |
kod |
str |
6-character alphanumeric room code |
szoba_id |
str |
UUID of created/joined room |
tulajdonos_id |
str |
Room owner's user ID |
jelenlegi_tagok_szama |
int |
Current member count |
4. gameChange.py - Game Category Router (20 lines)
| Route/Function |
Method |
Path |
Description |
jatek_valaszto |
GET |
/jatek-valaszto |
Displays game category selection screen |
indit_jatek |
GET |
/jatek/{kategoria} |
Loads game for specific category |
Note: indit_jatek currently fetches word from database but returns empty string (incomplete implementation).
5. paddle.py - Payment Webhook (21 lines)
| Route/Function |
Method |
Path |
Description |
paddle_webhook |
POST |
/paddle-webhook |
Receives Paddle payment events |
Webhook Logic
- Listens for
transaction.completed events
- Extracts
user_id from custom_data
- Updates
profilok table: sets is_premium = True
6. slang.py - Slang Word Importer (49 lines)
| Route/Function |
Method |
Path |
Description |
import_szleng_kifejezesek |
POST |
/szoba/import/szleng |
Imports slang words from GitHub repository |
Import Logic
- Fetches raw text from
SLANG_URL (GitHub)
- Filters words: must be 5 letters, alphabetic only
- Inserts unique words into
szavak table with category "szleng"
- Silently skips duplicates
HTML Templates Detailed Breakdown
templates/base.html - Base Layout (103 lines)
Structure
- Header with navigation (Játékok, Ranglétra, Prémium, Login/Logout)
- Main content area (
#jatek-terulet) loaded via HTMX
- JavaScript for Wordle-style keyboard input handling
Key JavaScript Variables
| Variable |
Type |
Description |
aktualisSor |
int |
Current row (0-5) |
aktualisBetuIndex |
int |
Current letter position (0-4) |
SZO_HOSSZ |
const |
Word length (5) |
MAX_PROBA |
const |
Maximum attempts (6) |
Key JavaScript Functions
| Function |
Description |
handleInput(key) |
Processes keyboard input, updates grid, submits on Enter |
HTMX Integration
- Uses
hx-get, hx-post, hx-target, hx-swap for dynamic content
- Polls room status every 3 seconds with
hx-trigger="every 3s"
templates/login.html - Login Form (36 lines)
- Email and password fields
- HTMX form submission to
/auth/login
- Error display in
#login-error
- Links to register and forgot password
templates/register.html - Registration Form (32 lines)
- Email and password (min 6 chars) fields
- HTMX form submission to
/auth/register
- Status display in
#register-status
- Link to login
templates/forgot-password.html - Password Recovery (24 lines)
- Email input field
- HTMX form submission to
/auth/forgot-password
- Status display in
#forgot-status
templates/reset-password.html - Password Reset (41 lines)
- New password input field
- Hidden field for
access_token extracted from URL hash
- JavaScript
extractToken() parses URL hash for Supabase token
- HTMX form submission to
/auth/reset-password
templates/jatek-valaszto.html - Game Selection (14 lines)
Three category buttons:
- Mai Szleng
/jatek/szleng
- Matek (Nerdle mód)
/jatek/matek
- Gamer / Geek
/jatek/gamer
templates/jatek.html - Game Interface (53 lines)
Variables from Context
| Variable |
Description |
kategoria_tipus |
Category identifier (szleng/matek/gamer) |
kategoria_nev |
Display name of category |
Layout
- 6 rows × 5 columns grid for guesses
- Category-specific virtual keyboard:
- Matek: Numbers 0-9 and operators (+, -, *, /, =)
- Others: Hungarian keyboard layout with special characters (Á, É, Í, Ó, Ö, Ő, Ú, Ü, Ű)
templates/rangletra.html - Leaderboard (51 lines)
Context Variable
| Variable |
Description |
toplista |
List of (sorszam, jatekos) tuples |
Jatekos Object Properties
| Property |
Description |
nev |
Username |
ido |
Time in seconds |
pont |
Score |
is_premium |
Premium badge display |
Features
- Category filter buttons (Szleng, Matek, Gamer)
- Medal emojis for top 3 ()
- Premium crown badge ()
templates/premium.html - Premium Page (22 lines)
- Paddle.js integration template
- Placeholder for checkout initialization
- Note: Currently a template/example, not fully integrated
Database Schema (Supabase Tables)
Based on code analysis, the following tables are used:
szavak - Words Table
| Column |
Type |
Description |
szo |
text |
The word/answer |
kategoria |
text |
Category (szleng, matek, gamer) |
szobak - Rooms Table
| Column |
Type |
Description |
id |
uuid |
Primary key |
tulajdonos_id |
uuid |
Owner's user ID |
kod |
text |
6-character room code |
szoba_tagok - Room Members Table
| Column |
Type |
Description |
id |
uuid |
Primary key |
szoba_id |
uuid |
Room ID (foreign key) |
user_id |
uuid |
Member's user ID |
rangletra - Leaderboard Table
| Column |
Type |
Description |
username |
text |
Player name |
pontszam |
int |
Score |
ido_masodperc |
int |
Time in seconds |
kategoria |
text |
Category |
is_premium |
bool |
Premium status |
profilok - User Profiles Table
| Column |
Type |
Description |
id |
uuid |
User ID (from Supabase Auth) |
is_premium |
bool |
Premium membership status |
API Endpoints Summary
| Method |
Path |
File |
Description |
| GET |
/ |
main.py |
Home page |
| POST |
/ellenorzes |
main.py |
Submit guess |
| GET |
/rangletra |
main.py |
Leaderboard |
| GET |
/premium |
main.py |
Premium page |
| GET |
/login |
main.py |
Login form |
| GET |
/register |
main.py |
Register form |
| POST |
/auth/register |
main.py |
Register user |
| POST |
/auth/login |
main.py |
Login user |
| GET |
/auth/logout |
main.py |
Logout user |
| GET |
/forgot-password |
main.py |
Password recovery form |
| POST |
/auth/forgot-password |
main.py |
Send reset email |
| GET |
/reset-password |
main.py |
Reset password form |
| POST |
/auth/reset-password |
main.py |
Update password |
| GET |
/jatek-valaszto |
gameChange.py |
Game selection |
| GET |
/jatek/{kategoria} |
gameChange.py |
Load game |
| POST |
/szoba/letrehozas |
room.py |
Create room |
| POST |
/szoba/csatlakozas |
room.py |
Join room |
| GET |
/szoba/statusz/{szoba_id} |
room.py |
Room status poll |
| POST |
/paddle-webhook |
paddle.py |
Payment webhook |
| POST |
/szoba/import/szleng |
slang.py |
Import slang words |
Security Considerations
- API Keys Exposed:
SUPABASE_KEY in database.py is a publishable key (safe for client-side), but should still be protected
- Cookie Security:
secure=False in login cookie - should be True in production (HTTPS)
- CSRF Protection: HTMX handles CSRF with cookies, but additional protection may be needed
- Input Validation: Basic validation present, but could be strengthened
- Rate Limiting: No rate limiting visible - consider adding for auth endpoints
Known Issues / TODOs
gameChange.py - indit_jatek() returns empty string (incomplete)
premium.html - Paddle integration is template-only, not fully functional
main.py line 166, 191, 226, 252 - AuthApiError is referenced but not imported
- No error handling for network failures in word fetching
- Leaderboard save function (
ment_rangletra_pont) is defined but never called