Inspiration
We both take Calc II, and our friends get stuck a course earlier, in precalculus. Office hours exist, but at midnight before a quiz we want to know right now whether our steps are right.
AI chatbots are tedious for this: photograph the page, write a prompt, re-prompt. Then they dump the whole solution when we only wanted to know where we went wrong. And they aren't reliable. When we gave Gemini a handwritten solution to
$$\int \sin^3 x \, dx$$
it got the final answer right but blamed a term that was actually correct. Our real mistake was somewhere else. If we had trusted it, we would have "fixed" the right part.
We wanted a tool that checks our own work, points at the first wrong line, and only helps as much as we ask, so we improve instead of copying answers.
What it does
- Write your solution by hand, one step per line, on a ruled canvas in any browser. It works with a stylus on an Android tablet, and palm and finger touches are ignored, so you can rest your hand while writing.
- Three courses: Precalculus, Calculus I and Calculus II.
- Pick how much help you want before checking:
| Level | Name | What you get |
|---|---|---|
| 1 | Walkthrough | Which line is wrong, why, and how to fix it |
| 2 | Pinpoint | Which line is wrong and why; you fix it |
| 3 | Nudge | One guiding question, no verdict |
| 4 | Check | Only correct or incorrect |
| 5 | Exam | Nothing until you submit; then a full review, and the problem locks |
- Press Check. Mathwise reads each handwritten line, shows you what it read, and highlights the first wrong line on your handwriting. Lines that correctly follow from an earlier mistake are not flagged, the way an exam grader gives "error carried forward" credit.
- Stuck? Ask for a hint. Each hint steps down one level, without spoiling more than you asked for.
- Reread the right section. Each mistake links to the matching section of a free OpenStax textbook.
- History keeps your checked problems in the browser.
How we built it
- Frontend: React, TypeScript, Vite and Tailwind. The canvas uses Pointer Events: it accepts the pen (and a mouse on laptops), ignores touch for palm rejection, and uses coalesced events and pressure for smooth ink. Math is rendered with KaTeX.
- Backend: Python and FastAPI, deployed on Modal as one HTTPS web app. The Gemini key is a Modal secret.
- Gemini API, in two separate calls:
- Transcription: each row is cropped into its own image. The prompt tells Gemini to transcribe exactly what is written and never fix mistakes, because vision models tend to silently correct student errors, which hides the very mistake we need to find.
- Checking: Gemini analyzes the steps once and returns structured JSON: verdict, first wrong line, mistake type, explanation, fix and a guiding question.
- Help levels are plain code, not AI: the server stores the one analysis and only sends the fields your level allows. That keeps the five levels consistent, and hints don't need another AI call.
- Reliability: if a Gemini model is overloaded or too slow, the backend falls back to another Gemini model instead of failing.
- Unit tests cover the levels, hints, transcription and fallbacks, with Gemini mocked.
Challenges we ran into
- Gemini overload during the event. We got 503 "high demand" and 429 rate-limit errors, and one check took over 3 minutes because the SDK quietly retried 5 times. We turned off the SDK's retries, added a time limit per model, and fall back through several Gemini models. A slow check now finishes in seconds.
- Every live call failed at first with a 400 error: our Pydantic schemas added
additionalPropertiesto the schema Gemini receives, and Gemini rejects it. Our tests mocked Gemini, so only a real call found it. - Transcription took 41 seconds for six lines. Lowering the model's thinking level made it about 4 seconds, with identical output.
- AI finds the wrong line only part of the time. Research benchmarks (ProcessBench and others) put AI first-error detection at roughly 40–65%, and a small model blamed the wrong line in our own test. We use a stronger model for checking.
- Strokes that cross the ruled lines, like an integral sign or a fraction, can land in the wrong row.
- Promised cloud credits didn't work, so we built on the Gemini free tier.
Accomplishments that we're proud of
- On our handwritten sin³x test, Mathwise read the lines exactly as written, mistake included, and blamed the correct line: the one the plain Gemini app got wrong.
- Real palm rejection in a plain web page on an Android tablet, without a native app.
- Five help levels that stay consistent, because one analysis is filtered instead of asking the AI five different ways.
- A live HTTPS deployment that survives model overload, at our first hackathon.
What we learned
- Mocked tests aren't enough with an AI API: the first real call found a bug every test missed.
- Reading handwriting and judging math are separate problems. Splitting them made each one easier to check and to fix.
- AI is good at explaining and bad at being sure. Anything that must be right (which fields a level shows, fallbacks, links) should be ordinary code.
- How to deploy on Modal, use Gemini structured output, and work with Pointer Events and stylus pressure.
What's next for Mathwise
- Math proof, not just AI opinion: use SymPy to check the final answer and show a counterexample for the blamed line ("at x = 1, line 3 and line 4 disagree").
- Circle the exact wrong term in red pen, not just the whole line.
- Calculus III. We haven't taken it yet, so we can't verify its problems ourselves.
- An "incomplete but on track" result, so a stuck student can get a nudge on half a solution.
- An instructor link that sets a maximum help level for an assignment.
Built With
- built-with-(14-tags)-python
- fastapi
- gemini-api
- google-genai
- html5
- katex
- modal
- pointer-events
- pydantic
- pytest
- react
- tailwindcss
- typescript
- vite
Log in or sign up for Devpost to join the conversation.