# innotech-lab/afro-agri architecture

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

- Interactive diagram: https://gitdiagram.com/innotech-lab/afro-agri
- Repository: https://github.com/innotech-lab/afro-agri

## Overview

AfroAgri is an agriculture-management web application: users access public analysis pages or role-specific dashboards, while the Django backend exposes account and agricultural-data services. The visible analysis service predicts plant disease from images and enriches results with treatment and symptom information; field, crop, journal, soil, and payment capabilities are represented by backend modules in the tree. Several routes and integrations are unsampled, so those connections are omitted or marked unverified rather than inferred.

Main entry points: [`backend/journal/models.py`](https://github.com/innotech-lab/afro-agri/blob/main/backend/journal/models.py) (Journal records), [`backend/champs/models.py`](https://github.com/innotech-lab/afro-agri/blob/main/backend/champs/models.py) (Field records), [`frontend/src/App.jsx`](https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/App.jsx) (Application routes), [`backend/users/views.py`](https://github.com/innotech-lab/afro-agri/blob/main/backend/users/views.py) (User and dashboard API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["Application routes<br/>[App.jsx]"]
  node_analysis_page["Analysis page<br/>[AnalysePage.jsx]"]
  node_terrain_ui["Terrain analyzer"]
  node_dashboards["Role dashboards"]
  node_resource_ui["Resource manager"]
end

subgraph group_identity["Identity and roles"]
  node_auth_ui["Authentication state<br/>[AuthContext.jsx]"]
  node_users_api["User and dashboard API<br/>[views.py]"]
  node_user_types[("User roles<br/>[models.py]")]
  node_user_store[("User records<br/>[models.py]")]
end

subgraph group_farm["Farm operations"]
  node_fields["Field management"]
  node_field_store[("Field records<br/>[models.py]")]
  node_crops["Crop management"]
  node_crop_store[("Crop records<br/>[models.py]")]
  node_journal["Crop journal"]
  node_journal_store[("Journal records<br/>[models.py]")]
end

subgraph group_insights["Agricultural insights"]
  node_soil["Soil study"]
  node_diagnostic["Plant diagnosis"]
  node_diagnosis_service["Disease inference<br/>[ia_service.py]"]
  node_diagnosis_store[("Diagnosis records<br/>[models.py]")]
  node_localisation["Location services"]
end

subgraph group_commerce["Payments"]
  node_payments["Payment services"]
  node_payment_store[("Payment records<br/>[models.py]")]
  node_subscriptions["Subscriptions"]
  node_transactions["Transactions"]
end

node_visitor(("User"))

node_visitor -->|"opens"| node_app
node_app -->|"routes to"| node_analysis_page
node_app -->|"routes to"| node_dashboards
node_analysis_page -->|"renders"| node_terrain_ui
node_visitor -.->|"signs in"| node_auth_ui
node_auth_ui -->|"posts credentials"| node_users_api
node_users_api -->|"reads and writes"| node_user_store
node_users_api -->|"looks up role"| node_user_types
node_dashboards -->|"uses resources"| node_resource_ui
node_resource_ui -.->|"requests endpoint"| node_fields
node_fields -.->|"manages records"| node_field_store
node_crops -.->|"manages records"| node_crop_store
node_journal -.->|"manages records"| node_journal_store
node_crop_store -->|"references field"| node_field_store
node_journal_store -->|"references crop"| node_crop_store
node_journal_store -->|"references user"| node_user_store
node_journal -->|"invokes diagnosis"| node_diagnosis_service
node_diagnostic -.->|"uses inference"| node_diagnosis_service
node_diagnosis_store -->|"references journal"| node_journal_store
node_soil -.->|"stores soil data"| node_field_store
node_localisation -.->|"uses field locations"| node_field_store
node_payments -.->|"manages records"| node_payment_store
node_payment_store -->|"references user"| node_user_store
node_subscriptions -.->|"integrates"| node_payments
node_transactions -.->|"integrates"| node_payments

click node_app "https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/App.jsx"
click node_analysis_page "https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/pages/AnalysePage.jsx"
click node_terrain_ui "https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/components/TerrainAnalyzer.jsx"
click node_dashboards "https://github.com/innotech-lab/afro-agri/tree/main/frontend/src/pages"
click node_resource_ui "https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/components/ResourceManager.jsx"
click node_auth_ui "https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/context/AuthContext.jsx"
click node_users_api "https://github.com/innotech-lab/afro-agri/blob/main/backend/users/views.py"
click node_user_types "https://github.com/innotech-lab/afro-agri/blob/main/backend/type_user/models.py"
click node_user_store "https://github.com/innotech-lab/afro-agri/blob/main/backend/users/models.py"
click node_fields "https://github.com/innotech-lab/afro-agri/tree/main/backend/champs"
click node_field_store "https://github.com/innotech-lab/afro-agri/blob/main/backend/champs/models.py"
click node_crops "https://github.com/innotech-lab/afro-agri/tree/main/backend/plantes"
click node_crop_store "https://github.com/innotech-lab/afro-agri/blob/main/backend/plantes/models.py"
click node_journal "https://github.com/innotech-lab/afro-agri/tree/main/backend/journal"
click node_journal_store "https://github.com/innotech-lab/afro-agri/blob/main/backend/journal/models.py"
click node_soil "https://github.com/innotech-lab/afro-agri/tree/main/backend/etude_sol"
click node_diagnostic "https://github.com/innotech-lab/afro-agri/tree/main/backend/diagnostic"
click node_diagnosis_service "https://github.com/innotech-lab/afro-agri/blob/main/backend/diagnostic/ia_service.py"
click node_diagnosis_store "https://github.com/innotech-lab/afro-agri/blob/main/backend/diagnostic/models.py"
click node_localisation "https://github.com/innotech-lab/afro-agri/tree/main/backend/localisation"
click node_payments "https://github.com/innotech-lab/afro-agri/tree/main/backend/paiement"
click node_payment_store "https://github.com/innotech-lab/afro-agri/blob/main/backend/paiement/models.py"
click node_subscriptions "https://github.com/innotech-lab/afro-agri/tree/main/backend/subscriptions"
click node_transactions "https://github.com/innotech-lab/afro-agri/tree/main/backend/transactions"

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_analysis_page,node_terrain_ui,node_dashboards,node_resource_ui,node_visitor toneBlue
class node_auth_ui,node_users_api,node_user_types,node_user_store toneAmber
class node_fields,node_field_store,node_crops,node_crop_store,node_journal,node_journal_store toneMint
class node_soil,node_diagnostic,node_diagnosis_service,node_diagnosis_store,node_localisation toneRose
class node_payments,node_payment_store,node_subscriptions,node_transactions toneIndigo
```

## Components

### Web experience

- [Application routes](https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Analysis page](https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/pages/AnalysePage.jsx): `frontend/src/pages/AnalysePage.jsx`
- [Terrain analyzer](https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/components/TerrainAnalyzer.jsx): `frontend/src/components/TerrainAnalyzer.jsx`
- [Role dashboards](https://github.com/innotech-lab/afro-agri/tree/main/frontend/src/pages): `frontend/src/pages`
- [Resource manager](https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/components/ResourceManager.jsx): `frontend/src/components/ResourceManager.jsx`

### Identity and roles

- [Authentication state](https://github.com/innotech-lab/afro-agri/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [User and dashboard API](https://github.com/innotech-lab/afro-agri/blob/main/backend/users/views.py): `backend/users/views.py`
- [User roles](https://github.com/innotech-lab/afro-agri/blob/main/backend/type_user/models.py): `backend/type_user/models.py`
- [User records](https://github.com/innotech-lab/afro-agri/blob/main/backend/users/models.py): `backend/users/models.py`

### Farm operations

- [Field management](https://github.com/innotech-lab/afro-agri/tree/main/backend/champs): `backend/champs`
- [Field records](https://github.com/innotech-lab/afro-agri/blob/main/backend/champs/models.py): `backend/champs/models.py`
- [Crop management](https://github.com/innotech-lab/afro-agri/tree/main/backend/plantes): `backend/plantes`
- [Crop records](https://github.com/innotech-lab/afro-agri/blob/main/backend/plantes/models.py): `backend/plantes/models.py`
- [Crop journal](https://github.com/innotech-lab/afro-agri/tree/main/backend/journal): `backend/journal`
- [Journal records](https://github.com/innotech-lab/afro-agri/blob/main/backend/journal/models.py): `backend/journal/models.py`

### Agricultural insights

- [Soil study](https://github.com/innotech-lab/afro-agri/tree/main/backend/etude_sol): `backend/etude_sol`
- [Plant diagnosis](https://github.com/innotech-lab/afro-agri/tree/main/backend/diagnostic): `backend/diagnostic`
- [Disease inference](https://github.com/innotech-lab/afro-agri/blob/main/backend/diagnostic/ia_service.py): `backend/diagnostic/ia_service.py`
- [Diagnosis records](https://github.com/innotech-lab/afro-agri/blob/main/backend/diagnostic/models.py): `backend/diagnostic/models.py`
- [Location services](https://github.com/innotech-lab/afro-agri/tree/main/backend/localisation): `backend/localisation`

### Payments

- [Payment services](https://github.com/innotech-lab/afro-agri/tree/main/backend/paiement): `backend/paiement`
- [Payment records](https://github.com/innotech-lab/afro-agri/blob/main/backend/paiement/models.py): `backend/paiement/models.py`
- [Subscriptions](https://github.com/innotech-lab/afro-agri/tree/main/backend/subscriptions): `backend/subscriptions`
- [Transactions](https://github.com/innotech-lab/afro-agri/tree/main/backend/transactions): `backend/transactions`

### Other components

- **User**

## Connections

- User → Application routes: opens (evidence: `frontend/src/App.jsx`)
- Application routes → Analysis page: routes to (evidence: `frontend/src/App.jsx`)
- Application routes → Role dashboards: routes to (evidence: `frontend/src/App.jsx`)
- Analysis page → Terrain analyzer: renders (evidence: `frontend/src/pages/AnalysePage.jsx`)
- User → Authentication state: signs in
- Authentication state → User and dashboard API: posts credentials (evidence: `frontend/src/context/AuthContext.jsx`)
- User and dashboard API → User records: reads and writes (evidence: `backend/users/views.py`)
- User and dashboard API → User roles: looks up role (evidence: `backend/users/views.py`)
- Role dashboards → Resource manager: uses resources (evidence: `frontend/src/pages/particulier/DashboardParticulier.jsx`)
- Resource manager → Field management: requests endpoint
- Field management → Field records: manages records
- Crop management → Crop records: manages records
- Crop journal → Journal records: manages records (evidence: `backend/journal/views.py`)
- Crop records → Field records: references field (evidence: `backend/plantes/models.py`)
- Journal records → Crop records: references crop (evidence: `backend/journal/models.py`)
- Journal records → User records: references user (evidence: `backend/journal/models.py`)
- Crop journal → Disease inference: invokes diagnosis (evidence: `backend/journal/views.py`)
- Plant diagnosis → Disease inference: uses inference
- Diagnosis records → Journal records: references journal (evidence: `backend/diagnostic/models.py`)
- Soil study → Field records: stores soil data
- Location services → Field records: uses field locations
- Payment services → Payment records: manages records (evidence: `backend/paiement/views.py`)
- Payment records → User records: references user (evidence: `backend/paiement/models.py`)
- Subscriptions → Payment services: integrates
- Transactions → Payment services: integrates
