# devopstem/plnasmartcheck architecture

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

- Interactive diagram: https://gitdiagram.com/devopstem/plnasmartcheck
- Repository: https://github.com/devopstem/plnasmartcheck

## Overview

PLNA Smart Check is an Android receipt and purchase tracker. Its main workflow captures a receipt by QR or image, recognizes and parses it, lets the user review it, then stores it locally and synchronizes with Firestore when online. Other documented capabilities include account and preference management, expense browsing and editing, product-health labels, and period-based statistics. The graph combines README-described capabilities with indexed or excerpted source relationships; links for unsampled implementation details rely on the README rather than inspected code.

Main entry points: [`app/src/main/java/com/plna/smartcheck/ui/scan/QrScanScreen.kt`](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/scan/QrScanScreen.kt) (Receipt scan UI), [`app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt`](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt) (Local expense repository), [`app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt`](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt) (Expense sync manager), [`app/src/main/java/com/plna/smartcheck/MainActivity.kt`](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/MainActivity.kt) (Main activity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and UI"]
  node_application["Application startup<br/>[PlnaApplication.kt]"]
  node_container["Dependency container<br/>[AppContainer.kt]"]
  node_activity["Main activity<br/>[MainActivity.kt]"]
  node_factory["ViewModel factory"]
  node_home["Expense list and detail<br/>[HomeScreen.kt]"]
  node_profile["Profile screen<br/>[ProfileScreen.kt]"]
end

subgraph group_capture["Receipt capture"]
  node_scan["Receipt scan UI<br/>[QrScanScreen.kt]"]
  node_qr["QR analyzer"]
  node_ocr["Russian OCR engine"]
  node_receiptparse["Text receipt parser<br/>[ReceiptParser.kt]"]
  node_qrparse["QR receipt parser<br/>[QrReceiptParser.kt]"]
  node_receiptapi["Receipt API client"]
  node_review["Receipt review"]
end

subgraph group_data["Expense data"]
  node_local["Local expense repository"]
  node_room[("Room expense storage<br/>[ExpenseEntities.kt]")]
  node_cloudrepo["Cloud expense repository"]
  node_sync["Expense sync manager"]
  node_network["Network monitor<br/>[NetworkMonitor.kt]"]
end

subgraph group_account["Account and settings"]
  node_accountui["Profile view model"]
  node_accountrepo["Account repository"]
  node_session[("User session")]
  node_preferences["Theme preferences"]
end

subgraph group_insights["Insights"]
  node_statistics["Statistics view model"]
  node_aggregator["Statistics aggregator"]
  node_health["Product health classifier<br/>[ProductHealth.kt]"]
  node_statscreen["Statistics screen"]
end

node_user(("User"))
node_firestore[("Firebase Firestore")]
node_camera(("Camera or gallery"))
node_ocrmodels["Tesseract model host"]

node_user -->|"opens"| node_activity
node_application -->|"creates"| node_container
node_application -->|"starts"| node_sync
node_activity -->|"shows"| node_home
node_activity -->|"shows"| node_profile
node_activity -->|"shows"| node_scan
node_factory -->|"gets dependencies"| node_container
node_user -->|"submits receipt"| node_scan
node_camera -->|"provides image"| node_scan
node_scan -->|"analyzes QR"| node_qr
node_scan -.->|"recognizes text"| node_ocr
node_ocr -->|"downloads models"| node_ocrmodels
node_scan -.->|"parses text"| node_receiptparse
node_scan -.->|"parses QR data"| node_qrparse
node_qrparse -->|"uses client"| node_receiptapi
node_scan -.->|"presents result"| node_review
node_review -->|"saves receipt"| node_local
node_home -.->|"browses expenses"| node_local
node_local -->|"reads and writes"| node_room
node_sync -->|"flushes deletes"| node_local
node_sync -->|"syncs account"| node_accountrepo
node_sync -->|"syncs expenses"| node_cloudrepo
node_sync -->|"checks connectivity"| node_network
node_local -->|"deletes remotely"| node_cloudrepo
node_cloudrepo -->|"reads and writes"| node_firestore
node_user -->|"manages account"| node_profile
node_profile -->|"dispatches actions"| node_accountui
node_accountui -->|"manages session"| node_accountrepo
node_accountrepo -->|"stores session"| node_session
node_accountrepo -.->|"syncs account"| node_firestore
node_accountui -->|"updates theme"| node_preferences
node_user -->|"views statistics"| node_statscreen
node_statscreen -->|"requests totals"| node_statistics
node_statistics -->|"aggregates periods"| node_aggregator
node_statistics -->|"reads expenses"| node_local
node_local -->|"classifies products"| node_health
node_statistics -->|"uses labels"| node_health

click node_application "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/PlnaApplication.kt"
click node_container "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/di/AppContainer.kt"
click node_activity "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/MainActivity.kt"
click node_factory "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/AppViewModelFactory.kt"
click node_home "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/home/HomeScreen.kt"
click node_profile "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/profile/ProfileScreen.kt"
click node_scan "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/scan/QrScanScreen.kt"
click node_qr "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/scan/QrBarcodeAnalyzer.kt"
click node_ocr "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/scan/RussianOcrEngine.kt"
click node_receiptparse "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/parser/ReceiptParser.kt"
click node_qrparse "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/parser/QrReceiptParser.kt"
click node_receiptapi "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/api/ReceiptApiClient.kt"
click node_review "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/smartcheck/SmartCheckViewModel.kt"
click node_local "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt"
click node_room "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/local/ExpenseEntities.kt"
click node_cloudrepo "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/repository/ExpenseRepository.kt"
click node_sync "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt"
click node_network "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/network/NetworkMonitor.kt"
click node_accountui "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/profile/ProfileViewModel.kt"
click node_accountrepo "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/repository/AccountRepository.kt"
click node_session "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/local/UserSessionEntity.kt"
click node_preferences "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/theme/ThemePreferences.kt"
click node_statistics "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsViewModel.kt"
click node_aggregator "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/statistics/StatisticsAggregator.kt"
click node_health "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/health/ProductHealth.kt"
click node_statscreen "https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsScreen.kt"

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_application,node_container,node_activity,node_factory,node_home,node_profile,node_user toneBlue
class node_scan,node_qr,node_ocr,node_receiptparse,node_qrparse,node_receiptapi,node_review,node_firestore toneAmber
class node_local,node_room,node_cloudrepo,node_sync,node_network toneMint
class node_accountui,node_accountrepo,node_session,node_preferences toneRose
class node_statistics,node_aggregator,node_health,node_statscreen,node_camera,node_ocrmodels toneIndigo
```

## Components

### App and UI

- [Application startup](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/PlnaApplication.kt): `app/src/main/java/com/plna/smartcheck/PlnaApplication.kt`
- [Dependency container](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/di/AppContainer.kt): `app/src/main/java/com/plna/smartcheck/di/AppContainer.kt`
- [Main activity](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/MainActivity.kt): `app/src/main/java/com/plna/smartcheck/MainActivity.kt`
- [ViewModel factory](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/AppViewModelFactory.kt): `app/src/main/java/com/plna/smartcheck/ui/AppViewModelFactory.kt`
- [Expense list and detail](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/home/HomeScreen.kt): `app/src/main/java/com/plna/smartcheck/ui/home/HomeScreen.kt`
- [Profile screen](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/profile/ProfileScreen.kt): `app/src/main/java/com/plna/smartcheck/ui/profile/ProfileScreen.kt`

### Receipt capture

- [Receipt scan UI](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/scan/QrScanScreen.kt): `app/src/main/java/com/plna/smartcheck/ui/scan/QrScanScreen.kt`
- [QR analyzer](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/scan/QrBarcodeAnalyzer.kt): `app/src/main/java/com/plna/smartcheck/data/scan/QrBarcodeAnalyzer.kt`
- [Russian OCR engine](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/scan/RussianOcrEngine.kt): `app/src/main/java/com/plna/smartcheck/data/scan/RussianOcrEngine.kt`
- [Text receipt parser](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/parser/ReceiptParser.kt): `app/src/main/java/com/plna/smartcheck/data/parser/ReceiptParser.kt`
- [QR receipt parser](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/parser/QrReceiptParser.kt): `app/src/main/java/com/plna/smartcheck/data/parser/QrReceiptParser.kt`
- [Receipt API client](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/api/ReceiptApiClient.kt): `app/src/main/java/com/plna/smartcheck/data/api/ReceiptApiClient.kt`
- [Receipt review](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/smartcheck/SmartCheckViewModel.kt): `app/src/main/java/com/plna/smartcheck/ui/smartcheck/SmartCheckViewModel.kt`

### Expense data

- [Local expense repository](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt): `app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt`
- [Room expense storage](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/local/ExpenseEntities.kt): `app/src/main/java/com/plna/smartcheck/data/local/ExpenseEntities.kt`
- [Cloud expense repository](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/repository/ExpenseRepository.kt): `app/src/main/java/com/plna/smartcheck/data/repository/ExpenseRepository.kt`
- [Expense sync manager](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt): `app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt`
- [Network monitor](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/network/NetworkMonitor.kt): `app/src/main/java/com/plna/smartcheck/data/network/NetworkMonitor.kt`

### Account and settings

- [Profile view model](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/profile/ProfileViewModel.kt): `app/src/main/java/com/plna/smartcheck/ui/profile/ProfileViewModel.kt`
- [Account repository](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/repository/AccountRepository.kt): `app/src/main/java/com/plna/smartcheck/data/repository/AccountRepository.kt`
- [User session](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/local/UserSessionEntity.kt): `app/src/main/java/com/plna/smartcheck/data/local/UserSessionEntity.kt`
- [Theme preferences](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/theme/ThemePreferences.kt): `app/src/main/java/com/plna/smartcheck/data/theme/ThemePreferences.kt`

### Insights

- [Statistics view model](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsViewModel.kt): `app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsViewModel.kt`
- [Statistics aggregator](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/statistics/StatisticsAggregator.kt): `app/src/main/java/com/plna/smartcheck/data/statistics/StatisticsAggregator.kt`
- [Product health classifier](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/data/health/ProductHealth.kt): `app/src/main/java/com/plna/smartcheck/data/health/ProductHealth.kt`
- [Statistics screen](https://github.com/devopstem/plnasmartcheck/blob/main/app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsScreen.kt): `app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsScreen.kt`

### Other components

- **User**
- **Firebase Firestore**
- **Camera or gallery**
- **Tesseract model host**

## Connections

- User → Main activity: opens
- Application startup → Dependency container: creates (evidence: `app/src/main/java/com/plna/smartcheck/PlnaApplication.kt`)
- Application startup → Expense sync manager: starts (evidence: `app/src/main/java/com/plna/smartcheck/PlnaApplication.kt`)
- Main activity → Expense list and detail: shows (evidence: `app/src/main/java/com/plna/smartcheck/MainActivity.kt`)
- Main activity → Profile screen: shows (evidence: `app/src/main/java/com/plna/smartcheck/MainActivity.kt`)
- Main activity → Receipt scan UI: shows (evidence: `app/src/main/java/com/plna/smartcheck/MainActivity.kt`)
- ViewModel factory → Dependency container: gets dependencies (evidence: `app/src/main/java/com/plna/smartcheck/ui/AppViewModelFactory.kt`)
- User → Receipt scan UI: submits receipt
- Camera or gallery → Receipt scan UI: provides image
- Receipt scan UI → QR analyzer: analyzes QR
- Receipt scan UI → Russian OCR engine: recognizes text
- Russian OCR engine → Tesseract model host: downloads models (evidence: `app/src/main/java/com/plna/smartcheck/data/scan/RussianOcrEngine.kt`)
- Receipt scan UI → Text receipt parser: parses text
- Receipt scan UI → QR receipt parser: parses QR data
- QR receipt parser → Receipt API client: uses client (evidence: `app/src/main/java/com/plna/smartcheck/data/api/ReceiptApiClient.kt`)
- Receipt scan UI → Receipt review: presents result
- Receipt review → Local expense repository: saves receipt (evidence: `app/src/main/java/com/plna/smartcheck/ui/smartcheck/SmartCheckViewModel.kt`)
- Expense list and detail → Local expense repository: browses expenses
- Local expense repository → Room expense storage: reads and writes (evidence: `app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt`)
- Expense sync manager → Local expense repository: flushes deletes (evidence: `app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt`)
- Expense sync manager → Account repository: syncs account (evidence: `app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt`)
- Expense sync manager → Cloud expense repository: syncs expenses (evidence: `app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt`)
- Expense sync manager → Network monitor: checks connectivity (evidence: `app/src/main/java/com/plna/smartcheck/data/sync/ExpenseSyncManager.kt`)
- Local expense repository → Cloud expense repository: deletes remotely (evidence: `app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt`)
- Cloud expense repository → Firebase Firestore: reads and writes (evidence: `app/src/main/java/com/plna/smartcheck/data/repository/ExpenseRepository.kt`)
- User → Profile screen: manages account
- Profile screen → Profile view model: dispatches actions (evidence: `app/src/main/java/com/plna/smartcheck/ui/profile/ProfileScreen.kt`)
- Profile view model → Account repository: manages session (evidence: `app/src/main/java/com/plna/smartcheck/ui/profile/ProfileViewModel.kt`)
- Account repository → User session: stores session (evidence: `app/src/main/java/com/plna/smartcheck/data/repository/AccountRepository.kt`)
- Account repository → Firebase Firestore: syncs account
- Profile view model → Theme preferences: updates theme (evidence: `app/src/main/java/com/plna/smartcheck/ui/profile/ProfileViewModel.kt`)
- User → Statistics screen: views statistics
- Statistics screen → Statistics view model: requests totals (evidence: `app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsScreen.kt`)
- Statistics view model → Statistics aggregator: aggregates periods (evidence: `app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsViewModel.kt`)
- Statistics view model → Local expense repository: reads expenses (evidence: `app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsViewModel.kt`)
- Local expense repository → Product health classifier: classifies products (evidence: `app/src/main/java/com/plna/smartcheck/data/repository/LocalExpenseRepository.kt`)
- Statistics view model → Product health classifier: uses labels (evidence: `app/src/main/java/com/plna/smartcheck/ui/statistics/StatisticsViewModel.kt`)
