A powerful, Apple Notes-inspired application that allows you to draw mathematical equations on a digital canvas and get instant solutions using the power of Google's Gemini AI.
- Infinite Canvas: Draw freely on a responsive, black canvas.
- AI-Powered Solutions: Recognized handwriting and solves math problems instantly using Gemini 3.0.
- Responsive Design:
- Desktop: Full toolbar with inline color/size controls.
- iPad/Tablet: Adaptive layout with bottom toolbar and palette menu for mobile-friendly usage.
- Mobile: Compact bottom toolbar with "Style" popover to maximize screen space.
- Touch Support: Native touch event handling for smooth drawing on iPads and phones.
- Apple-Style UI: Glassmorphic, floating toolbars and smooth transitions.
- Frontend: React, Vite, Tailwind CSS, TypeScript, Mantine UI
- Backend: Python, FastAPI, Google GenAI SDK (Gemini 3.0)
- Tools: Lucide React (Icons), Axios, Pillow (Image Processing)
Follow these steps to set up the project locally.
- Node.js (v18+)
- Python (v3.10+)
- A Google Cloud API Key for Gemini
git clone https://github.com/yourusername/math-notes.git
cd math-notesNavigate to the backend directory and set up the Python environment.
cd backend-cal
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# On Mac/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtConfigure Environment Variables:
Create a .env file in backend-cal and add your Gemini API key:
GEMINI_API_KEY=your_google_api_key_hereRun the Backend Server:
python main.py
# Server will start on http://localhost:8900Open a new terminal and navigate to the frontend directory.
cd frontend-cal
# Install dependencies
npm installConfigure Environment Variables:
Create a .env.local file in frontend-cal if it doesn't exist:
VITE_API_URL=http://localhost:8900Run the Frontend Development Server:
npm run dev
# App will run on http://localhost:5173 (or similiar port)- Select a Tool: Use the Pencil to draw or Eraser to correct mistakes.
- Adjust Style:
- On Desktop: Use the slider and color dots in the top toolbar.
- On Mobile/iPad: Tap the Palette button to open the sizing and color menu.
- Draw: Write a math problem (e.g.,
2 + 2, integrals, linear equations). - Solve: Click the Run (Play) button. The AI will analyze your drawing and overlay the answer in LaTeX format.
- Reset: Click the Reset button to clear the canvas.
This project is configured for seamless deployment on Vercel, hosting both the React Frontend and Python FastAPI Backend in a single repository.
frontend-calas Root: The Vercel project Root Directory must be set tofrontend-cal.vercel.json: Located infrontend-cal/vercel.json, this file handles:- Rewrites: Directs
/calculateAPI requests to the Python backend. - Builds: Configures
@vercel/static-buildfor Vite and@vercel/pythonfor FastAPI.
- Rewrites: Directs
- Serverless Backend: The Python backend runs as a Serverless Function, meaning no separate server is required!
- Push to GitHub: Ensure your latest code is on the default branch.
- Import to Vercel: Select the repository.
- Project Settings:
- Root Directory:
frontend-cal - Environment Variables: Add
GEMINI_API_KEYwith your Google Cloud API Key.
- Root Directory:
- Deploy: Click deploy!
During development, we encountered and resolved several critical issues:
- Root Directory Mismatch: Vercel initially failed to build because it looked for the app in the repo root.
- Fix: Set
frontend-calas the Root Directory in Vercel settings.
- Fix: Set
- Backend 404 / Missing Build: The backend was building but the frontend wasn't (or vice versa).
- Fix: Updated
vercel.jsonto explicitly include both builds:"builds": [ { "src": "package.json", "use": "@vercel/static-build", ... }, { "src": "backend-cal/main.py", "use": "@vercel/python" } ]
- Fix: Updated
- ModuleNotFoundError (Python): The backend crashed on Vercel because it couldn't find local modules like
appsorconstants.- Fix: Added
sys.path.append(...)inmain.pyto ensure the runtime finds the correct folder.
- Fix: Added
- 500 Server Error (Gemini API): The backend would crash if the AI model returned markdown or encountered an error.
- Fix: Implemented robust error handling and Regex-based JSON parsing in
utils.pyto safely extract answers.
- Fix: Implemented robust error handling and Regex-based JSON parsing in
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open-source and available under the MIT License.