A Wordle-style daily word guessing game API built with FastAPI. Players get 6 attempts to guess a 5-letter word, with feedback after each guess.
🌐 Live API: https://word-puzzle.up.railway.app
📚 API Documentation: https://word-puzzle.up.railway.app/docs
🎮 Play the Game: https://word-puzzle-frontend.vercel.app/
💻 Frontend Repository: https://github.com/waker-btn/word_puzzle_frontend
- Daily 5-letter word puzzle (new word each day)
- 6 attempts to guess the word
- Feedback system:
2= correct position,1= wrong position,0= not in word - User authentication with JWT
- Each user gets their own game progress tracked per day
- FastAPI - Python web framework
- PostgreSQL - Database
- SQLModel - ORM
- JWT - Authentication
- Uvicorn - ASGI server
Copy .env.example to .env and fill in your values:
cp .env.example .envRequired variables:
APP_ENV=development
DATABASE_HOSTNAME=localhost
DATABASE_PORT=5432
DATABASE_USER=your_user
DATABASE_PW=your_password
DATABASE_NAME=word_puzzle
or
DATABASE_URL=
JWT_SECRET_KEY=your-secret-key # Run: openssl rand -hex 32
JWT_ALGORITHM=HS256
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
RATE_LIMIT=10/minuteUsing Poetry:
poetry install
poetry shellCreate an empty database:
createdb word_puzzleThe app will automatically create all the tables when it starts up.
uvicorn main:app --reloadAPI will be at http://localhost:8000
Interactive docs: http://localhost:8000/docs
curl -X POST http://localhost:8000/register \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'curl -X POST http://localhost:8000/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'Returns: {"access_token": "...", "token_type": "bearer"}
curl -X GET http://localhost:8000/games/words \
-H "Authorization: Bearer YOUR_TOKEN"curl -X POST http://localhost:8000/games/words \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"guess": "crane"}'Response includes:
attempt: Your guess and the feedback (e.g.,["crane", "01220"])remaining_attempts: How many guesses leftgame_status:ongoing,won, orlostword: The answer (only shown when game is over)
Each guess returns a 5-character string:
2= Letter is correct and in the right spot (🟩)1= Letter is in the word but wrong spot (🟨)0= Letter is not in the word (⬜)
Example: If the word is "SWEET" and you guess "STALE":
- Result:
"21001" - S=2 (correct!), T=1 (in word, wrong spot), A=0 (not in word), L=0, E=1 (in word, wrong spot)
word_puzzle/
├── main.py # App entry point
├── database.py # DB setup
├── settings.py # Config
├── controllers/ # Business logic
├── models/ # Database models
├── routers/ # API routes
├── schemas/ # Request/response schemas
├── dependencies/ # Auth dependencies
└── utils/ # Helper functions
- Inspired by Wordle by Josh Wardle
- Word list from 5-Letter-words
- Built by Matt Hemstock