Skip to content

DmytroPI-dev/go-hangman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

40 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Hangman Game

A modern, multilingual Hangman game built with Go, React, and Firebase. Features responsive design, multiple difficulty levels, and support for English, Ukrainian, and Polish languages.

Hangman Game License

๐ŸŒŸ Features

  • ๐ŸŒ Multilingual Support: English, Ukrainian, and Polish
  • ๐ŸŽฏ Three Difficulty Levels: Easy, Normal, and Hard
  • ๐Ÿ’ก Hint System: Get contextual clues for words
  • ๐Ÿ”ค Letter Reveal: Open letters strategically (difficulty-based)
  • โŒจ๏ธ Keyboard Support: Play with physical keyboard or on-screen buttons
  • ๐Ÿ“ฑ Fully Responsive: Optimized for mobile and desktop
  • ๐ŸŽจ Beautiful UI: Built with Chakra UI
  • โ˜๏ธ Cloud-Native: Deployed on Firebase Hosting and Google Cloud Run

๐Ÿš€ Game webpage

Try the game live: https://hgame.i-dmytro.org

๐Ÿ—๏ธ Architecture

Tech Stack

Frontend:

  • React >= 19.0 with TypeScript
  • Vite (build tool)
  • Chakra UI 2.x (component library)
  • react-i18next (internationalization)
  • Deployed on Firebase Hosting

Backend:

  • Go 1.25
  • GIN (Go web framework)
  • Deployed on Google Cloud Run

Database:

  • Firebase Firestore (NoSQL database)

๐Ÿ“ Project Structure

go-hangman/
โ”œโ”€โ”€ frontend/              # React frontend application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/        # React components
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/             # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ i18n/              # Internationalization configuration
โ”‚   โ”‚   โ”œโ”€โ”€ locales/           # i18n translations
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ en/            # English translations
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ua/            # Ukrainian translations
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ pl/            # Polish translations
โ”‚   โ”‚   โ”œโ”€โ”€ types/             # TypeScript type definitions
โ”‚   โ”‚   โ”œโ”€โ”€ services/          # Frontend API services
โ”‚   โ”‚   โ”œโ”€โ”€ theme/             # Custom theme configuration
โ”‚   โ”‚   โ”œโ”€โ”€ main.ts            # Application entry point
โ”‚   โ”‚   โ””โ”€โ”€ App.tsx            # Main application component
โ”‚   โ”œโ”€โ”€ dist/                  # Production build output
โ”‚   โ”œโ”€โ”€ firebase.json          # Firebase Hosting configuration
โ”‚   โ””โ”€โ”€ package.json           # Project dependencies
โ”‚
โ”œโ”€โ”€ backend/                   # Go backend application
โ”‚   โ”œโ”€โ”€ handlers/              # HTTP request handlers
โ”‚   โ”œโ”€โ”€ game/                  # Game logic
โ”‚   โ”œโ”€โ”€ session/               # Session management
โ”‚   โ”œโ”€โ”€ utils/                 # Utility functions and helpers
โ”‚   โ”‚    โ”œโ”€โ”€ db_connection/    # Database connection checker
โ”‚   โ”‚    โ””โ”€โ”€ seeder/           # Database seeding scripts
โ”‚   โ”‚    
โ”‚   โ”œโ”€โ”€ database.example.json  # Example database structure
โ”‚   โ”œโ”€โ”€ Dockerfile             # Dockerfile for backend application
โ”‚   โ”œโ”€โ”€ go.mod                 # Go module configuration
โ”‚   โ”œโ”€โ”€ go.sum                 # Go module checksum file
โ”‚   โ””โ”€โ”€ main.go                # Application entry point
โ”‚
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ deploy.yaml        # CI/CD pipeline configuration
โ”‚
โ””โ”€โ”€ README.md

๐Ÿ› ๏ธ Local Development

Prerequisites

  • Node.js 22.20.0 or higher
  • Go 1.25 or higher
  • Firebase CLI (npm install -g firebase-tools)
  • Docker (optional, for containerized development)

1. Clone the Repository

git clone https://github.com/dmytropi-dev/go-hangman.git
cd go-hangman

2. Set Up Firebase

  1. Create a new Firebase project at console.firebase.google.com
  2. Enable Firestore Database
  3. Download service account key:
    • Go to Project Settings โ†’ Service Accounts
    • Click "Generate New Private Key"
    • Save as backend/serviceAccountKey.json IMPORTANT: Keep this file secure and do not commit it to version control!
  4. Initialize Firebase in frontend:
cd frontend
firebase login
firebase init hosting
# Select your Firebase project
# Set public directory to: dist
# Configure as single-page app: Yes

3. Populate Database

Use the example database structure (see database.example.json) to create collections for each language (en, ua, pl) and add word documents with the required fields.:

# Import words to Firestore
# You can use Firebase Console or upload via script

4. Set Up Backend

cd backend

# Install dependencies
go mod download
go mod tidy

# Run backend
go run main.go

Backend will be available at http://localhost:8080

5. Set Up Frontend

cd frontend

# Install dependencies
npm install

# Create .env file
echo "VITE_API_URL=http://localhost:8080" > .env

# Run development server
npm run dev

Frontend will be available at http://localhost:5173


๐ŸŽฎ Game Rules

Difficulty Levels

Difficulty Attempts Hints Open Letters
Easy 7 โœ… 2
Normal 5 โœ… 1
Hard 3 โœ… 0

How to Play

  1. Select your preferred language and difficulty
  2. Click letters on the keyboard or type on your physical keyboard
  3. Use hint to get clue about the word
  4. On Easy/Normal, you can reveal letters (costs 1 attempt each)
  5. Guess the word before running out of attempts!

๐Ÿ—ƒ๏ธ Database Structure

See database.example.json for the complete structure. Each language has its own collection with words containing:

  • word: The word to guess
  • hint: A clue about the word

Example:

{
  "word": "elephant",
  "hint": "A large mammal with a trunk",    
}

๐Ÿš€ Deployment

Automated Deployment (CI/CD)

The project uses GitHub Actions for automated deployment:

  1. On PR merge to main:

    • Frontend โ†’ Firebase Hosting
    • Backend โ†’ Google Cloud Run
  2. Required GitHub Secrets:

    • FIREBASE_SERVICE_ACCOUNT : Firebase service account key
    • GCP_SA_KEY : Google Cloud service account key
    • BACKEND_URL : Backend URL for frontend configuration
    • GCP_PROJECT_ID : Your GCP project ID
    • DOCKERHUB_USERNAME : Docker Hub username
    • DOCKERHUB_PASSWORD : Docker Hub access password
    • GITHUB_TOKEN : GitHub token for actions (automatically provided)

Manual Deployment

Frontend:

cd frontend
npm run build
firebase deploy --only hosting

Backend:

cd backend
gcloud run deploy hangman-backend \
  --source . \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated

๐ŸŒ Internationalization

The game supports three languages with full UI translation:

  • English (en)
  • Ukrainian (ua)
  • Polish (pl)

Adding a New Language

  1. Create translation file: frontend/src/locales/[lang]/translation.json
  2. Add language to frontend/src/i18n/config.ts
  3. Add words to Firestore: data/[lang]/ collection
  4. Update language selector in GameSetup.tsx

๐Ÿ“ Environment Variables

Frontend

Variable Description Example
VITE_API_URL Backend API URL https://your-backend.run.app

๐Ÿค 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

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘จโ€๐Ÿ’ป Author

Dmytro Pishchenkov


๐Ÿ™ Acknowledgments

  • Chakra UI for the beautiful component library
  • Firebase for hosting and database
  • Google Cloud Platform for serverless backend
  • The Open Source community

๐Ÿ“ž Support

If you have any questions or issues, please open an issue on GitHub.


Happy Gaming! ๐ŸŽฎ๐ŸŽ‰

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages