Math Guru is a galaxy-themed, interactive mathematics learning application built with React, TypeScript, and AI-powered tutoring. Explore 40+ interconnected math topics through gamified territory capture, receive AI explanations, and master mathematics with interactive visualizations.
- ๐ Galaxy Exploration: 40 interconnected math topics arranged as celestial territories
- ๐ค AI Tutoring: Offline Llama 3.1 8B AI for instant math explanations (no API costs!)
- ๐ฏ Territory Capture: Master topics through quizzes and unlock related areas
- ๐ Interactive Visualizations: Live mathematical graphs and scenario simulations
- ๐พ Progress Persistence: Your learning journey saves automatically across sessions
- ๐ Quiz Retries: Retry failed quizzes to improve your score
- Node.js 18+
- Modern web browser with localStorage support
# Clone the repository
git clone https://github.com/R-G78/MathGuru.git
cd MathGuru
# Install dependencies
npm install
# Start the development server
npm run devOption A: Official Installer (Easiest)
- Download the official installer: https://ollama.ai/download/Ollama-darwin.zip
- Double-click the downloaded file and follow the installation wizard
- Ollama is now installed and available in your Applications folder
Option B: Manual Installation
# Download Ollama archive
curl -L https://ollama.ai/download/Ollama-darwin.zip -o ollama.zip
unzip ollama.zip
# Extract and install
cp -r Ollama.app/Contents/Resources/ollama ~/.ollama/
chmod +x ~/.ollama/ollama
export PATH="$HOME/.ollama:$PATH"
# Add to shell profile (e.g., ~/.zshrc or ~/.bash_profile)
echo 'export PATH="$HOME/.ollama:$PATH"' >> ~/.zshrc
source ~/.zshrcAutomated Installation (Recommended)
curl -fsSL https://ollama.ai/install.sh | shManual Installation
# Download latest release
curl -L https://ollama.ai/download/ollama-linux-amd64 -o ollama
chmod +x ollama
sudo mv ollama /usr/local/bin/
# For other architectures:
# ARM64: ollama-linux-arm64
# AMD64: ollama-linux-amd64Ubuntu/Debian Repository (Alternative)
# Add Ollama repository
sudo apt update
sudo apt install -y ca-certificates curl
curl -fsSL https://ollama.ai/install.sh | sh
# Or using snap
sudo snap install ollamaOption A: Official Windows Installer (Easiest)
- Download: https://ollama.ai/download/OllamaSetup.exe
- Run the installer executable
- Follow the installation wizard
- Ollama will be added to your PATH automatically
Option B: PowerShell Installation
# Download and run installer
irm https://ollama.ai/download/OllamaSetup.exe -OutFile OllamaSetup.exe
.\OllamaSetup.exeOption C: Windows Subsystem for Linux (WSL)
# Inside WSL terminal
curl -fsSL https://ollama.ai/install.sh | sh-
Pull the Llama 3.1 8B model (first time download takes ~5-10 minutes):
ollama pull llama3.1:8b
-
Start the Ollama server (keep this terminal window open):
ollama serve
- Server runs on
http://localhost:11434 - Math Guru will automatically connect to this address
- Server runs on
-
Verify installation:
# Check if server is running curl http://localhost:11434/api/version # Test a simple prompt curl -X POST http://localhost:11434/api/generate \ -H "Content-Type: application/json" \ -d '{"model": "llama3.1:8b", "prompt": "Hello!", "stream": false}'
-
Run Math Guru:
npm run dev
Open http://localhost:5173 to start using AI-powered tutoring!
- macOS: macOS 11.0 or later, 8GB+ RAM recommended
- Linux: Most modern distributions, 8GB+ RAM recommended
- Windows: Windows 10 version 2004+ (21H2), 8GB+ RAM recommended
Llama 3.1 8B requires ~5GB disk space and ~8GB RAM. Apple Silicon Macs get accelerated performance.
- LM Studio - Point API to
localhost:11434 - oobabooga/text-generation-webui - Enable OpenAI compatibility
- Other OpenAI-compatible servers
The app automatically tries the local LLM first (http://localhost:11434), falling back to OpenAI GPT if:
- Local server isn't running
- Model unavailable
- API key not configured
Free with Ollama: No usage costs, runs entirely offline after initial model download.
- Introduction to Algebra
- Linear Equations & Systems
- Polynomials & Rational Functions
- Matrices & Vectors
- Quadratic Equations (Starting Point)
- Quadratic Formula & Discriminant
- Parabola Graphs & Vertex Form
- Completion of the Square & Factorization
- Real-World Applications & Complex Roots
- Geometry Foundations
- Triangles & Trigonometry
- Quadrilaterals, Circles, Area & Volume
- Coordinate Geometry
- Trigonometric Functions & Identities
- Trigonometric Equations & Inverse Functions
- Limits & Continuity, Functions Analysis
- Derivatives, Integrals & Applications
- Descriptive Statistics & Probability
- Data Analysis, Regression & Inference
- Territory Capture: Pass quizzes (60%+ score) to conquer topics
- Intelligent Unlocking: Completing one topic unlocks related territories
- Progressive Learning: Easy beginner topics lead to advanced concepts
- AI Guidance: Ask questions anytime for instant explanations
- Frontend: React 18 with TypeScript
- UI Library: Shadcn/UI + Tailwind CSS
- Animation: Framer Motion
- State Management: React hooks with localStorage persistence
- AI Integration: Ollama/Llama 3.1 8B with OpenAI fallback
- Visualization: Custom SVG math graphs with interactive controls
- Build Tool: Vite
src/
โโโ components/ # React components
โ โโโ ui/ # Reusable UI components (Shadcn/UI)
โ โโโ GalaxyMap.tsx # Main exploration map
โ โโโ LearningSession.tsx # Topic learning interface
โ โโโ Quiz.tsx # Interactive quiz system
โ โโโ MathVisualization.tsx # Mathematical visualizations
โโโ lib/ # Business logic & services
โ โโโ topics.ts # Topic definitions & lessons
โ โโโ ai-service.ts # AI tutoring integration
โ โโโ progress-service.ts # User progress management
โ โโโ utils.ts # Utility functions
โโโ pages/ # Page components
โโโ hooks/ # Custom React hooks
โ โโโ use-mobile.tsx # Mobile detection hook
โ โโโ use-toasts.ts # Toast notification hook
โโโ App.tsx # Main application component
- CSS Framework: Tailwind CSS for utility-first styling
- Component Library: Shadcn/UI for consistent, accessible UI
- Animations: Framer Motion for smooth transitions
- Themes: Gradient backgrounds with galaxy aesthetic
- Responsive: Mobile-first design with adaptive layouts
- All Shadcn/UI components are pre-downloaded under
@/components/ui - Custom math visualizations with SVG-based interactive graphs
- Galaxy map with constellation-style topic connections
- AI chat interface with conversation persistence
- Progress tracking with mastery indicators
- Import components from
@/components/uiin React components - Customize themes by modifying
tailwind.config.ts - Add global styles to
src/index.css - Path alias
@/points to thesrc/directory
The app uses Llama 3.1 8B running locally via Ollama for free, private AI tutoring. If no local LLM is available, it falls back to OpenAI GPT (requires API key in .env).
Environment Variables:
VITE_OPENAI_API_KEY=your-openai-api-key-here # Fallback only
VITE_LOCAL_LLM_URL=http://localhost:11434 # Ollama server# Build optimized bundle
npm run build
# Preview production build
npm run preview- Fork the repository
- Create a feature branch
- Make changes and test thoroughly
- Submit a pull request
This project is open source under the MIT License.
- Don't re-export types that you're already importing
- All Shadcn/UI components are available as pre-installed dependencies
- The app gracefully degrades when AI services are unavailable
- Progress persists automatically using browser localStorage
Zero API costs when using Ollama with Llama 3.1 8B! ๐