This repository contains the backend code for a Hangman game - a classic word guessing game. The application provides APIs to create game sessions, track player progress, and handle game logic for the Hangman experience.
- 🎲 Game session management (create and play sessions)
- 🔤 Random word selection from a database
- ✅ Letter guessing validation
- 📊 Game state tracking (lives, guessed letters, masked word)
- 🏁 Game completion detection (win or lose)
- 📈 Player progress tracking
- 📦 Node.js
- 🚂 Express.js
- 🗃️ Sequelize ORM
- 🗄️ SQLite database
- 🔌 CORS support for frontend integration
app.js- Main application entry pointmodels/- Database models for Word and GameSessionroutes/- API endpoints for game sessionsservices/- Business logic for game sessionsserializers/- Data transformation for API responses
- POST
/api/sessions - Request body:
{ "name": "player_name" } - Creates a new game session with a randomly selected word
- POST
/api/sessions/:id/play - Request body:
{ "letter": "a" } - Adds a guessed letter to the session and updates game state
The game implements the classic Hangman rules:
- 💖 Player gets 6 lives (attempts) to guess the word
- ❌ Each incorrect guess reduces the remaining lives
- ✅ Correct guesses reveal the corresponding letters in the word
- 🎬 Game ends when either:
- 🏆 Player correctly guesses all letters (win)
- 💀 Player runs out of lives (lose)
- 📝
title- The word to be guessed
- 👤
playerName- Name of the player - 🔤
playedLetters- Letters that have been guessed - 🕒
startedAt- When the game session started - 🏁
finishedAt- When the game ended (null if still in progress) - 🔗 Associated with a Word to be guessed
- 📥 Clone the repository
- 📦 Install dependencies:
npm install - 🚀 Start the server:
node app.js - 🌐 The server will run at http://localhost:3000
- 🔐 User authentication and profiles
- 🏆 Score tracking and leaderboards
- 🌡️ Multiple difficulty levels
- 🗂️ Categories for words
- ⏱️ Time-based challenges
- 👥 Multiplayer support