An intelligent web application that allows users to upload images of math problems and receive detailed, step-by-step solutions powered by Claude AI with vision capabilities.
- Image Upload: Drag-and-drop or click to upload images of math problems
- AI-Powered Analysis: Uses Claude 3.5 Sonnet with vision to read and understand math problems from images
- Step-by-Step Solutions: Provides detailed explanations for each step of the solution
- Modern UI: Clean, responsive interface that works on desktop and mobile devices
- Multiple Image Formats: Supports PNG, JPG, JPEG, GIF, and WEBP files
The app features:
- Clean upload interface with drag-and-drop support
- Image preview before solving
- Loading state while processing
- Formatted solution display with step-by-step breakdown
- Error handling for invalid inputs
- Backend: Python with Flask
- Frontend: HTML5, CSS3, JavaScript (Vanilla)
- AI: Anthropic Claude API with vision capabilities
- Image Processing: Pillow (PIL)
- Python 3.8 or higher
- Anthropic API key (Get one here)
For a quick setup, you can use the provided startup scripts:
Linux/Mac:
chmod +x run.sh
./run.shWindows:
run.batThese scripts will automatically:
- Create a virtual environment if needed
- Install all dependencies
- Start the Flask server
Just make sure you have a .env file with your API key first!
git clone <repository-url>
cd Test-JDP# On Linux/Mac
python3 -m venv venv
source venv/bin/activate
# On Windows
python -m venv venv
venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the root directory:
cp .env.example .envEdit the .env file and add your Anthropic API key:
ANTHROPIC_API_KEY=your_actual_api_key_here
FLASK_ENV=development
FLASK_DEBUG=True
MAX_CONTENT_LENGTH=16777216
To get an API key:
- Go to https://console.anthropic.com/
- Sign up or log in
- Navigate to API Keys section
- Create a new API key
- Copy and paste it into your
.envfile
python app.pyThe application will start on http://localhost:5000
- Open your browser and navigate to
http://localhost:5000 - Click the upload area or drag and drop an image of a math problem
- Click "Solve Math Problem"
- Wait for the AI to analyze and solve the problem
- View the step-by-step solution
- PNG (.png)
- JPEG (.jpg, .jpeg)
- GIF (.gif)
- WebP (.webp)
Maximum file size: 16MB
Serves the main application interface
Analyzes and solves a math problem from an uploaded image
Request:
- Method: POST
- Content-Type: multipart/form-data
- Body: image file
Response:
{
"success": true,
"solution": "Step-by-step solution text..."
}Health check endpoint
Response:
{
"status": "healthy",
"api_configured": true
}Test-JDP/
├── app.py # Flask application and API endpoints
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
├── .env # Environment variables (create this)
├── .gitignore # Git ignore rules
├── README.md # This file
├── templates/
│ └── index.html # Main HTML template
├── static/
│ ├── styles.css # Application styles
│ └── script.js # Frontend JavaScript
└── uploads/ # Temporary upload directory
└── .gitkeep
- Upload: User uploads an image containing a math problem
- Encoding: The image is read and base64-encoded
- AI Analysis: The encoded image is sent to Claude API with vision capabilities
- Problem Solving: Claude analyzes the image, identifies the math problem, and solves it step-by-step
- Display: The solution is returned and displayed in a formatted, easy-to-read manner
The application handles various error scenarios:
- Invalid file types
- Files exceeding size limits
- Missing API key configuration
- Network errors
- AI processing errors
All errors are displayed to the user with helpful messages.
The app runs in debug mode by default when using python app.py. This provides:
- Auto-reload on code changes
- Detailed error messages
- Debug toolbar
ANTHROPIC_API_KEY: Your Anthropic API key (required)FLASK_ENV: Set to 'development' or 'production'FLASK_DEBUG: Enable/disable debug modeMAX_CONTENT_LENGTH: Maximum file upload size in bytes (default: 16MB)PORT: Server port (default: 5000)
- The app validates file types and sizes before processing
- Uploaded files are read into memory and not permanently stored
- API keys are stored in environment variables, never in code
- CORS is enabled for development (configure for production use)
- Make sure you've created a
.envfile - Verify your
ANTHROPIC_API_KEYis set correctly - Restart the Flask server after updating
.env
- Check the file size is under 16MB
- Verify the file format is supported (PNG, JPG, JPEG, GIF, WEBP)
- Ensure the
uploads/directory exists
- Make sure port 5000 is not in use
- Verify all dependencies are installed:
pip install -r requirements.txt - Check Python version is 3.8 or higher
Potential features for future versions:
- Support for handwritten math problems
- Multiple problem detection in a single image
- Solution export (PDF, text file)
- Problem history and favorites
- Support for different math subjects (calculus, algebra, geometry, etc.)
- LaTeX rendering for mathematical notation
- User accounts and problem-saving functionality
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions, please open an issue on the GitHub repository.
- Powered by Anthropic Claude AI
- Built with Flask