About the project
Inspiration
After running multiple stargazing meetups, we watched learners struggle to retain facts about constellations, planets, and missions. We dreamed of a quiz app that not only tests knowledge, but continuously evolves—generating fresh questions, adapting difficulty, and even chatting like a tutor. AstroQuiz sprang from that need for a more dynamic, personalized way to learn the universe.
What it does
- Dynamic Quiz Generation: Hit “Generate Questions” in the admin UI and your Supabase Edge Function (
generate-questions) calls an LLM to seed new multiple-choice astronomy questions and distractors into yourquestions&choicestables. - Timed Challenges & Adaptive Difficulty: Each question has a 30-second timer. After you answer, the front-end sends
{ userId, questionId, correct, responseTime }to thedetect-cheatingandchoose-next-questionfunctions. The AI chooses “easy/medium/hard” for your next question, keeping the quiz challenging but fair. - Instant Feedback & Streak Tracking: Correct or incorrect answers highlight instantly in the UI, and your score + streak update live.
- Global Realtime Leaderboard: When you finish, the
submit-scorefunction upserts your high score intouser_scores, and the React<Leaderboard />subscribes via Supabase Realtime to display the top 10 scores. - AI Tutor Chatbot: A floating
<Chatbot />widget streams back LLM-generated hints or answers when you ask “What causes a lunar eclipse?”—powered by theai-tutor-chatEdge Function. - Multilanguage & PWA Support: The
translate-textfunction lets you toggle between English and other languages. Offline-first with theusePWAhook, you can quiz even when you lose connectivity.
How we built it
- Data & Auth:
- Supabase Auth for sign-in (email/password & magic link)
- PostgreSQL tables provisioned via migrations (
20250617005013_quiet_bread.sql,…_warm_scene.sql) forprofiles,questions,choices, anduser_scores Row-Level Security policies guard reads/writes.
- Serverless Logic:
Five TypeScript Edge Functions under
supabase/functions/:generate-questions/index.tsdetect-cheating/index.tschoose-next-question/index.tstranslate-text/index.tsai-tutor-chat/index.ts
Each function calls either OpenAI GPT-4 or the Hugging Face Inference API (swappable via your
.env) and writes back to the database.- Frontend:
Vite + React (TypeScript) with Tailwind CSS for styling
Key hooks in
src/hooks/:useAuth.ts(wraps Supabase client),usePWA.ts(handles service-worker registration and offline mode)Components in
src/:<QuizScreen />,<ScoreDisplay />,<ResultModal />,<Leaderboard />,<Chatbot />, and an optional<AdminPanel />undersrc/lib/React Router for navigation and
lucide-reactfor crisp SVG icons.
Challenges we ran into
- Streaming LLM Replies: Integrating the streaming API from
ai-tutor-chatwithout janky UI updates required a custom React hook to buffer incoming chunks. - Crafting RLS Policies: Balancing security (no one can overwrite another user’s score) with realtime leaderboard reads took many iterations of Supabase policy tests.
- Adaptive-difficulty Prompt-Tuning: Teaching the LLM to reliably return
"difficulty": "medium"(and not something else) forchoose-next-questioninvolved careful prompt-engineering.
Accomplishments that we’re proud of
- Full AI-powered content pipeline—from question generation all the way through translation and chat hints—built entirely as modular Edge Functions.
- Offline-first capabilities, so learners can quiz under dark sky conditions without dropping progress.
- Realtime leaderboard that updates instantly across all connected clients, fueled by Supabase’s live subscriptions.
What we learned
- Best practices for structuring Supabase Edge Functions in TypeScript.
- How to secure a learning app with Row-Level Security and one-time upserts.
- Techniques for streaming AI responses into React UIs.
- Simple PWA patterns using a custom
usePWAhook to cache static assets and quiz data.
What’s next for AstroQuiz: AI-Powered Interactive Astronomy Quiz
- Mobile PWA enhancements: add push notifications for daily quiz challenges.
- Voice Interface: integrate Whisper for speech-to-text Q&A.
- Community features: user profiles, badges, and group study rooms.
Built with
- Languages & Frameworks: React (Vite), TypeScript
- Styling & Animations: Tailwind CSS, Framer Motion
- State & Routing: React Router DOM, custom hooks (
useAuth,usePWA) - Icons: lucide-react
- Backend & Database: Supabase (Auth, PostgreSQL, Realtime, Storage, Edge Functions)
- Serverless Functions: TypeScript functions under
supabase/functions/calling OpenAI or Hugging Face APIs - AI & LLM APIs: OpenAI GPT-4 & Hugging Face Inference (swappable via
.env) - Deployment: Vercel (frontend), Supabase CLI for Edge Functions and database migrations
- PWA Support: Service-worker and offline caching utilities in
src/utils/pwaUtils.ts
Built With
- hugging
- huggingface
- javascript
- netlify
- openai
- react
- supabase
- tailwind
- typescript
- vite


Log in or sign up for Devpost to join the conversation.