MathNotes AI is a Flask note-taking workspace for math study. It combines rich notes, file uploads, OCR extraction, Firebase-backed storage, and a Gemini-powered tutor that can answer questions using the current note and uploaded material as context.
- User accounts and note storage through Firebase
- Rich note editor with autosave-style API endpoints
- Image, clipboard image, and PDF upload support
- OCR preprocessing with OpenCV, Pillow, PyMuPDF, PyPDF2, and Tesseract
- OCR confirmation flow so extracted text can be reviewed before it is used
- Gemini chat assistant with note content, file text, and recent chat history as context
- Per-note chat history saved in Firebase
- Python, Flask
- Firebase Admin SDK, Realtime Database, and Storage
- Google Gemini API
- Tesseract OCR, OpenCV, Pillow, PyMuPDF, PyPDF2
- HTML templates, CSS, and browser JavaScript
Install Tesseract OCR first. On Windows, the common installer is available from the UB Mannheim Tesseract builds. Make sure the tesseract executable is available on your PATH.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Copy-Item .env.example .env
python app.pyAdd a Firebase service account JSON locally and set FIREBASE_SERVICE_ACCOUNT_PATH to that file. Do not commit the service account file.
| Name | Purpose |
|---|---|
FLASK_SECRET_KEY |
Secret used to sign Flask session data |
FIREBASE_SERVICE_ACCOUNT_PATH |
Local path to a Firebase Admin service account JSON |
FIREBASE_DATABASE_URL |
Firebase Realtime Database URL |
FIREBASE_STORAGE_BUCKET |
Firebase Storage bucket |
GEMINI_API_KEY |
Google Gemini API key |
FLASK_DEBUG |
Set to 1 for local debug mode |
PORT |
Flask port, defaults to 8080 |
The app treats uploaded content as part of a note's study context. OCR output is stored alongside each file, then consolidated into a single context block for the assistant. This keeps AI responses grounded in the user's actual materials while preserving a review step for imperfect OCR.
No service-account files or API keys are committed. Runtime credentials are loaded from environment variables or local ignored files. Rotate any credentials that were ever committed before using this project in a public setting.
- Replace the simplified login flow with Firebase client-side sign-in and secure ID-token verification
- Add automated tests for OCR preprocessing, upload validation, and assistant context assembly
- Add file-size and file-type limits for safer uploads
- Add note export to Markdown or PDF