An interactive, AI-powered quiz game that tutors students on Artificial Intelligence concepts — built with React and powered by the Anthropic Claude API.
- Infinite AI-generated questions — Claude generates fresh, unique questions every session; no static question bank.
- 5 topic areas — AI Basics, Machine Learning, Language Models, AI Ethics, Advanced AI.
- 3 difficulty levels — Beginner, Intermediate, Expert.
- Personalised feedback — Claude analyses your session results and writes tailored study guidance.
- XP system — Earn points for correct answers across sessions.
- Repeat-question avoidance — Previously asked questions are sent back to the model to prevent duplicates.
| Layer | Technology |
|---|---|
| UI framework | React 18 (functional components + hooks) |
| Build tool | Vite 5 |
| AI backend | Anthropic Claude API (/v1/messages) |
| Styling | Inline React styles + CSS keyframes |
| Fonts | Google Fonts (Syne, Space Mono) |
| Linting | ESLint + eslint-plugin-react-hooks |
- Node.js ≥ 18 and npm ≥ 9
- An Anthropic API key
# 1. Clone the repository
git clone https://github.com/your-org/ai-quest.git
cd ai-quest
# 2. Install dependencies
npm install
# 3. Configure environment
cp .env.example .env
# Edit .env and set VITE_ANTHROPIC_API_KEY=sk-ant-...
# 4. Start the development server
npm run devOpen http://localhost:5173 in your browser.
npm run build
npm run preview # preview the production build locally
⚠️ Production Warning — See Security Considerations before deploying.
ai-quest/
├── public/ # Static assets
├── src/
│ ├── components/
│ │ └── Particles.jsx # Celebratory particle burst component
│ ├── constants/
│ │ └── game.js # Centralised game config (topics, difficulties, XP)
│ ├── hooks/
│ │ └── useQuiz.js # All game state & logic (testable, framework-agnostic)
│ ├── utils/
│ │ └── api.js # Anthropic API helpers with input validation
│ ├── AITutorGame.jsx # Root component — screen routing only
│ └── main.jsx # React entry point
├── docs/
│ └── security-notes.md # Extended security documentation
├── .env.example # Environment variable template (safe to commit)
├── .gitignore
├── package.json # Pinned dependencies
├── SECURITY.md # Vulnerability disclosure policy
└── README.md
All configuration is via environment variables. Copy .env.example to .env:
| Variable | Required | Default | Description |
|---|---|---|---|
VITE_ANTHROPIC_API_KEY |
✅ Yes | — | Your Anthropic API key |
VITE_CLAUDE_MODEL |
No | claude-sonnet-4-20250514 |
Claude model to use |
VITE_MAX_TOKENS |
No | 1000 |
Max tokens per API response |
VITE_TOTAL_QUESTIONS |
No | 5 |
Questions per quiz session (1–20) |
This project is a client-side React app, which means VITE_ANTHROPIC_API_KEY is embedded in the compiled JavaScript bundle. Anyone who inspects the network requests or bundle can read the key.
For any public or production deployment, you must:
- Create a server-side proxy (e.g. an Express route, Next.js API route, or serverless function) that holds the API key and forwards requests to Anthropic.
- Remove
VITE_ANTHROPIC_API_KEYfrom the frontend entirely. - Add rate limiting and authentication to the proxy endpoint.
This architecture is safe for local development and internal tools where the audience is trusted.
- Topic and difficulty values are sourced from closed constant lists — they are never taken from free-form user input.
- All user-influenced values are sanitised (length-capped, type-checked) before being included in prompts.
- Model responses are structurally validated before use; malformed output causes a visible error rather than silent failure.
- Prompts are capped at 8000 characters.
- API responses are validated for expected shape before any data is rendered.
See docs/security-notes.md for the full security architecture.
- Fork the repository and create a feature branch:
git checkout -b feat/my-feature - Follow existing code style — components stay thin, logic lives in hooks/utils.
- Never commit
.envor any real credentials. - Open a pull request with a clear description of the change and its motivation.
- Ensure
npm run lintpasses with zero warnings before submitting.
Please read our Code of Conduct before contributing.
MIT © Your Organisation. See LICENSE for details.