Problem
This started from a simple need: compute area, perimeter, surface area and volume for basic 2D and 3D shapes in one place, not lose the results, and be able to use the same calculation logic from both a command line and a browser. The real problem wasn't the maths — the formulas are trivial — it was settling the output into a single structure and serving it identically to three different consumers: the console, a JSON file, and a web request.
Approach
A single file holds a GeometryCalculator class: one method per shape (square, rectangle, circle, triangle, cube, sphere), all returning the same dictionary shape — shape, inputs, calculations, units and timestamp. Each result is also appended to the instance's calculations_history list, which can be written to JSON and read back. The web layer is a thin Flask shell riding on that same dictionary: /api/calculate, /api/history and /api/save hand the identical structure back as JSON. Flask is wrapped in try/except ImportError, so the program doesn't die when it isn't installed. The entry point branches on the argument: pass `web` and you get the server on 127.0.0.1:5000, pass nothing and you get the console menu.
Decisions and trade-offs
- I required every calculation to return the same dictionary type (shape / inputs / calculations / units / timestamp), because console printing, JSON persistence and the web API should all consume one structure; the alternative was a bespoke return type per shape, which branches the printing and serialisation code once per shape. Embedding the units (cm², cm) inside the result was deliberate too — a number shouldn't travel separately from its unit.
- I made Flask an optional rather than required dependency: the import sits in try/except ImportError, and when it's missing a same-named run_web_server function is defined that prints the install command instead. I didn't want someone who only wants to compute an area to install a web stack; the alternative was listing Flask as a requirement, which needlessly weighs down the tool's core use.
- I put input validation inside each method rather than the constructor (side <= 0 raises ValueError), so the error says which measurement of which shape was wrong; the alternative of one generic validator produced context-free messages like "must be positive".
- I wrote history to a JSON file rather than a database (hesaplama_gecmisi.json), because for a single-user calculator one file covers the persistence need and the result dictionary already serialises to JSON one-to-one; SQLite was the alternative and would have been a needless layer at this scale.
Outcome
NO MEASUREMENT — the repo has no tests, benchmarks or recorded runs, so I claim no numbers. What exists: a single file computing area, perimeter, surface area and volume for six shapes (square, rectangle, circle, triangle, cube, sphere), one uniform result structure carrying unit labels, in-session calculation history, JSON save/load, and an optional Flask interface launched with `geometry_calculator web` (127.0.0.1:5000, /api/calculate + /api/history + /api/save). ONE THING THIS PAGE MUST CORRECT: the project is NOT Streamlit-based. The word streamlit appears nowhere in the source (zero matches); the imports are math, json, datetime, os, sys, and optionally Flask. The web layer is Flask. The repo was last updated 2025-06-21, making it one of the oldest active projects in the inventory — it should be presented as learning-period work rather than a showcase piece.
Stack
Sources
Every technical claim on this page was derived from the sources below.
- https://github.com/msgxr/GeometryCalculator
- https://github.com/msgxr/GeometryCalculator/blob/main/README.md
- https://github.com/msgxr/GeometryCalculator/blob/main/geometry_calculator
What I could not verify
Points I could not confirm while writing. I keep them visible rather than asserting them silently.
- KAYNAK ÇELİŞKİSİ — DÜZELTİLMESİ GEREKİYOR: lib/projects.ts hem açıklamada ("Python/Streamlit tabanlı interaktif web uygulaması") hem stack'te ('Streamlit') Streamlit diyor; GitHub depo açıklaması ve README de aynı iddiayı taşıyor. KOD BUNU DESTEKLEMİYOR: dosyada streamlit hiç geçmiyor, web katmanı Flask. Yani yanlış olan depo README'si/açıklaması ve site envanteri; kod doğru kaynak. Hem kart metni hem stack düzeltilmeli (Streamlit → Flask, opsiyonel).
- Kodda doğrulanmış yapısal not: ana dosyanın adı uzantısız — 'geometry_calculator', .py değil. Bu yüzden modül olarak import edilemez, yalnızca doğrudan çalıştırılabilir. Depoda requirements.txt de yok, yani opsiyonel Flask bağımlılığı hiçbir yerde bildirilmemiş.
- DOGRULANAMADI: Dosya başlığındaki 'Author: Python Geometri Hesaplayıcı' alanı bir kişi adı değil, doldurulmamış şablon değeri; 'Version: 1.0' ibaresi de bir sürüm etiketi/yayın kaydına dayanmıyor. Bunlardan yazarlık veya sürüm iddiası çıkarılmamalı.
- Canlı demo YOK (GitHub Pages API 404). Flask modu yalnızca 127.0.0.1:5000'de yerel çalışıyor ve app.run(debug=True) ile başlatılıyor — barındırılmış bir örnek yok, debug modu da barındırmaya uygun değil.
- lib/projects.ts bu projeyi featured: false olarak işaretliyor. Görevde "mümkünse" incelenmesi istendiği için içerik hazırladım, ancak depo durumu (2025-06-21, test yok, uzantısız dosya, hatalı README) bir vaka sayfasını taşımaya zayıf; öne çıkarılmaması mevcut haliyle doğru karar.