Math Quest:互動式 3D/AR 數學學習
Math Quest: Interactive 3D / AR maths learning
Math Quest 是一款以互動式 3D 幾何模型教授幾何的 mobile-first 網頁應用程式,支援旋轉模型及在支援手機上使用 AR。應用程式提供 10 堂免費課程、2 堂付費進階課程、測驗和導師提示,額外內容可在確認 M-Pesa 付款後解鎖。項目以 Next.js 14、MongoDB Atlas 和 Safaricom Daraja 建置,並以 Gemma 提供學習提示及管理摘要。
Posted on Oct 18 AI-assisted
Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle
What I Built
Well, at times learning is hard for some people, especially Mathematics (and maybe Physics 😅️ ) but we'll focus on some math. Most people would love to learn with visuals in order to make it easier and maybe after a while they will pay for it with our local currency ( Kenya ). 3D models help interactivity and learners can get detailed experience especially for spheres and 3d shapes. 3D artists can also get some coffee( payment appreciation) for their contribution to better models.
Math Quest is a mobile-first web app that teaches geometry through interactive 3D solids—cubes like spheres, cylinders, cones, pyramids, hemispheres, and compass:
- Learners read a short explanation ( there's also a voice narrator ), explore a diagram and a rotatable model (with optional AR on supported phones), answer a quick check, and request tutor hints when stuck.
- Ten lessons are free; extra content unlocks after a confirmed M-Pesa payment. Accounts use email OTP to reduce fake sign-ups.
- An admin dashboard tracks users, verified payments, revenue, and voice-service errors.
- A public artists gallery lets 3D creators submit model links and share PayPal or M-Pesa details for tips. Built with Next.js, MongoDB, and Safaricom Daraja, deployable on Render. Currently I am using publicly available models but I have credited the authors within the website as per their licenses.
The problem
- Learners need geometry they can See and Move — not only flat textbook diagrams
- 3D artists need a way to showcase their skills
Who's using it
- Pupils & parents - Short quests on any phone and free core lessons
- Teachers / tutors - Admin insights
- 3D artists - Submit models and get tips (PayPal / Mpesa)
Features map
Math Quest Landing page
│
├── Learning
│ ├── 10 free 3D geometry lessons
│ ├── 2 paid advanced lessons
│ ├── Interactive diagrams
│ ├── GLB models + AR (where supported)
│ ├── Quiz + mastery progress
│ └── Step-by-step tutor hints
│
├── Access & trust
│ ├── Email OTP registration
│ ├── Session auth (JWT cookie)
│ └── M-Pesa unlock (confirmed only)
│
├── Community
│ ├── Artists submit model links
│ └── Buy-me-a-coffee (PayPal / M-Pesa)
│
└── Ops
├── Admin: users, revenue, payments
├── Failure analytics
└── Artist approve / reject
Demo
Here is a link from Render : https://mathquest-hlil.onrender.com/
Code
Here is my code of which I have included an example of what is in my .env file for anyone to try out and run on local to at least view the admin on local ( My email is the only admin on Render ).
Math Quest
Interactive 3D geometry lessons in the browser — rotate models, optional AR, tutor hints, email OTP sign-up, M-Pesa unlock, and an admin dashboard with Gemma briefing.
| Route | What |
|---|---|
/ |
Landing page |
/learn |
Lessons |
/artists |
3D artist gallery + tips (PayPal / M-Pesa) |
/admin |
Analytics, payments, AI logs, approvals |
Stack: Next.js 14 · TypeScript · MongoDB Atlas · Safaricom Daraja · Render
Install
Fork the repo
git clone <your-repo-url> cd math-quest cp .env.example .env.local # fill in at least JWT_SECRET (and MONGODB_URI for accounts/payments) npm install npm run dev
Open http://localhost:3000.
| Command | Purpose |
|---|---|
npm run dev |
Local development |
npm run build |
Production build |
npm start |
Run production build |
Environment
Copy .env.example → .env.local (local) or set the same keys on Render.
Add your keys.
Admin
Sign in with an email listed in ADMIN_EMAILS, then open /admin.
Gemma (if configured) summarises highlights, what to…
How I Built It
- I used local Ollama and installed Gemma model
- I used local Gemma for improving my local project files
- I used Gemma to provide hints for learners in the project using API from Google AI studio
- I used ElevenLabs text-to-speech free credit for audio for the readers who also need articulation. Some other educational voice ID was not free so I used the free one provided in Developers dashboard
- I used Gemma-powered admin briefing that summarizes highlights, issues to check, and pending approvals using API from Google AI studio.
- I use MongoDB to preserve lesson history , API errors and user data
Project Tech stack
Layer | Choice
--------------------------------------------------------------
Frontend | "Next.js 14 (App Router), TypeScript, CSS", Gemma
3D / AR | Google <model-viewer> + .glb
Backend | Next.js API routes
Database | MongoDB Atlas
Payments | Safaricom Daraja (STK Push + Query + callback)
Auth | Email OTP + JWT cookie
Audio | ElevenLabs + browser fallback
Hosting | Render
_______________________________________________________________
List of screens and controls
- Landing page
| Control | What it does |
|---|---|
| Header | Header. |
| Start learning | Opens learning page. |
| 🎨 Artists gallery | Opens artists page. |
| Feature cards | Information only. |
| *Footer * | Footer. |
- Header
| Control | What it does |
|---|---|
| Theme toggle | Light / dark theme. |
| Sign in | Opens auth modal |
| Sign out | Ends session; progress no longer saves to the cloud. |
| Unlock with M-Pesa (or pay entry) | Opens M-Pesa payment modal. |
| Admin (admin users only) | Opens admin dashboard. |
- Lessons List
| Control | What it does |
|---|---|
| Free lesson row | Selects lesson: content, diagram, 3D model, quiz. |
| Paid / locked lesson row | Asks for M-Pesa unlock if not paid; opens lesson if paid or admin. |
| Progress marks | Show saved attempts/mastery when signed in. |
- Lessons Workspace
| Control | What it does |
|---|---|
| Lesson title & summary | Topic overview. |
| Lesson body text | Teaching content. |
| Diagram (LessonVisual) | SVG preview of the solid. |
| 3D model viewer | Drag to rotate, scroll to zoom. Background always dark. |
| View in your space | Opens AR on supported phones. |
| Model credit line | Shows 3D model author / licence. |
| Play audio | Speaks lesson text (ElevenLabs or browser voice if there is API error). |
| Answer options | Select one multiple-choice answer. |
| Check answer | Marks right/wrong, shows explanation, saves progress if signed in. |
| Get a hint | Gemma tutor hint. Up to 3 levels. |
- Footer
| Control | What it does |
|---|---|
| Home | Go to home. |
| Lessons | Lessons page. |
| Artists gallery | Go to artists gallery. |
| Admin | Go to admin dashboard. |
| Submit a 3D model | Go to artists submit form. |
- Auth modal
| Control | What it does |
|---|---|
| Sign in | Log in with email + password (if email verified). |
| Need an account? Register | Switch to registration form. |
| Name / Email / Password | Account fields. |
| Send verification code | Saves account and sends 6-digit OTP email (or logs OTP if Resend not set). |
| Verification code (OTP) | Enter the 6-digit code. |
| Verify & continue | Confirms OTP, signs you in, closes modal. |
| Resend code | Sends a new OTP (expires in 10 minutes). |
| Back to sign in | Return to login form. |
| Already registered? Sign in | Switch to login form. |
- Pay modal (M-Pesa)
| Control | What it does |
|---|---|
| M-Pesa phone number | Number that receives the STK PIN prompt. |
| Pay with M-Pesa | Starts STK Push. Order stays pending until success. |
| I’ve paid — check status | Checks Daraja/DB. Unlocks only if payment completed. |
| Close | Closes modal without unlocking. |
- Artists page — gallery
| Control | What it does |
|---|---|
| ← Back to Math Quest | Go to home. |
| Open 3D model | Opens model URL in a new tab. |
| ☕ Buy me a coffee (PayPal) | Opens PayPal donate / paypal.me for that artist. |
| 📱 M-Pesa: … | Copies M-Pesa number for Send Money. |
- Artists page — submit form
| Control | What it does |
|---|---|
| Display name | Public artist name. |
| Contact for moderation. | |
| Model title | Name of the model. |
| Model URL | Public https link to .glb or model page. |
| Bio (optional) | Short description. |
| License (optional) | e.g. CC-BY, CC0. |
| PayPal | Email or paypal.me for tips. |
| M-Pesa number | Phone for tips (at least one of PayPal or M-Pesa required). |
| Submit for review | Saves as pending until admin approves. |
- Admin — Gemma briefing
| Control | What it does |
|---|---|
| Summary | Short overview of platform health. |
| Highlights | Key stats (users, revenue, AI). |
| What to check | Issues to review (pending pay, OTP, errors). |
| Approvals pending | Artist queue status. |
| Open Artists & tips | Switches to Artists tab. |
- Admin — tabs
| Control | What it does |
|---|---|
| Overview | KPI cards + metrics table. |
| Payments | Confirmed M-Pesa payments table. |
| Users | Recent users (verified / paid). |
| AI services | Gemma + ElevenLabs event log table. |
| Artists & tips | Submissions + PayPal/M-Pesa + approve/reject. |
- Admin — artist actions
| Control | What it does |
|---|---|
| Approve | Publishes models. |
| Reject | Keeps model off the public gallery. |
| ← Home | Go to home. |
| Lessons | Go to lessons page. |
Why Does Open Innovation Matter?
The project is created based on open source models and it makes these possible :
Access: Runs in the browser on shared or low-end phones—no app install.
Local payments: M-Pesa matches how families in Kenya already pay.
Pedagogy: 3D + hints support spatial thinking better than static notes alone.
Integrity: OTP reduces bot sign-ups; only confirmed payments unlock content.
Creators: Artists can share better models and receive tips without the app storing huge binary files.
My Agent Session
My First User
Prize Categories
- Best Use of Render
- Best Use of Gemma
- Best Use of ElevenLabs
- Best Use of MongoDB Atlas
來源:DEV Community · dev.to