Skip to content

stussysenik/math-explainer-redwood

Repository files navigation



 M A T H V I Z 

Verified-first math orchestration

Node 20 RedwoodJS 8.9 SymPy MIT License


MathViz — Fundamental Theorem of Calculus with KaTeX rendering


What is this?

Demo

MathViz is a conversational math solver that handles any advanced engineering mathematics problem — from Kreyszig-level probability to Fourier series — with every intermediate step verified by SymPy. Ask in natural language, get textbook-quality output with proofs you can trust.


Features

Solve — natural language → symbolic computation pipeline

  • Any query dynamically routed through NLP (NVIDIA NIM / Anthropic Claude)
  • SymPy verification on every intermediate step — green badges show VERIFIED
  • Step-by-step reasoning with numbered walkthrough

Render — textbook-quality math, not plain text

  • KaTeX for all equations (inline $...$ and display $$...$$)
  • TheoremBox components styled like LaTeX amsthm environments
  • Interactive Desmos and GeoGebra graphs

Stream — real-time gate-by-gate progress

  • 6-stage Zod-validated pipeline: Input → Routing → SymPy → Symbol → Verify → Graph
  • Live progress indicator as each gate completes
  • Engine diagnostics panel with per-gate timing

Upload — scan textbook problems

  • Paperclip icon to attach images (JPG, PNG, WebP)
  • Vision-capable AI extracts the math problem from photos

Architecture

                    ┌──────────────┐
                    │  CommandBar  │   natural language + image upload
                    └──────┬───────┘
                           │
                    ┌──────▼───────┐
                    │  NLP Router  │   NIM / Anthropic / Stub
                    └──────┬───────┘
                           │
              ┌────────────┼────────────┐
              │            │            │
        ┌─────▼─────┐ ┌───▼────┐ ┌─────▼─────┐
        │  SymPy    │ │ Verify │ │  Graph    │
        │  Sidecar  │ │ Steps  │ │  Builder  │
        │  (8100)   │ │        │ │           │
        └─────┬─────┘ └───┬────┘ └─────┬─────┘
              │            │            │
              └────────────┼────────────┘
                           │
                    ┌──────▼───────┐
                    │  Renderer    │   KaTeX + Desmos + GeoGebra
                    └──────────────┘

Quick Start

Prerequisites: Node.js 20, Yarn, Python 3.10+

# Clone
git clone https://github.com/stussysenik/math-explainer-redwood.git
cd math-explainer-redwood

# Install JS dependencies
yarn install

# Set up the database
yarn rw prisma migrate dev

# Set up the Python sidecar
cd sidecar
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cd ..

# Configure environment
cp .env.example .env
# Add your API keys to .env:
#   NVIDIA_NIM_API_KEY=...
#   ANTHROPIC_API_KEY=...
#   DESMOS_API_KEY=...

# Run everything (sidecar + Redwood dev server)
./scripts/dev.sh

Open localhost:8920 and start solving.


Screenshots

Computation with step verification
Computation — step-by-step with verification
Theory response with KaTeX
Theory — KaTeX-rendered definitions
Integration with graphing
Integration — symbolic result + graph
Clean landing state
Landing — minimal, focused input

Tech Stack

Layer Technology Role
Framework RedwoodJS 8.9 Full-stack React + GraphQL + Prisma
Frontend React 18 + Tailwind CSS 3 Component rendering
Math KaTeX LaTeX equation rendering
Graphs Desmos API + GeoGebra Interactive graphing
NLP NVIDIA NIM / Anthropic Claude Natural language understanding
Symbolic SymPy (Python FastAPI sidecar) Computation + verification
Database SQLite + Prisma ORM Conversation persistence
Validation Zod Gate-by-gate schema validation

Project Structure

math-explainer-redwood/
├── api/                    # GraphQL API + pipeline
│   ├── src/lib/pipeline/   # 6-gate orchestrator (Zod-validated)
│   ├── src/lib/nlpRouter/  # NIM, Anthropic, Stub adapters
│   ├── src/lib/engines/    # SymPy client
│   └── src/services/       # Solve mutation + streaming
├── web/                    # React frontend
│   ├── src/components/
│   │   ├── math/           # KaTeXBlock, MathText, DesmosGraph, GeoGebraGraph
│   │   └── solve/          # CommandBar, StepByStep, TheoremBox, GateProgress
│   └── src/hooks/          # useSolveStream, useExternalScript
├── sidecar/                # Python FastAPI (port 8100)
│   └── math_sidecar/
│       ├── routers/        # SymPy, Wolfram, Octave endpoints
│       └── services/       # DSPy router, clients
└── scripts/
    └── dev.sh              # One-command dev startup

License

MIT


Built with RedwoodJS and SymPy

About

Verified-first math orchestration — solve any Kreyszig-level problem with SymPy verification, KaTeX rendering, and interactive graphing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors