Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / calculator / AGENTS.md
| 1 | # AGENTS.md — calculator/ (':calculator') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `calculator/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install calculator (dev by default)._ |
| 6 | - Gradle: :calculator / dir: calculator/ |
| 7 | - Package roots present: ui, widget, domain, platform, network, intents |
| 8 | - Entry files: MainActivity.kt + Route.kt + Navigation.kt (tab destinations: Calculator, Graph, Units) |
| 9 | - Deps: :library:network, :library:widgets |
| 10 | - Metadata: metadata_data/calculator.md (present) |
| 11 | - Rust: no / screenshotTest: yes |
| 12 | |
| 13 | ## Overview |
| 14 | **Purpose:** Modern Material You calculator — scientific/basic modes, function graphing with analysis, and a multi-category unit converter with live currency rates. |
| 15 | **Key features:** |
| 16 | - Scientific + basic keypad with expression history |
| 17 | - Graph page: plots functions with root / intercept / min-max / intersection detection |
| 18 | - Unit converter across many categories incl. live currency rates (`CurrencyApi` over `:library:network`) |
| 19 | - Home-screen widgets for both calculator and unit converter (`:library:widgets` Glance) |
| 20 | **Architecture / data-flow:** Single-screen `MainActivity` hosting `ui/` pages (`CalculatorPage`, `GraphPage`, `UnitConverterPage`) over a `util/` ViewModel + pure expression/graph/units helpers; widget receivers in `widget/` share the same logic. Internet is used only for currency rates. |
| 21 | **Entry points + reading order:** `MainActivity.kt` → `ui/CalculatorPage.kt` → `util/CalculatorViewModel.kt` + `util/CalculatorUiContract.kt` → `util/Expression.kt` / `util/GraphAnalysis.kt` / `domain/UnitRegistry.kt` → `widget/CalculatorGlanceWidget.kt`. |
| 22 | **Gotchas:** |
| 23 | - `util/` is NOT a closed package root — don't add more files there |
| 24 | - Currency rates are the only network call — everything else must stay offline-safe |
| 25 | |
| 26 | ## Key files |
| 27 | ### Root — entry |
| 28 | - com/vayunmathur/calculator/MainActivity.kt |
| 29 | - com/vayunmathur/calculator/Route.kt + Navigation.kt |
| 30 | ### ui/ — keypad, graph, converter pages |
| 31 | - com/vayunmathur/calculator/ui/CalculatorPage.kt |
| 32 | - com/vayunmathur/calculator/ui/CalculatorKeypad.kt |
| 33 | - com/vayunmathur/calculator/ui/CalculatorDialogs.kt (unit-picker sheet; its absolute-time date/time pickers stay local — see the DIALOG LOCAL EXCEPTION in the file) |
| 34 | - com/vayunmathur/calculator/ui/GraphPage.kt |
| 35 | - com/vayunmathur/calculator/ui/UnitConverterPage.kt |
| 36 | ### util/ — ViewModel + pure engine |
| 37 | - com/vayunmathur/calculator/util/CalculatorViewModel.kt |
| 38 | - com/vayunmathur/calculator/util/CalculatorUiContract.kt |
| 39 | - com/vayunmathur/calculator/util/Expression.kt — expression parsing/eval |
| 40 | - com/vayunmathur/calculator/util/GraphAnalysis.kt — root/intercept/min-max/intersection |
| 41 | - com/vayunmathur/calculator/domain/UnitRegistry.kt |
| 42 | - com/vayunmathur/calculator/domain/BasicUnitCategories.kt |
| 43 | - com/vayunmathur/calculator/util/CurrencyApi.kt — only network call |
| 44 | - com/vayunmathur/calculator/util/Formatting.kt |
| 45 | ### intents/ — assistant IPC (validated contracts over the engines above) |
| 46 | - com/vayunmathur/calculator/intents/CalculatorContract.kt — caps + validation (expression ≤200 ch, result ≤100 ch); evaluation reuses `domain/Expression`, conversion reuses `domain/UnitRegistry` + live currency category |
| 47 | - com/vayunmathur/calculator/intents/EvaluateIntent.kt — `calculator_evaluate` (scalar result) |
| 48 | - com/vayunmathur/calculator/intents/ConvertUnitIntent.kt — `calculator_convert_unit` (the app's one network call, live rates, only for currency pairs) |
| 49 | ### widget/ — Glance widgets sharing the same logic |
| 50 | - com/vayunmathur/calculator/widget/CalculatorGlanceWidget.kt |
| 51 | - com/vayunmathur/calculator/widget/CalculatorGlanceWidgetReceiver.kt |
| 52 | - com/vayunmathur/calculator/widget/CalculatorKeyAction.kt |
| 53 | - com/vayunmathur/calculator/widget/CalculatorWidgetSettingsActivity.kt |
| 54 | - com/vayunmathur/calculator/widget/UnitsGlanceWidget.kt |
| 55 | - com/vayunmathur/calculator/widget/UnitsGlanceWidgetReceiver.kt |
| 56 | - com/vayunmathur/calculator/widget/UnitsWidgetActions.kt |
| 57 | |
| 58 | ## Verify (this module only) |
| 59 | ``` |
| 60 | ./gradlew :calculator:compileDevKotlin |
| 61 | ./gradlew :calculator:lint |
| 62 | ./gradlew :calculator:checkMetadata |
| 63 | ``` |