# nnaajjeebb12/cocohusk architecture

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

- Interactive diagram: https://gitdiagram.com/nnaajjeebb12/cocohusk
- Repository: https://github.com/nnaajjeebb12/cocohusk

## Overview

HuskTech is an offline-first Flutter app for classifying coconut-husk maturity from photos. Users analyze gallery or batch images, or use Android’s live camera; predictions pass through an on-device TFLite classifier and rejection checks, then are saved for history review. Model management supports bundled, custom, and optional cloud-updated models. The graph also includes documented logging and guidance capabilities. Dart implementation details were not sampled, so some links among those modules are shown as unverified rather than asserted as inspected calls.

Main entry points: [`lib/main.dart`](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart) (App shell), [`lib/model_manager.dart`](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/model_manager.dart) (Model manager), [`lib/inference_engine.dart`](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/inference_engine.dart) (TFLite inference), [`lib/live_camera_page.dart`](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/live_camera_page.dart) (Live camera)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_app["App shell<br/>[main.dart]"]
  node_photo_input["Photo input<br/>[main.dart]"]
  node_live_camera["Live camera"]
  node_model_guide["Model guide<br/>[main.dart]"]
  node_stage_help["Stage help<br/>[main.dart]"]
end

subgraph group_prediction["Prediction"]
  node_classifier["TFLite inference"]
  node_rejection["Rejection checks"]
  node_labels["Class labels<br/>[class_names.txt]"]
  node_reject_config["Rejection config"]
end

subgraph group_models["Model lifecycle"]
  node_bundled_model["Bundled model"]
  node_model_manager["Model manager<br/>[model_manager.dart]"]
  node_custom_model["Custom model file"]
  node_cloud_service["Cloud model service"]
  node_model_cache[("Model cache<br/>[model_manager.dart]")]
end

subgraph group_records["History and logs"]
  node_history_store[("History store<br/>[history_store.dart]")]
  node_history_view["History trends"]
  node_logger["Logging<br/>[app_logger.dart]"]
  node_log_view["Log viewer<br/>[log_page.dart]"]
end

node_user(("App user"))

node_user -->|"uses"| node_app
node_app -->|"offers"| node_photo_input
node_photo_input -.->|"analyzes photos"| node_classifier
node_app -->|"opens"| node_live_camera
node_live_camera -->|"runs inference"| node_classifier
node_live_camera -->|"hands off capture"| node_app
node_app -.->|"requests predictions"| node_classifier
node_classifier -->|"passes outputs"| node_rejection
node_rejection -->|"reads stats"| node_reject_config
node_classifier -.->|"uses labels"| node_labels
node_model_manager -->|"resolves fallback"| node_bundled_model
node_model_manager -->|"loads selection"| node_custom_model
node_model_manager -->|"fetches updates"| node_cloud_service
node_model_manager -->|"caches download"| node_model_cache
node_app -->|"manages models"| node_model_manager
node_model_manager -.->|"provides model"| node_classifier
node_app -->|"saves predictions"| node_history_store
node_history_store -.->|"supplies history"| node_history_view
node_app -.->|"records logs"| node_logger
node_log_view -->|"displays logs"| node_logger
node_user -->|"reads guide"| node_model_guide
node_user -->|"views explanations"| node_stage_help

click node_app "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart"
click node_photo_input "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart"
click node_live_camera "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/live_camera_page.dart"
click node_model_guide "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart"
click node_stage_help "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart"
click node_classifier "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/inference_engine.dart"
click node_rejection "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/inference_engine.dart"
click node_labels "https://github.com/nnaajjeebb12/cocohusk/blob/main/assets/model/class_names.txt"
click node_reject_config "https://github.com/nnaajjeebb12/cocohusk/blob/main/assets/model/rejection_config.json"
click node_bundled_model "https://github.com/nnaajjeebb12/cocohusk/blob/main/assets/model/coconut_husk_quality_model.tflite"
click node_model_manager "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/model_manager.dart"
click node_model_cache "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/model_manager.dart"
click node_history_store "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/history_store.dart"
click node_history_view "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/history_trends_view.dart"
click node_logger "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/app_logger.dart"
click node_log_view "https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/log_page.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_app,node_photo_input,node_live_camera,node_model_guide,node_stage_help,node_user toneBlue
class node_classifier,node_rejection,node_labels,node_reject_config toneAmber
class node_bundled_model,node_model_manager,node_custom_model,node_cloud_service,node_model_cache toneMint
class node_history_store,node_history_view,node_logger,node_log_view toneRose
```

## Components

### User interaction

- [App shell](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart): `lib/main.dart`
- [Photo input](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart): `lib/main.dart`
- [Live camera](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/live_camera_page.dart): `lib/live_camera_page.dart`
- [Model guide](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart): `lib/main.dart`
- [Stage help](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/main.dart): `lib/main.dart`

### Prediction

- [TFLite inference](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/inference_engine.dart): `lib/inference_engine.dart`
- [Rejection checks](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/inference_engine.dart): `lib/inference_engine.dart`
- [Class labels](https://github.com/nnaajjeebb12/cocohusk/blob/main/assets/model/class_names.txt): `assets/model/class_names.txt`
- [Rejection config](https://github.com/nnaajjeebb12/cocohusk/blob/main/assets/model/rejection_config.json): `assets/model/rejection_config.json`

### Model lifecycle

- [Bundled model](https://github.com/nnaajjeebb12/cocohusk/blob/main/assets/model/coconut_husk_quality_model.tflite): `assets/model/coconut_husk_quality_model.tflite`
- [Model manager](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/model_manager.dart): `lib/model_manager.dart`
- **Custom model file**
- **Cloud model service**
- [Model cache](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/model_manager.dart): `lib/model_manager.dart`

### History and logs

- [History store](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/history_store.dart): `lib/history_store.dart`
- [History trends](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/history_trends_view.dart): `lib/history_trends_view.dart`
- [Logging](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/app_logger.dart): `lib/app_logger.dart`
- [Log viewer](https://github.com/nnaajjeebb12/cocohusk/blob/main/lib/log_page.dart): `lib/log_page.dart`

### Other components

- **App user**

## Connections

- App user → App shell: uses (evidence: `README.md`)
- App shell → Photo input: offers (evidence: `README.md`)
- Photo input → TFLite inference: analyzes photos
- App shell → Live camera: opens (evidence: `README.md`)
- Live camera → TFLite inference: runs inference (evidence: `README.md`)
- Live camera → App shell: hands off capture (evidence: `README.md`)
- App shell → TFLite inference: requests predictions
- TFLite inference → Rejection checks: passes outputs (evidence: `README.md`)
- Rejection checks → Rejection config: reads stats (evidence: `README.md`)
- TFLite inference → Class labels: uses labels
- Model manager → Bundled model: resolves fallback (evidence: `README.md`)
- Model manager → Custom model file: loads selection (evidence: `README.md`)
- Model manager → Cloud model service: fetches updates (evidence: `README.md`)
- Model manager → Model cache: caches download (evidence: `README.md`)
- App shell → Model manager: manages models (evidence: `README.md`)
- Model manager → TFLite inference: provides model
- App shell → History store: saves predictions (evidence: `README.md`)
- History store → History trends: supplies history
- App shell → Logging: records logs
- Log viewer → Logging: displays logs (evidence: `README.md`)
- App user → Model guide: reads guide (evidence: `README.md`)
- App user → Stage help: views explanations (evidence: `README.md`)
