Skip to content

tusharcancodehere/App_Dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator App

Architectural Plan

To keep the project maintainable and scalable, the application is divided into three layers:

1. UI Layer (Flet)

Responsible for:

  • User interactions
  • Display updates
  • Event handling

2. Logic Layer

Responsible for:

  • Calculator state management
  • Tracking operands and operators
  • Processing user input

3. Utility Layer

Responsible for:

  • Mathematical operations
  • Precision handling
  • Error handling
  • Secure calculations without using eval()

Development Roadmap

Phase 1 — State Management

Goal: Build the calculator engine.

  • Create CalculatorEngine
  • Store current operand
  • Store previous operand
  • Store selected operator
  • Handle input flow before pressing "="

Phase 2 — Refined UI

Goal: Improve the user experience.

  • Replace standard buttons with custom Container widgets
  • Create a minimalist layout
  • Improve spacing and alignment
  • Add consistent styling

Phase 3 — Robust Parsing

Goal: Make calculations reliable.

  • Implement calculate()
  • Handle division by zero
  • Handle invalid input
  • Improve floating-point precision

Phase 4 — History Logging

Goal: Track previous calculations.

  • Add history panel
  • Create scrollable ListView
  • Save operations locally
  • Load history on startup

Project Structure

calculator_app/
├── main.py           # Flet entry point
├── engine.py         # Calculator logic
├── styles.py         # Colors, fonts, themes
└── history.json      # Optional persistent storage

Technical Strategy: Avoiding eval()

Instead of evaluating raw strings, operators are mapped directly to Python functions.

import operator

ops = {
    "+": operator.add,
    "-": operator.sub,
    "*": operator.mul,
    "/": operator.truediv,
}

# Example
# result = ops[operator_symbol](float(num1), float(num2))

Benefits

  • Safer than eval()
  • Easier to debug
  • Easier to extend
  • Better control over errors

Implementation Notes

UI Direction

  • Material Design 3 inspired
  • Dark theme
  • High contrast colors
  • Minimalist layout

State Flow

INPUTTING_FIRST_NUMBER
        ↓
WAITING_FOR_OPERATOR
        ↓
INPUTTING_SECOND_NUMBER
        ↓
CALCULATE_RESULT

Input Validation

Use regex validation to ensure user input is valid before passing values to the calculation engine.


Current Status

Feature Status
Project Structure ⬜ Planned
Calculator Engine ⬜ Planned
UI Components ⬜ Planned
Parsing & Validation ⬜ Planned
History Logging ⬜ Planned
Testing ⬜ Planned

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages