AI QuizMaster is a small quiz generator that pairs a desktop Swing client with a Node.js backend. Users can register or sign in locally, request Gemini-powered quizzes on any topic, take them inside the app, and review their personal history.
- Topic-based quiz generation with selectable difficulty and question count (5–10).
- Gemini API creates fresh multiple-choice questions stored in MongoDB.
- Java Swing desktop client with login, quiz, results, and history views.
- Local flat-file storage (
user-data/) keeps hashed credentials and a per-user score log.
backend/– Express + MongoDB API that talks to Gemini and persists quizzes/results.src/– Java desktop client (AIQuizMaster) that consumes the backend.user-data/– Runtime directory the client uses for credentials (users.txt) and history (history.txt).
- Node.js 18+ and npm.
- Java 17+ (the client uses the built-in
java.net.httpclient). - MongoDB instance (local or Atlas connection string).
- Google Gemini API key with access to
gemini-2.5-flash(configurable).
cd backend- Install dependencies:
npm install - Create
.env(or set env vars) with at least:PORT=3000 MONGODB_URI=mongodb+srv://<user>:<pass>@<cluster>/quiz GEMINI_API_KEY=your_google_api_key GEMINI_MODEL=gemini-2.5-flash # optional override QUIZ_MIN_QUESTIONS=5 # optional QUIZ_MAX_QUESTIONS=10 # optional - Start the server:
npm run dev(nodemon) ornpm start. - Verify health check at
http://localhost:3000/health.
- From the repo root, compile the sources:
mkdir -p out javac -d out src/*.java - Run the app (expects the backend on
http://localhost:3000):java -cp out AIQuizMaster - Register a user inside the app (stored locally in
user-data/users.txt), generate quizzes, and view results/history.
Tip: keep the backend running while you use the client; quiz generation fails if the API or Gemini key is missing.
- Quiz generation fails immediately – Confirm the backend is running,
MONGODB_URIis reachable, andGEMINI_API_KEYis valid. - Login not persisted – Ensure the client process can write to
user-data/. Deleteuser-data/users.txtonly if you want a clean slate. - Connection refused – Adjust
QuizService.BASE_URLinsrc/QuizService.javaif you run the backend on another host/port.