# os4mu/agrimobile architecture

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

- Interactive diagram: https://gitdiagram.com/os4mu/agrimobile
- Repository: https://github.com/os4mu/agrimobile

## Overview

AgriStock is an Android inventory app whose apparent workflow is to sign in, scan a product with the camera, identify it on-device, and use stock-in/out or scan-history screens to manage inventory. The tree also shows local persistence, a product catalog, connectivity monitoring, and pending-scan synchronization. The README is empty and no runtime source was excerpted, so the connections below are plausible from names and paths, not verified calls; all are dashed with no evidence path.

Main entry points: [`app/src/main/java/com/example/data/repository/Repositories.kt`](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/repository/Repositories.kt) (Repositories), [`app/src/main/java/com/example/ui/screens/MainScreen.kt`](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/MainScreen.kt) (Main screen), [`app/src/main/java/com/example/util/SyncPendingScansWorker.kt`](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/util/SyncPendingScansWorker.kt) (Pending scan worker), [`app/src/main/java/com/example/MainActivity.kt`](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/MainActivity.kt) (Main activity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App workflow"]
  node_activity["Main activity<br/>[MainActivity.kt]"]
  node_login["Login screen<br/>[LoginScreen.kt]"]
  node_home["Home screen<br/>[HomeScreen.kt]"]
  node_main_screen["Main screen<br/>[MainScreen.kt]"]
  node_scan_screen["Scan product"]
  node_restock["Restock screen<br/>[RestockScreen.kt]"]
  node_stockout["Stock-out screen<br/>[StockOutScreen.kt]"]
  node_my_scans["My scans<br/>[MyScansScreen.kt]"]
end

subgraph group_vision["Product scanning"]
  node_camera["Camera manager<br/>[CameraManager.kt]"]
  node_preprocess["Image preprocessor"]
  node_opencv["OpenCV init<br/>[OpenCvInit.kt]"]
  node_detector["YOLO detector<br/>[YOLODetector.kt]"]
  node_model["Detection model"]
end

subgraph group_inventory["Inventory data"]
  node_catalog["Product catalog<br/>[ProductCatalog.kt]"]
  node_repository["Repositories<br/>[Repositories.kt]"]
  node_dao["Data access<br/>[Daos.kt]"]
  node_entities["Inventory entities<br/>[Entities.kt]"]
  node_database[("Local database")]
end

subgraph group_sync["Offline sync"]
  node_network["Network monitor<br/>[NetworkMonitor.kt]"]
  node_worker["Pending scan worker"]
  node_syncutils["Sync utilities<br/>[SyncUtils.kt]"]
end

node_user(("User"))

node_user -.->|"opens"| node_activity
node_activity -.->|"shows"| node_login
node_activity -.->|"shows"| node_home
node_home -.->|"navigates"| node_main_screen
node_main_screen -.->|"opens"| node_scan_screen
node_main_screen -.->|"opens"| node_restock
node_main_screen -.->|"opens"| node_stockout
node_main_screen -.->|"opens"| node_my_scans
node_scan_screen -.->|"captures with"| node_camera
node_camera -.->|"supplies image"| node_preprocess
node_preprocess -.->|"prepares input"| node_detector
node_detector -.->|"uses"| node_model
node_scan_screen -.->|"records scan"| node_repository
node_restock -.->|"updates stock"| node_repository
node_stockout -.->|"updates stock"| node_repository
node_my_scans -.->|"loads scans"| node_repository
node_repository -.->|"consults"| node_catalog
node_repository -.->|"uses"| node_dao
node_dao -.->|"queries"| node_database
node_database -.->|"stores"| node_entities
node_worker -.->|"checks connectivity"| node_network
node_worker -.->|"delegates sync"| node_syncutils
node_worker -.->|"syncs pending scans"| node_repository

click node_activity "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/MainActivity.kt"
click node_login "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/LoginScreen.kt"
click node_home "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/HomeScreen.kt"
click node_main_screen "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/MainScreen.kt"
click node_scan_screen "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/ScanProductScreen.kt"
click node_restock "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/RestockScreen.kt"
click node_stockout "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/StockOutScreen.kt"
click node_my_scans "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/MyScansScreen.kt"
click node_camera "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/camera/CameraManager.kt"
click node_preprocess "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/cv/ImagePreprocessor.kt"
click node_opencv "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/cv/OpenCvInit.kt"
click node_detector "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/cv/YOLODetector.kt"
click node_model "https://github.com/os4mu/agrimobile/blob/main/app/src/main/assets/v2best_float16.tflite"
click node_catalog "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/ProductCatalog.kt"
click node_repository "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/repository/Repositories.kt"
click node_dao "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/dao/Daos.kt"
click node_entities "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/entities/Entities.kt"
click node_database "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/AgriStockDatabase.kt"
click node_network "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/NetworkMonitor.kt"
click node_worker "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/util/SyncPendingScansWorker.kt"
click node_syncutils "https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/util/SyncUtils.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_activity,node_login,node_home,node_main_screen,node_scan_screen,node_restock,node_stockout,node_my_scans,node_user toneBlue
class node_camera,node_preprocess,node_opencv,node_detector,node_model toneAmber
class node_catalog,node_repository,node_dao,node_entities,node_database toneMint
class node_network,node_worker,node_syncutils toneRose
```

## Components

### App workflow

- [Main activity](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/MainActivity.kt): `app/src/main/java/com/example/MainActivity.kt`
- [Login screen](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/LoginScreen.kt): `app/src/main/java/com/example/ui/screens/LoginScreen.kt`
- [Home screen](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/HomeScreen.kt): `app/src/main/java/com/example/ui/screens/HomeScreen.kt`
- [Main screen](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/MainScreen.kt): `app/src/main/java/com/example/ui/screens/MainScreen.kt`
- [Scan product](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/ScanProductScreen.kt): `app/src/main/java/com/example/ui/screens/ScanProductScreen.kt`
- [Restock screen](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/RestockScreen.kt): `app/src/main/java/com/example/ui/screens/RestockScreen.kt`
- [Stock-out screen](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/StockOutScreen.kt): `app/src/main/java/com/example/ui/screens/StockOutScreen.kt`
- [My scans](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/ui/screens/MyScansScreen.kt): `app/src/main/java/com/example/ui/screens/MyScansScreen.kt`

### Product scanning

- [Camera manager](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/camera/CameraManager.kt): `app/src/main/java/com/example/camera/CameraManager.kt`
- [Image preprocessor](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/cv/ImagePreprocessor.kt): `app/src/main/java/com/example/cv/ImagePreprocessor.kt`
- [OpenCV init](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/cv/OpenCvInit.kt): `app/src/main/java/com/example/cv/OpenCvInit.kt`
- [YOLO detector](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/cv/YOLODetector.kt): `app/src/main/java/com/example/cv/YOLODetector.kt`
- [Detection model](https://github.com/os4mu/agrimobile/blob/main/app/src/main/assets/v2best_float16.tflite): `app/src/main/assets/v2best_float16.tflite`

### Inventory data

- [Product catalog](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/ProductCatalog.kt): `app/src/main/java/com/example/data/ProductCatalog.kt`
- [Repositories](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/repository/Repositories.kt): `app/src/main/java/com/example/data/repository/Repositories.kt`
- [Data access](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/dao/Daos.kt): `app/src/main/java/com/example/data/dao/Daos.kt`
- [Inventory entities](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/entities/Entities.kt): `app/src/main/java/com/example/data/entities/Entities.kt`
- [Local database](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/AgriStockDatabase.kt): `app/src/main/java/com/example/data/AgriStockDatabase.kt`

### Offline sync

- [Network monitor](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/data/NetworkMonitor.kt): `app/src/main/java/com/example/data/NetworkMonitor.kt`
- [Pending scan worker](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/util/SyncPendingScansWorker.kt): `app/src/main/java/com/example/util/SyncPendingScansWorker.kt`
- [Sync utilities](https://github.com/os4mu/agrimobile/blob/main/app/src/main/java/com/example/util/SyncUtils.kt): `app/src/main/java/com/example/util/SyncUtils.kt`

### Other components

- **User**

## Connections

- User → Main activity: opens
- Main activity → Login screen: shows
- Main activity → Home screen: shows
- Home screen → Main screen: navigates
- Main screen → Scan product: opens
- Main screen → Restock screen: opens
- Main screen → Stock-out screen: opens
- Main screen → My scans: opens
- Scan product → Camera manager: captures with
- Camera manager → Image preprocessor: supplies image
- Image preprocessor → YOLO detector: prepares input
- YOLO detector → Detection model: uses
- Scan product → Repositories: records scan
- Restock screen → Repositories: updates stock
- Stock-out screen → Repositories: updates stock
- My scans → Repositories: loads scans
- Repositories → Product catalog: consults
- Repositories → Data access: uses
- Data access → Local database: queries
- Local database → Inventory entities: stores
- Pending scan worker → Network monitor: checks connectivity
- Pending scan worker → Sync utilities: delegates sync
- Pending scan worker → Repositories: syncs pending scans
