An AI-powered quiz dungeon game.
- Backend: FastAPI API that starts a session, generates dungeon flavor text, asks questions, gives hints, and checks answers.
- Frontend: Vite + React (shadcn/ui) client in
quest-master/. - Optional CLI: quick terminal version in
main-cli.py.
- You start a game with an
ageandinterest. - The backend uses an LLM (LangChain) to generate:
- a short in-world environment narration
- a question (returned as
question || answerinternally) - a hint
- a correctness verdict ("Correct" / "Incorrect")
- Game rules:
3lives+10points per correct answer- level up every
30points (max level3) - win at
90points
main.py- FastAPI server (default for the web app)main-cli.py- CLI game loopagents/agent.py- LLM-driven environment/question/hint/check logiccore/llm.py- LLM provider selection + env var loadingcore/tools.py- point/life tools + optional search tooldata/history.json- persisted question history (auto-created)quest-master/- React frontend
python -m venv venv
# Windows:
venv\Scripts\activate
# macOS/Linux:
# source venv/bin/activate
pip install -r requirements.txt
copy .env.example .env # Windows PowerShell: Copy-Item .env.example .env
# then edit .env and set GROQ_API_KEY
uvicorn main:app --reload --port 8000Health check:
curl http://localhost:8000/healthThe frontend is in quest-master/ and expects the backend at http://localhost:8000 (see quest-master/src/lib/api.ts).
cd quest-master
npm install
npm run devVite runs on http://localhost:8080 (configured in quest-master/vite.config.ts).
python main-cli.pyNote: the CLI and API share the same persisted question history file: data/history.json.
Create a .env (see .env.example).
Required (default configuration):
GROQ_API_KEY- used bycore/llm.py(default provider:groq)
Optional (only if you switch providers in code):
GLM_API_KEYGOOGLE_API_KEY
Optional (only if the question generator ends up using the search tool):
TAVILY_API_KEY
GET /healthPOST /game/startbody:{ "age": number, "interest": string }GET /game/{session_id}/questionPOST /game/{session_id}/hintbody:{ "question": string, "correct_answer": string }POST /game/{session_id}/answer-checkbody:{ "question": string, "correct_answer": string, "user_answer": string }GET /game/{session_id}/environmentGET /game/{session_id}/state
- Sessions are in-memory in
main.py(SESSIONSdict). Restarting the server resets all sessions. - Question history is persisted globally in
data/history.jsonto reduce repeats. - CORS is currently wide open (
allow_origins=["*"]) for local development.
cd quest-master
npm run test