feat: Initialize QuizMaster Live project

This commit sets up the foundational structure for the QuizMaster Live application. It includes:
- Initializing a new Vite project with React and TypeScript.
- Configuring project dependencies and build tools (Vite, TypeScript).
- Defining core application types for game state, players, questions, etc.
- Setting up basic Tailwind CSS for styling and defining custom animations.
- Integrating with the Google Gemini API for AI-powered question generation.
- Configuring environment variables for API keys and defining the application's metadata.
- Adding a README with setup instructions and local development guide.
This commit is contained in:
Philip
2026-01-28 17:11:29 -08:00
parent 61870f121f
commit 7cdd75ea83
16 changed files with 2142 additions and 8 deletions
+52
View File
@@ -0,0 +1,52 @@
import { GoogleGenAI, Type } from "@google/genai";
import { Question } from "../types";
const generateQuestions = async (topic: string, count: number = 5): Promise<Question[]> => {
if (!process.env.API_KEY) {
console.error("API Key is missing");
return [];
}
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY });
try {
const response = await ai.models.generateContent({
model: "gemini-3-flash-preview",
contents: `Generate ${count} trivia questions about "${topic}". The questions should be suitable for a pub quiz.`,
config: {
responseMimeType: "application/json",
responseSchema: {
type: Type.ARRAY,
items: {
type: Type.OBJECT,
properties: {
text: { type: Type.STRING, description: "The question text" },
answer: { type: Type.STRING, description: "The correct answer" },
points: { type: Type.INTEGER, description: "Points value, usually 10, 20, or 30" },
category: { type: Type.STRING, description: "Short category name" }
},
required: ["text", "answer", "points", "category"]
}
}
}
});
if (response.text) {
const rawData = JSON.parse(response.text);
// Map to our internal ID structure
return rawData.map((q: any) => ({
id: crypto.randomUUID(),
text: q.text,
answer: q.answer,
points: q.points,
category: q.category
}));
}
return [];
} catch (error) {
console.error("Gemini generation error:", error);
return [];
}
};
export { generateQuestions };