Skip to content

R-G78/MathGuru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Math Guru ๐ŸŒŒ - Interactive Mathematics Learning Platform

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.

โญ Features

  • ๐ŸŒŒ 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

๐Ÿƒโ€โ™‚๏ธ Quick Start

Prerequisites

  • Node.js 18+
  • Modern web browser with localStorage support

Installation

# Clone the repository
git clone https://github.com/R-G78/MathGuru.git
cd MathGuru

# Install dependencies
npm install

# Start the development server
npm run dev

Setup Offline AI Tutoring (Llama 3.1 8B)

macOS ๐ŸŽฏ

Option A: Official Installer (Easiest)

  1. Download the official installer: https://ollama.ai/download/Ollama-darwin.zip
  2. Double-click the downloaded file and follow the installation wizard
  3. 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 ~/.zshrc
Linux ๐Ÿง

Automated Installation (Recommended)

curl -fsSL https://ollama.ai/install.sh | sh

Manual 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-amd64

Ubuntu/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 ollama
Windows ๐ŸชŸ

Option A: Official Windows Installer (Easiest)

  1. Download: https://ollama.ai/download/OllamaSetup.exe
  2. Run the installer executable
  3. Follow the installation wizard
  4. 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.exe

Option C: Windows Subsystem for Linux (WSL)

# Inside WSL terminal
curl -fsSL https://ollama.ai/install.sh | sh

Setting up Llama 3.1 8B Model

  1. Pull the Llama 3.1 8B model (first time download takes ~5-10 minutes):

    ollama pull llama3.1:8b
  2. 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
  3. 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}'
  4. Run Math Guru:

    npm run dev

    Open http://localhost:5173 to start using AI-powered tutoring!

System Requirements

  • 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.

Option 2: Alternative Local LLM Runners

  • LM Studio - Point API to localhost:11434
  • oobabooga/text-generation-webui - Enable OpenAI compatibility
  • Other OpenAI-compatible servers

Configuration

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.

๐Ÿงฎ Mathematics Topics Covered

Algebra (6 topics)

  • Introduction to Algebra
  • Linear Equations & Systems
  • Polynomials & Rational Functions
  • Matrices & Vectors

Quadratics Cluster (9 topics)

  • Quadratic Equations (Starting Point)
  • Quadratic Formula & Discriminant
  • Parabola Graphs & Vertex Form
  • Completion of the Square & Factorization
  • Real-World Applications & Complex Roots

Geometry (6 topics)

  • Geometry Foundations
  • Triangles & Trigonometry
  • Quadrilaterals, Circles, Area & Volume
  • Coordinate Geometry

Trigonometry (4 topics)

  • Trigonometric Functions & Identities
  • Trigonometric Equations & Inverse Functions

Calculus (7 topics)

  • Limits & Continuity, Functions Analysis
  • Derivatives, Integrals & Applications

Statistics (5 topics)

  • Descriptive Statistics & Probability
  • Data Analysis, Regression & Inference

๐ŸŽฎ Game Mechanics

  • 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

๐Ÿ›  Technical Stack

  • 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

๐Ÿ“‚ File Structure

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

๐ŸŽจ Styling

  • 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

Components

  • 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

Development

  • Import components from @/components/ui in React components
  • Customize themes by modifying tailwind.config.ts
  • Add global styles to src/index.css
  • Path alias @/ points to the src/ directory

๐Ÿค– AI Configuration

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

๐Ÿš€ Building for Production

# Build optimized bundle
npm run build

# Preview production build
npm run preview

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes and test thoroughly
  4. Submit a pull request

๐Ÿ“„ License

This project is open source under the MIT License.

Note

  • 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! ๐ŸŽ‰

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages