# truganic/client-farmer architecture

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

- Interactive diagram: https://gitdiagram.com/truganic/client-farmer
- Repository: https://github.com/truganic/client-farmer

## Overview

Farmer App Client is a React Native app for farmer onboarding and farm-activity management. Users enter through login or account registration, register farm details, then use a dashboard to log planting, inputs, and harvests or review history; the app also offers farmer-ID QR display and scanning. Screens use a shared API layer, which adds stored JWTs to signed requests and handles one refresh-and-retry path. Screen-to-API links are dashed where excerpts show imports but not the call sites; unsampled screen behavior is not assumed.

Main entry points: [`src/navigation/AppNavigator.js`](https://github.com/truganic/client-farmer/blob/main/src/navigation/AppNavigator.js) (Stack navigation), [`src/api/config.js`](https://github.com/truganic/client-farmer/blob/main/src/api/config.js) (API client), [`src/screens/LoginScreen.js`](https://github.com/truganic/client-farmer/blob/main/src/screens/LoginScreen.js) (Login), [`src/screens/UserRegistrationScreen.js`](https://github.com/truganic/client-farmer/blob/main/src/screens/UserRegistrationScreen.js) (User registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_onboarding["Onboarding"]
  node_login["Login<br/>[LoginScreen.js]"]
  node_user_registration["User registration"]
  node_farm_registration["Farm registration"]
end

subgraph group_farm_activity["Farm Activity"]
  node_home["Dashboard<br/>[HomeScreen.js]"]
  node_input_log["Input log<br/>[InputLogScreen.js]"]
  node_planting_log["Planting log"]
  node_harvest_log["Harvest log"]
  node_history["Activity history<br/>[HistoryScreen.js]"]
  node_qr_scanner["QR scanner<br/>[QRScannerScreen.js]"]
end

subgraph group_app_flow["App Flow"]
  node_app["App root<br/>[App.js]"]
  node_navigator["Stack navigation<br/>[AppNavigator.js]"]
end

subgraph group_service_layer["Service Layer"]
  node_api["API client<br/>[config.js]"]
  node_signed_client["Signed requests<br/>[signedClient.js]"]
  node_token_store[("Token storage")]
end

node_farmer(("Farmer"))
node_gateway{{"API gateway"}}

node_farmer -->|"opens app"| node_navigator
node_app -->|"renders"| node_navigator
node_navigator -->|"routes to"| node_login
node_navigator -->|"routes to"| node_user_registration
node_navigator -->|"routes to"| node_farm_registration
node_navigator -->|"routes to"| node_home
node_navigator -->|"routes to"| node_input_log
node_navigator -->|"routes to"| node_planting_log
node_navigator -->|"routes to"| node_harvest_log
node_navigator -->|"routes to"| node_history
node_navigator -->|"routes to"| node_qr_scanner
node_farmer -->|"signs in"| node_login
node_farmer -->|"creates account"| node_user_registration
node_farmer -->|"registers farm"| node_farm_registration
node_farm_registration -->|"submits registration"| node_api
node_login -.->|"requests auth"| node_api
node_user_registration -.->|"requests signup"| node_api
node_home -.->|"loads activity"| node_api
node_input_log -.->|"saves input"| node_api
node_planting_log -.->|"saves planting"| node_api
node_harvest_log -.->|"saves harvest"| node_api
node_history -.->|"loads history"| node_api
node_api -->|"sends signed request"| node_signed_client
node_api -->|"reads tokens"| node_token_store
node_api -->|"updates tokens"| node_token_store
node_signed_client -->|"sends HTTP request"| node_gateway
node_farmer -.->|"scans code"| node_qr_scanner

click node_app "https://github.com/truganic/client-farmer/blob/main/App.js"
click node_navigator "https://github.com/truganic/client-farmer/blob/main/src/navigation/AppNavigator.js"
click node_login "https://github.com/truganic/client-farmer/blob/main/src/screens/LoginScreen.js"
click node_user_registration "https://github.com/truganic/client-farmer/blob/main/src/screens/UserRegistrationScreen.js"
click node_farm_registration "https://github.com/truganic/client-farmer/blob/main/src/screens/FarmRegistrationScreen.js"
click node_home "https://github.com/truganic/client-farmer/blob/main/src/screens/HomeScreen.js"
click node_input_log "https://github.com/truganic/client-farmer/blob/main/src/screens/InputLogScreen.js"
click node_planting_log "https://github.com/truganic/client-farmer/blob/main/src/screens/PlantingLogScreen.js"
click node_harvest_log "https://github.com/truganic/client-farmer/blob/main/src/screens/HarvestLogScreen.js"
click node_history "https://github.com/truganic/client-farmer/blob/main/src/screens/HistoryScreen.js"
click node_qr_scanner "https://github.com/truganic/client-farmer/blob/main/src/screens/QRScannerScreen.js"
click node_api "https://github.com/truganic/client-farmer/blob/main/src/api/config.js"
click node_signed_client "https://github.com/truganic/client-farmer/blob/main/src/auth/signedClient.js"

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_login,node_user_registration,node_farm_registration toneBlue
class node_home,node_input_log,node_planting_log,node_harvest_log,node_history,node_qr_scanner toneAmber
class node_app,node_navigator,node_gateway toneMint
class node_api,node_signed_client,node_token_store toneRose
class node_farmer toneIndigo
```

## Components

### Onboarding

- [Login](https://github.com/truganic/client-farmer/blob/main/src/screens/LoginScreen.js): `src/screens/LoginScreen.js`
- [User registration](https://github.com/truganic/client-farmer/blob/main/src/screens/UserRegistrationScreen.js): `src/screens/UserRegistrationScreen.js`
- [Farm registration](https://github.com/truganic/client-farmer/blob/main/src/screens/FarmRegistrationScreen.js): `src/screens/FarmRegistrationScreen.js`

### Farm Activity

- [Dashboard](https://github.com/truganic/client-farmer/blob/main/src/screens/HomeScreen.js): `src/screens/HomeScreen.js`
- [Input log](https://github.com/truganic/client-farmer/blob/main/src/screens/InputLogScreen.js): `src/screens/InputLogScreen.js`
- [Planting log](https://github.com/truganic/client-farmer/blob/main/src/screens/PlantingLogScreen.js): `src/screens/PlantingLogScreen.js`
- [Harvest log](https://github.com/truganic/client-farmer/blob/main/src/screens/HarvestLogScreen.js): `src/screens/HarvestLogScreen.js`
- [Activity history](https://github.com/truganic/client-farmer/blob/main/src/screens/HistoryScreen.js): `src/screens/HistoryScreen.js`
- [QR scanner](https://github.com/truganic/client-farmer/blob/main/src/screens/QRScannerScreen.js): `src/screens/QRScannerScreen.js`

### App Flow

- [App root](https://github.com/truganic/client-farmer/blob/main/App.js): `App.js`
- [Stack navigation](https://github.com/truganic/client-farmer/blob/main/src/navigation/AppNavigator.js): `src/navigation/AppNavigator.js`

### Service Layer

- [API client](https://github.com/truganic/client-farmer/blob/main/src/api/config.js): `src/api/config.js`
- [Signed requests](https://github.com/truganic/client-farmer/blob/main/src/auth/signedClient.js): `src/auth/signedClient.js`
- **Token storage**

### Other components

- **Farmer**
- **API gateway**

## Connections

- Farmer → Stack navigation: opens app (evidence: `README.md`)
- App root → Stack navigation: renders (evidence: `App.js`)
- Stack navigation → Login: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → User registration: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → Farm registration: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → Dashboard: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → Input log: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → Planting log: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → Harvest log: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → Activity history: routes to (evidence: `src/navigation/AppNavigator.js`)
- Stack navigation → QR scanner: routes to (evidence: `src/navigation/AppNavigator.js`)
- Farmer → Login: signs in (evidence: `README.md`)
- Farmer → User registration: creates account (evidence: `README.md`)
- Farmer → Farm registration: registers farm (evidence: `README.md`)
- Farm registration → API client: submits registration (evidence: `src/screens/FarmRegistrationScreen.js`)
- Login → API client: requests auth (evidence: `src/screens/LoginScreen.js`)
- User registration → API client: requests signup
- Dashboard → API client: loads activity (evidence: `src/screens/HomeScreen.js`)
- Input log → API client: saves input (evidence: `src/screens/InputLogScreen.js`)
- Planting log → API client: saves planting (evidence: `src/screens/PlantingLogScreen.js`)
- Harvest log → API client: saves harvest (evidence: `src/screens/HarvestLogScreen.js`)
- Activity history → API client: loads history (evidence: `src/screens/HistoryScreen.js`)
- API client → Signed requests: sends signed request (evidence: `src/api/config.js`)
- API client → Token storage: reads tokens (evidence: `src/api/config.js`)
- API client → Token storage: updates tokens (evidence: `src/api/config.js`)
- Signed requests → API gateway: sends HTTP request (evidence: `src/auth/signedClient.js`)
- Farmer → QR scanner: scans code
