# ransen1128-png/smartpoultry architecture

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

- Interactive diagram: https://gitdiagram.com/ransen1128-png/smartpoultry
- Repository: https://github.com/ransen1128-png/smartpoultry

## Overview

SMARTPOULTRY is a Django poultry-farm management system with operational records, financial tracking, analytics, reporting, alerts, and vision/age-estimation features. The documented user workflow is to manage flocks and record production and financial activity, then view analytics, forecasts, alerts, and reports. The graph includes the documented product branches and sampled internal vision, persistence, and audit layers. Some relationships are documented only in the README; unsampled implementation links are omitted rather than inferred.

Main entry points: [`app.py`](https://github.com/ransen1128-png/smartpoultry/blob/main/app.py) (Django application), [`smartpoultry/reports/excel_export.py`](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/reports/excel_export.py) (Reports and exports), [`smartpoultry/core/spur_cache.py`](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/spur_cache.py) (Spur prediction cache), [`smartpoultry/revenue/models.py`](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/revenue/models.py) (Revenue records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_django["Django application<br/>[app.py]"]
end

subgraph group_farm["Farm operations"]
  node_flocks["Flock management<br/>[models.py]"]
  node_production["Production and health<br/>[models.py]"]
  node_inventory["Inventory tracking<br/>[models.py]"]
end

subgraph group_finance["Finance and insights"]
  node_revenue["Revenue records<br/>[models.py]"]
  node_expenses["Expense records<br/>[models.py]"]
  node_analytics["Analytics and forecasts<br/>[views.py]"]
  node_reports["Reports and exports<br/>[excel_export.py]"]
  node_mlpredictor["Forecast predictor<br/>[predictor.py]"]
end

subgraph group_identity["Accounts and alerts"]
  node_accounts["Accounts and roles<br/>[views.py]"]
  node_notifications["Alerts and notifications<br/>[readiness.py]"]
end

subgraph group_vision["Vision and ML"]
  node_visionapi["Vision API<br/>[vision_api.py]"]
  node_freeinfer["Free image inference<br/>[free_inference.py]"]
  node_poultryvision["Poultry vision<br/>[poultry_vision.py]"]
  node_spurcache["Spur prediction cache<br/>[spur_cache.py]"]
  node_spurservice["Cache service"]
  node_spurmeasure["Spur measurement"]
  node_geometry["Geometry API<br/>[geometry_api.py]"]
  node_ageclassifier["Rooster age classifier"]
end

subgraph group_platform["Core platform"]
  node_audit["Change auditing<br/>[audit.py]"]
  node_coremodels[("Farm and shared records<br/>[models.py]")]
  node_storage["Uploaded-file storage<br/>[storage.py]"]
end

node_operator(("Farm user"))

node_operator -->|"uses"| node_django
node_django -.->|"routes to"| node_accounts
node_django -.->|"routes to"| node_flocks
node_django -.->|"routes to"| node_production
node_django -.->|"routes to"| node_inventory
node_django -.->|"routes to"| node_revenue
node_django -.->|"routes to"| node_expenses
node_django -.->|"routes to"| node_analytics
node_django -.->|"routes to"| node_reports
node_django -.->|"routes to"| node_notifications
node_flocks -.->|"supports records"| node_production
node_revenue -->|"references"| node_flocks
node_revenue -->|"reads"| node_production
node_analytics -.->|"uses forecasts"| node_mlpredictor
node_mlpredictor -->|"trains from"| node_revenue
node_mlpredictor -->|"trains from"| node_expenses
node_reports -->|"reads"| node_revenue
node_reports -->|"reads"| node_expenses
node_reports -->|"reads"| node_production
node_reports -->|"reads"| node_flocks
node_reports -->|"reads"| node_inventory
node_storage -->|"persists files"| node_coremodels
node_audit -->|"records changes"| node_coremodels
node_freeinfer -->|"uses"| node_poultryvision
node_spurservice -->|"calls"| node_spurcache
node_spurservice -->|"runs inference"| node_freeinfer
node_spurcache -->|"uses"| node_freeinfer
node_spurcache -->|"uses"| node_visionapi
node_spurcache -->|"uses"| node_geometry
node_spurcache -->|"uses"| node_spurmeasure
node_spurcache -->|"reads and writes"| node_coremodels
node_ageclassifier -.->|"saves estimates"| node_coremodels
node_operator -.->|"submits photos"| node_visionapi
node_notifications -.->|"alerts on stock"| node_inventory

click node_django "https://github.com/ransen1128-png/smartpoultry/blob/main/app.py"
click node_accounts "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/accounts/views.py"
click node_flocks "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/flocks/models.py"
click node_production "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/production/models.py"
click node_inventory "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/inventory/models.py"
click node_revenue "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/revenue/models.py"
click node_expenses "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/expenses/models.py"
click node_analytics "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/analytics/views.py"
click node_reports "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/reports/excel_export.py"
click node_notifications "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/notifications/readiness.py"
click node_audit "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/audit.py"
click node_coremodels "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/models.py"
click node_storage "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/storage.py"
click node_visionapi "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/vision_api.py"
click node_freeinfer "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/free_inference.py"
click node_poultryvision "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/poultry_vision.py"
click node_spurcache "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/spur_cache.py"
click node_spurservice "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/spur_cache_service.py"
click node_spurmeasure "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/spur_measurement.py"
click node_geometry "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/geometry_api.py"
click node_ageclassifier "https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/rooster_age_classifier.py"
click node_mlpredictor "https://github.com/ransen1128-png/smartpoultry/blob/main/ml_models/predictor.py"

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_django,node_operator toneBlue
class node_flocks,node_production,node_inventory toneAmber
class node_revenue,node_expenses,node_analytics,node_reports,node_mlpredictor toneMint
class node_accounts,node_notifications toneRose
class node_visionapi,node_freeinfer,node_poultryvision,node_spurcache,node_spurservice,node_spurmeasure,node_geometry,node_ageclassifier toneIndigo
class node_audit,node_coremodels,node_storage toneTeal
```

## Components

### Application entry

- [Django application](https://github.com/ransen1128-png/smartpoultry/blob/main/app.py): `app.py`

### Farm operations

- [Flock management](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/flocks/models.py): `smartpoultry/flocks/models.py`
- [Production and health](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/production/models.py): `smartpoultry/production/models.py`
- [Inventory tracking](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/inventory/models.py): `smartpoultry/inventory/models.py`

### Finance and insights

- [Revenue records](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/revenue/models.py): `smartpoultry/revenue/models.py`
- [Expense records](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/expenses/models.py): `smartpoultry/expenses/models.py`
- [Analytics and forecasts](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/analytics/views.py): `smartpoultry/analytics/views.py`
- [Reports and exports](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/reports/excel_export.py): `smartpoultry/reports/excel_export.py`
- [Forecast predictor](https://github.com/ransen1128-png/smartpoultry/blob/main/ml_models/predictor.py): `ml_models/predictor.py`

### Accounts and alerts

- [Accounts and roles](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/accounts/views.py): `smartpoultry/accounts/views.py`
- [Alerts and notifications](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/notifications/readiness.py): `smartpoultry/notifications/readiness.py`

### Vision and ML

- [Vision API](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/vision_api.py): `smartpoultry/core/vision_api.py`
- [Free image inference](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/free_inference.py): `smartpoultry/core/free_inference.py`
- [Poultry vision](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/poultry_vision.py): `smartpoultry/core/poultry_vision.py`
- [Spur prediction cache](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/spur_cache.py): `smartpoultry/core/spur_cache.py`
- [Cache service](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/spur_cache_service.py): `smartpoultry/core/spur_cache_service.py`
- [Spur measurement](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/spur_measurement.py): `smartpoultry/core/spur_measurement.py`
- [Geometry API](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/geometry_api.py): `smartpoultry/core/geometry_api.py`
- [Rooster age classifier](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/rooster_age_classifier.py): `smartpoultry/core/rooster_age_classifier.py`

### Core platform

- [Change auditing](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/audit.py): `smartpoultry/core/audit.py`
- [Farm and shared records](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/models.py): `smartpoultry/core/models.py`
- [Uploaded-file storage](https://github.com/ransen1128-png/smartpoultry/blob/main/smartpoultry/core/storage.py): `smartpoultry/core/storage.py`

### Other components

- **Farm user**

## Connections

- Farm user → Django application: uses (evidence: `README.md`)
- Django application → Accounts and roles: routes to
- Django application → Flock management: routes to
- Django application → Production and health: routes to
- Django application → Inventory tracking: routes to
- Django application → Revenue records: routes to
- Django application → Expense records: routes to
- Django application → Analytics and forecasts: routes to
- Django application → Reports and exports: routes to
- Django application → Alerts and notifications: routes to
- Flock management → Production and health: supports records
- Revenue records → Flock management: references (evidence: `smartpoultry/revenue/models.py`)
- Revenue records → Production and health: reads (evidence: `smartpoultry/revenue/models.py`)
- Analytics and forecasts → Forecast predictor: uses forecasts
- Forecast predictor → Revenue records: trains from
- Forecast predictor → Expense records: trains from
- Reports and exports → Revenue records: reads (evidence: `smartpoultry/reports/excel_export.py`)
- Reports and exports → Expense records: reads (evidence: `smartpoultry/reports/excel_export.py`)
- Reports and exports → Production and health: reads (evidence: `smartpoultry/reports/excel_export.py`)
- Reports and exports → Flock management: reads (evidence: `smartpoultry/reports/excel_export.py`)
- Reports and exports → Inventory tracking: reads (evidence: `smartpoultry/reports/excel_export.py`)
- Uploaded-file storage → Farm and shared records: persists files (evidence: `smartpoultry/core/storage.py`)
- Change auditing → Farm and shared records: records changes (evidence: `smartpoultry/core/audit.py`)
- Free image inference → Poultry vision: uses (evidence: `smartpoultry/core/free_inference.py`)
- Cache service → Spur prediction cache: calls (evidence: `smartpoultry/core/spur_cache_service.py`)
- Cache service → Free image inference: runs inference (evidence: `smartpoultry/core/spur_cache_service.py`)
- Spur prediction cache → Free image inference: uses (evidence: `smartpoultry/core/spur_cache.py`)
- Spur prediction cache → Vision API: uses (evidence: `smartpoultry/core/spur_cache.py`)
- Spur prediction cache → Geometry API: uses (evidence: `smartpoultry/core/spur_cache.py`)
- Spur prediction cache → Spur measurement: uses (evidence: `smartpoultry/core/spur_cache.py`)
- Spur prediction cache → Farm and shared records: reads and writes (evidence: `smartpoultry/core/spur_cache.py`)
- Rooster age classifier → Farm and shared records: saves estimates
- Farm user → Vision API: submits photos
- Alerts and notifications → Inventory tracking: alerts on stock
