# detached-space/totals architecture

> Architecture diagram of the GitHub repository detached-space/totals, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/detached-space/totals
- Repository: https://github.com/detached-space/totals

## Overview

Totals is a local-first Flutter finance app centered on capturing bank SMS, turning them into transactions and balance updates, and presenting that data through accounts, budgets, history, and analytics. The graph also includes documented supporting capabilities: optional data sync, browser access, backup/import-export, security, and Android widgets. The README documents the principal relationships; sampled source excerpts cover Android SMS delegation, widget rendering, and shortcut launch handling, not the Dart runtime wiring, so those implementation links are not asserted beyond documented flows.

Main entry points: [`app/lib/main.dart`](https://github.com/detached-space/totals/blob/playstore-version/app/lib/main.dart) (Flutter app), [`app/lib/repositories/transaction_repository.dart`](https://github.com/detached-space/totals/blob/playstore-version/app/lib/repositories/transaction_repository.dart) (Transactions), [`app/lib/database/database_helper.dart`](https://github.com/detached-space/totals/blob/playstore-version/app/lib/database/database_helper.dart) (Local database), [`app/lib/local_server/server_service.dart`](https://github.com/detached-space/totals/blob/playstore-version/app/lib/local_server/server_service.dart) (Local HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Transaction capture"]
  node_sms_receiver["SMS receiver"]
  node_sms_service["SMS parsing<br/>[sms_service.dart]"]
  node_transaction["Transactions"]
end

subgraph group_finance["Finance management"]
  node_accounts["Accounts"]
  node_categories["Categories"]
  node_budgets["Budgets"]
  node_analytics["Analytics"]
  node_insights["Financial insights"]
  node_spending_map["Spending map"]
end

subgraph group_platform["App platform"]
  node_local_db[("Local database")]
  node_app_ui["Flutter app<br/>[main.dart]"]
  node_auth["Biometric lock<br/>[lock_screen.dart]"]
  node_widgets["Home widgets"]
end

subgraph group_integrations["External access"]
  node_web_server["Local HTTP server"]
  node_data_sync["Optional data sync<br/>[sync_service.dart]"]
  node_export_import["Export and import"]
end

node_user(("User"))
node_bank_sms["Bank SMS"]
node_browser(("Browser client"))
node_backend{{"Configured backend"}}

node_bank_sms -->|"arrives as"| node_sms_receiver
node_sms_receiver -->|"delegates SMS"| node_sms_service
node_sms_service -->|"extracts transactions"| node_transaction
node_transaction -->|"stores locally"| node_local_db
node_accounts -->|"stores locally"| node_local_db
node_user -->|"uses"| node_app_ui
node_app_ui -->|"manages"| node_accounts
node_app_ui -->|"views history"| node_transaction
node_app_ui -->|"tags transactions"| node_categories
node_app_ui -->|"configures"| node_budgets
node_budgets -->|"tracks spending"| node_transaction
node_app_ui -->|"presents analysis"| node_analytics
node_app_ui -->|"presents insights"| node_insights
node_app_ui -.->|"offers opt-in map"| node_spending_map
node_app_ui -->|"secures access"| node_auth
node_app_ui -->|"provides widget data"| node_widgets
node_user -->|"enables server"| node_web_server
node_browser -->|"requests data"| node_web_server
node_web_server -->|"reads finance data"| node_local_db
node_user -.->|"opts in"| node_data_sync
node_data_sync -.->|"pushes selected data"| node_backend
node_user -->|"backs up or restores"| node_export_import
node_export_import -->|"imports and exports"| node_local_db

click node_sms_receiver "https://github.com/detached-space/totals/blob/playstore-version/app/android/app/src/main/kotlin/detached/totals/SafeIncomingSmsReceiver.kt"
click node_sms_service "https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/sms_service.dart"
click node_transaction "https://github.com/detached-space/totals/blob/playstore-version/app/lib/repositories/transaction_repository.dart"
click node_accounts "https://github.com/detached-space/totals/blob/playstore-version/app/lib/repositories/account_repository.dart"
click node_categories "https://github.com/detached-space/totals/blob/playstore-version/app/lib/repositories/category_repository.dart"
click node_budgets "https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/budget_service.dart"
click node_analytics "https://github.com/detached-space/totals/blob/playstore-version/app/lib/screens/analytics_page.dart"
click node_insights "https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/financial_insights.dart"
click node_spending_map "https://github.com/detached-space/totals/blob/playstore-version/app/lib/_redesign/screens/spending_map_page.dart"
click node_local_db "https://github.com/detached-space/totals/blob/playstore-version/app/lib/database/database_helper.dart"
click node_app_ui "https://github.com/detached-space/totals/blob/playstore-version/app/lib/main.dart"
click node_auth "https://github.com/detached-space/totals/blob/playstore-version/app/lib/_redesign/screens/lock_screen.dart"
click node_widgets "https://github.com/detached-space/totals/blob/playstore-version/app/android/app/src/main/kotlin/detached/totals/ExpenseWidgetProvider.kt"
click node_web_server "https://github.com/detached-space/totals/blob/playstore-version/app/lib/local_server/server_service.dart"
click node_data_sync "https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/data_sync/sync_service.dart"
click node_export_import "https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/data_export_import_service.dart"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sms_receiver,node_sms_service,node_transaction,node_user,node_browser toneBlue
class node_accounts,node_categories,node_budgets,node_analytics,node_insights,node_spending_map toneAmber
class node_local_db,node_app_ui,node_auth,node_widgets toneMint
class node_web_server,node_data_sync,node_export_import toneRose
class node_bank_sms,node_backend toneIndigo
```

## Components

### Transaction capture

- [SMS receiver](https://github.com/detached-space/totals/blob/playstore-version/app/android/app/src/main/kotlin/detached/totals/SafeIncomingSmsReceiver.kt): `app/android/app/src/main/kotlin/detached/totals/SafeIncomingSmsReceiver.kt`
- [SMS parsing](https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/sms_service.dart): `app/lib/services/sms_service.dart`
- [Transactions](https://github.com/detached-space/totals/blob/playstore-version/app/lib/repositories/transaction_repository.dart): `app/lib/repositories/transaction_repository.dart`

### Finance management

- [Accounts](https://github.com/detached-space/totals/blob/playstore-version/app/lib/repositories/account_repository.dart): `app/lib/repositories/account_repository.dart`
- [Categories](https://github.com/detached-space/totals/blob/playstore-version/app/lib/repositories/category_repository.dart): `app/lib/repositories/category_repository.dart`
- [Budgets](https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/budget_service.dart): `app/lib/services/budget_service.dart`
- [Analytics](https://github.com/detached-space/totals/blob/playstore-version/app/lib/screens/analytics_page.dart): `app/lib/screens/analytics_page.dart`
- [Financial insights](https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/financial_insights.dart): `app/lib/services/financial_insights.dart`
- [Spending map](https://github.com/detached-space/totals/blob/playstore-version/app/lib/_redesign/screens/spending_map_page.dart): `app/lib/_redesign/screens/spending_map_page.dart`

### App platform

- [Local database](https://github.com/detached-space/totals/blob/playstore-version/app/lib/database/database_helper.dart): `app/lib/database/database_helper.dart`
- [Flutter app](https://github.com/detached-space/totals/blob/playstore-version/app/lib/main.dart): `app/lib/main.dart`
- [Biometric lock](https://github.com/detached-space/totals/blob/playstore-version/app/lib/_redesign/screens/lock_screen.dart): `app/lib/_redesign/screens/lock_screen.dart`
- [Home widgets](https://github.com/detached-space/totals/blob/playstore-version/app/android/app/src/main/kotlin/detached/totals/ExpenseWidgetProvider.kt): `app/android/app/src/main/kotlin/detached/totals/ExpenseWidgetProvider.kt`

### External access

- [Local HTTP server](https://github.com/detached-space/totals/blob/playstore-version/app/lib/local_server/server_service.dart): `app/lib/local_server/server_service.dart`
- [Optional data sync](https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/data_sync/sync_service.dart): `app/lib/services/data_sync/sync_service.dart`
- [Export and import](https://github.com/detached-space/totals/blob/playstore-version/app/lib/services/data_export_import_service.dart): `app/lib/services/data_export_import_service.dart`

### Other components

- **User**
- **Bank SMS**
- **Browser client**
- **Configured backend**

## Connections

- Bank SMS → SMS receiver: arrives as (evidence: `README.md`)
- SMS receiver → SMS parsing: delegates SMS (evidence: `README.md`)
- SMS parsing → Transactions: extracts transactions (evidence: `README.md`)
- Transactions → Local database: stores locally (evidence: `README.md`)
- Accounts → Local database: stores locally (evidence: `README.md`)
- User → Flutter app: uses (evidence: `README.md`)
- Flutter app → Accounts: manages (evidence: `README.md`)
- Flutter app → Transactions: views history (evidence: `README.md`)
- Flutter app → Categories: tags transactions (evidence: `README.md`)
- Flutter app → Budgets: configures (evidence: `README.md`)
- Budgets → Transactions: tracks spending (evidence: `README.md`)
- Flutter app → Analytics: presents analysis (evidence: `README.md`)
- Flutter app → Financial insights: presents insights (evidence: `README.md`)
- Flutter app → Spending map: offers opt-in map (evidence: `README.md`)
- Flutter app → Biometric lock: secures access (evidence: `README.md`)
- Flutter app → Home widgets: provides widget data (evidence: `README.md`)
- User → Local HTTP server: enables server (evidence: `README.md`)
- Browser client → Local HTTP server: requests data (evidence: `README.md`)
- Local HTTP server → Local database: reads finance data (evidence: `README.md`)
- User → Optional data sync: opts in (evidence: `README.md`)
- Optional data sync → Configured backend: pushes selected data (evidence: `README.md`)
- User → Export and import: backs up or restores (evidence: `README.md`)
- Export and import → Local database: imports and exports (evidence: `README.md`)
