German Hangman Game for Reddit

A German language learning game built on Reddit's Devvit platform. Test your German vocabulary with a classic Hangman game featuring words from various categories and difficulty levels.

Features

  • German Vocabulary: Learn and practice German words across multiple categories
  • Difficulty Levels: Words categorized as easy, medium, or hard based on length and complexity
  • Dynamic Word Pool: Words are fetched from Random Words API and stored in Redis
  • Hint System: Each word comes with a helpful hint to guide players
  • Score Tracking: Track your performance with a scoring system and streaks
  • Admin Tools: Moderators can add custom words and enrich the word pool

How to Play

  1. Start a new game by selecting a difficulty level (easy, medium, or hard)
  2. Guess letters by clicking on the on-screen keyboard
  3. Each incorrect guess adds a part to the hangman drawing
  4. You win if you guess the word before the hangman is complete (6 incorrect guesses)
  5. Use the provided hint if you're stuck!

Technical Architecture

Data Flow

  1. Word Source: German words are fetched from Random Words API
  2. Persistence: All words are stored in Redis for fast retrieval and to avoid repeated API calls
  3. Enrichment: The word pool grows automatically when:
    • The app initializes
    • A word is needed but Redis is empty for that difficulty level
    • A moderator triggers manual enrichment

Key Components

  • Word Enricher: Fetches random German words with various categories and lengths
  • Difficulty Estimator: Categorizes words as easy (≤5 letters), medium (6-9 letters), or hard (≥10 letters)
  • Redis Storage: Words stored in hash tables by difficulty level
  • Hangman Game Logic: Manages game state, scoring, and user interaction

Development

Prerequisites

  • Node.js 22 or higher
  • Reddit developer account
  • Devvit CLI installed (npm install -g @devvit/cli)

Setup

  1. Clone this repository
  2. Install dependencies: npm install
  3. Start the development server: npm run dev
  4. Test in the Devvit playground

Configuration

The app requires HTTP access to external domains:

  • random-words-api.kushcreates.com: For fetching German words
  • api.open-thesaurus.de: Alternative word source (legacy)

These domains must be approved in your Devvit Developer Settings.

Redis Data Structure

Words are stored in Redis using the following keys:

  • german_words:easy: Easy difficulty words
  • german_words:medium: Medium difficulty words
  • german_words:hard: Hard difficulty words

Each key contains a hash mapping words to their hints.

Admin Features

Moderators have access to:

  • Word Manager: View all words in the Redis store
  • Word Enricher: Add random words from the Random Words API
  • Custom Word Tool: Add specific words with custom hints and difficulty levels
  • Redis Inspector: View and manage the Redis data store

Inspiration

We wanted to create an engaging way to learn German vocabulary directly on Reddit, where communities already gather. Hangman was the perfect choice because it's universally familiar, requires no prior language knowledge, and provides immediate feedback. Our goal was to make language learning fun, accessible, and rewarding through a game that people would want to play daily.

What It Does

  • Interactive Learning: Players guess German words letter by letter, with helpful hints for each word
  • Progressive Difficulty: Words are categorized by length and complexity (easy: ≤5 letters, medium: 6-9 letters, hard: ≥10 letters)
  • Self-Sustaining Word Pool: The game automatically fetches and caches German words from the Random Words API
  • Admin Tools: Moderators can manage the word pool, add custom words, and monitor Redis storage
  • Progress Tracking: Players can track their performance with scoring and streaks

How We Built It

Tech Stack

  • Frontend: React with TypeScript, Tailwind CSS for styling
  • Backend: Node.js with Express, TypeScript for type safety
  • Data Storage: Redis for fast word caching and retrieval
  • Deployment: Devvit platform for Reddit integration
  • APIs:
    • Random Words API for German vocabulary
    • OpenThesaurus as a fallback word source

Key Components

  1. Word Management

    • german-words.ts: Core word selection logic with Redis fallback
    • word-enricher-redis.ts: Handles word fetching, deduplication, and Redis storage
    • random-words-api.ts: Client for the Random Words API with response normalization
  2. Game Logic

    • Shared TypeScript types for consistent data structures
    • Difficulty estimation based on word length
    • Hint generation with word categories and lengths
  3. Admin Interface

    • Redis inspection tools
    • Word enrichment controls
    • Custom word addition

Challenges We Faced

  1. API Integration

    • Normalizing responses from different word sources
    • Implementing rate limiting and error handling
    • Ensuring consistent word quality across difficulty levels
  2. Data Management

    • Designing an efficient Redis schema for word storage
    • Implementing lazy loading for the word pool
    • Handling concurrent access to shared resources
  3. User Experience

    • Making the game intuitive for language learners
    • Providing helpful feedback and hints
    • Ensuring smooth performance on Reddit's platform

Accomplishments We're Proud Of

  • Created a self-maintaining word pool that grows with usage
  • Built a responsive, accessible UI that works well on Reddit
  • Implemented robust error handling and fallback mechanisms
  • Developed comprehensive admin tools for content management
  • Achieved type safety across the entire stack with TypeScript

What We Learned

  • The importance of proper type definitions in a full-stack TypeScript application
  • Best practices for Redis data modeling and optimization
  • Techniques for normalizing third-party API responses
  • How to build engaging, educational games within Reddit's ecosystem
  • The value of automated testing and continuous integration

What's Next

Short-term Goals

  • Add more word categories and themes
  • Implement daily challenges with leaderboards
  • Enhance the hint system with more contextual information
  • Add audio pronunciations for words

Long-term Vision

  • Support for multiple languages beyond German
  • Social features for sharing progress
  • Integration with language learning platforms
  • Advanced analytics for tracking learning progress
  • Mobile optimization for better on-the-go learning

Built With

Share this project:

Updates