A user-friendly web application built with Flask that allows you to calculate the area and volume of various 2D and 3D geometric shapes with customizable units.
- 2D Shapes: Circle, Rectangle/Square, Triangle (Right, Equilateral, Isosceles, Scalene, ASA/SAS), Trapezium, Parallelogram, Pentagon, Hexagon, Rhombus, Ellipse, Sector.
- 3D Shapes: Sphere, Cylinder, Cuboid, Cone, Pyramid (Surface Area & Volume).
- Dynamic Conversions: Native support for Meters, Centimeters, Millimeters, Inches, and Feet.
- Compound Geometry Parsing: user can get answer for messy and hand-drawn complex and compound geometries by uploading/taking image of the sketch or printed shapes using the advanced Vision-Language Model (VLM). (e.g., a rectangle with an attached semicircle).
- Zero-Retention Architecture: Images are processed strictly in memory using the
google-genaiSDK and are never stored on the server and can handle ~1000 requests/day. - Interactive "Review & Correct" UI: The frontend dynamically generates an input form based on the AI's JSON output, allowing the user to review detected measurements and manually input any missing dimensions before executing the final math.
- Webpage screenshot

The calculator is live on Hugging Face Spaces: 👉 Geometry Calculator
-
Clone the repository:
git clone https://huggingface.co/spaces/Deep7285/Geometry-Calculator cd Geometry-Calculator -
Create and activate a virtual environment:
# On Windows: python -m venv venv .\venv\Scripts\activate # On macOS/Linux: python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Setup Environment Variables:
This app requires a Google Gemini API Key to process sketches.
i. This app requires a Google Gemini API Key to process sketches.
ii. Add your API key:GEMINI_API_KEY=your_actual_api_key_here
(Note: The .env file is included in .gitignore to prevent secret leakage).
-
Run the Flask application: for testing run the following in the terminal
python app.py
this will open the localhost for test environment
-
Open your web browser and navigate to
http://127.0.0.1:5000/.
This project includes a production-ready Dockerfile. To run it containerized:
docker build -t geometry-calculator .
docker run -p 7860:7860 -e GEMINI_API_KEY=your_key_here geometry-calculator - Backend: Python 3.11, Flask
- AI Integration: Google GenAI SDK (
gemini-2.5-flash) - Computer Vision Processing: OpenCV, Pillow, Numpy
- Production Server: Gunicorn
- Frontend: HTML5, CSS3 (Flexbox), Vanilla JavaScript (Dynamic DOM Manipulation)
- Deployment: Docker Containerized, hosted via Hugging Face Spaces