A modern, interactive astronomy learning platform built with React, TypeScript, and Supabase. Test your knowledge of the cosmos through engaging quizzes, compete on leaderboards, and learn with an AI-powered astronomy tutor.
- Dynamic Questions: Randomized astronomy questions with multiple difficulty levels
- Real-time Scoring: Instant feedback with streak tracking
- Timed Challenges: 30-second timer per question for added excitement
- Visual Learning: Image-based questions for enhanced engagement
- Progress Tracking: Detailed statistics and performance analytics
- AI-Powered Translation: Questions available in 10+ languages
- Real-time Translation: Instant question translation during quizzes
- Fallback Support: Multiple AI providers ensure reliable translation
- Language Selection: Easy language switching with flag indicators
- Live Leaderboards: Real-time rankings with automatic updates
- Achievement System: Unlock badges and milestones
- Streak Challenges: Build impressive answer streaks
- Performance Analytics: Detailed accuracy and speed metrics
- Interactive Chat: Ask questions about astronomy and space science
- Expert Knowledge: Specialized in astronomy, planets, stars, and space missions
- Conversation History: Maintains context for natural conversations
- Multiple AI Providers: OpenAI, Hugging Face, and custom endpoints
- Automated Monitoring: AI-powered cheating detection
- Anomaly Analysis: Speed and pattern analysis
- Confidence Scoring: Detailed suspicion assessment
- Visual Indicators: Subtle warnings on leaderboards
- Question Management: Create, edit, and organize quiz questions
- AI Question Generation: Bulk generate questions on any astronomy topic
- User Management: Monitor users and suspicious activities
- Analytics Dashboard: Comprehensive platform statistics
- React 18 with TypeScript
- Tailwind CSS for styling
- React Router for navigation
- Lucide React for icons
- Vite for development and building
- Supabase for database and authentication
- PostgreSQL with Row Level Security (RLS)
- Supabase Edge Functions for serverless computing
- Real-time subscriptions for live updates
- OpenAI GPT-3.5 for question generation and tutoring
- Hugging Face models as fallback
- Custom AI endpoints for additional reliability
- Multi-provider architecture for maximum uptime
- Node.js 18+ and npm
- Supabase account
- OpenAI API key (recommended)
- Hugging Face API key (optional fallback)
git clone <repository-url>
cd astroquiz-learning-app
npm install
Create a .env
file in the root directory:
# Supabase Configuration
VITE_SUPABASE_URL=your_supabase_url_here
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key_here
# AI Provider Configuration
AI_PROVIDER=openai
# OpenAI API Configuration (recommended)
OPENAI_API_KEY=your_openai_api_key_here
# Hugging Face API Configuration (optional fallback)
HF_API_KEY=your_huggingface_api_key_here
- Create a new Supabase project
- Run the migration files in order from
supabase/migrations/
- Enable Row Level Security on all tables
# Install Supabase CLI
npm install -g supabase
# Initialize and link project
supabase init
supabase link --project-ref your-project-ref
# Run migrations
supabase db push
# Deploy all edge functions
supabase functions deploy ai-tutor-chat
supabase functions deploy generate-questions
supabase functions deploy translate-text
supabase functions deploy detect-cheating
# Set environment variables for functions
supabase secrets set OPENAI_API_KEY=your_openai_api_key
supabase secrets set HF_API_KEY=your_huggingface_api_key
supabase secrets set AI_PROVIDER=openai
npm run dev
- User information and statistics
- Admin privileges and suspicion flags
- Performance metrics (total score, best streak, games played)
- Quiz questions with multiple choice options
- Categories, difficulty levels, and images
- Creator tracking and timestamps
- Individual quiz attempt records
- Scoring, timing, and streak data
- Integrity flags and suspicion reasons
- Row Level Security (RLS) on all tables
- Real-time subscriptions for live updates
- Automatic triggers for data consistency
- Performance indexes for fast queries
- Sign Up: Create an account with email and username
- Choose Language: Select your preferred language for questions
- Take Quizzes: Answer astronomy questions within the time limit
- Track Progress: Monitor your scores, streaks, and achievements
- Ask the AI Tutor: Get help with astronomy concepts
- Compete: Climb the leaderboards and unlock achievements
- Access Admin Panel: Available to users with admin privileges
- Manage Questions: Create, edit, and organize quiz content
- Generate Questions: Use AI to bulk create questions on any topic
- Monitor Users: Track user activity and suspicious behavior
- View Analytics: Access platform-wide statistics and insights
The app supports multiple AI providers with automatic fallback:
-
OpenAI (Recommended)
- Most reliable and accurate
- Best for question generation and tutoring
- Requires paid API key
-
Hugging Face
- Free tier available
- Good fallback option
- May have occasional downtime
-
Custom Endpoints
- Additional reliability
- Configurable endpoints
- Custom model support
# AI Provider Selection
AI_PROVIDER=openai # Options: openai, huggingface
# API Keys
OPENAI_API_KEY=sk-...
HF_API_KEY=hf_...
# Supabase Configuration
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=eyJ...
- Supabase Auth with email/password
- Row Level Security (RLS) policies
- Secure session management
- Admin role protection
- Encrypted data transmission
- Secure API endpoints
- Input validation and sanitization
- Rate limiting on AI endpoints
- Automated cheating detection
- Anomaly analysis algorithms
- Confidence scoring system
- Non-intrusive monitoring
The app can be deployed to any static hosting service:
# Build for production
npm run build
# Deploy to your preferred platform
# (Vercel, Netlify, GitHub Pages, etc.)
Supabase handles all backend infrastructure:
- Database hosting and backups
- Edge Functions deployment
- Real-time subscriptions
- Authentication services
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow TypeScript best practices
- Use Tailwind CSS for styling
- Maintain component modularity
- Add proper error handling
- Include comprehensive logging
Chat with the AI astronomy tutor
POST /functions/v1/ai-tutor-chat
{
"message": "What is a black hole?",
"conversation_history": [...]
}
Generate quiz questions using AI
POST /functions/v1/generate-questions
{
"topic": "Solar System",
"count": 5,
"difficulty": "medium"
}
Translate text to different languages
POST /functions/v1/translate-text
{
"text": "What is the largest planet?",
"targetLang": "es"
}
Analyze quiz sessions for suspicious behavior
POST /functions/v1/detect-cheating
{
"session_id": "uuid",
"user_id": "uuid",
"score": 8,
"total_questions": 10,
"time_taken": 45,
"streak": 5
}
- Ensure Supabase Edge Functions are properly deployed
- Check environment variables are set correctly
- Verify API endpoints are accessible
- Confirm AI provider API keys are configured
- Check Edge Function logs in Supabase dashboard
- Verify language codes are supported
- Verify Supabase URL and keys in
.env
- Check RLS policies are properly configured
- Ensure migrations have been applied
- Monitor database query performance
- Check for proper indexing
- Optimize real-time subscriptions
This project is licensed under the MIT License - see the LICENSE file for details.
- Supabase for the excellent backend-as-a-service platform
- OpenAI for powerful AI capabilities
- Pexels for beautiful astronomy images
- Lucide for the comprehensive icon library
- Tailwind CSS for the utility-first CSS framework
For support, please:
- Check the troubleshooting section above
- Search existing GitHub issues
- Create a new issue with detailed information
- Contact the development team
Built with โค๏ธ for astronomy enthusiasts and learners everywhere
Explore the universe, one question at a time ๐