# shawaiz-project/agrismart-mobile-and-web-app-v1 architecture

> Architecture diagram of the GitHub repository shawaiz-project/agrismart-mobile-and-web-app-v1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shawaiz-project/agrismart-mobile-and-web-app-v1
- Repository: https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1

## Overview

AgriSmart is an agricultural management and commerce platform: farmers and buyers use the Expo app to manage farms and crops, monitor crop health and conditions, consult AMIS prices, and transact in the marketplace; administrators operate a permission-gated console. The mobile API client connects those workflows to the Express API, which owns authorization and PostgreSQL business data. Mobile SQLite supports offline caches and queued mutations. Major API dispatch is visible in app.js; detailed wiring for unsampled route modules and offline synchronization is not shown, so those links are kept at subsystem level.

Main entry points: [`backend/src/app.js`](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/app.js) (REST API router), [`mobile/src/app/_layout.jsx`](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/_layout.jsx) (Mobile navigation), [`mobile/src/api/client.js`](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/api/client.js) (API client), [`backend/src/db/pool.js`](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/db/pool.js) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobileapp["Mobile navigation<br/>[_layout.jsx]"]
  node_authscreens["Sign-in and onboarding<br/>[login.jsx]"]
  node_adminui["Admin console<br/>[_layout.jsx]"]
  node_apiclient["API client<br/>[client.js]"]
end

subgraph group_farm["Farm intelligence"]
  node_farmui["Farm and crop screens<br/>[farms.jsx]"]
  node_scanui["Disease scanning<br/>[index.jsx]"]
  node_weatherui["Weather and prices<br/>[index.jsx]"]
  node_farmroutes["Farms and crops<br/>[farms.js]"]
  node_airoutes["AI crop analysis<br/>[ai.js]"]
  node_weatherprices["Weather and AMIS<br/>[market-prices.js]"]
end

subgraph group_commerce["Marketplace and plans"]
  node_marketui["Marketplace and orders<br/>[index.jsx]"]
  node_plansui["Subscriptions<br/>[index.jsx]"]
  node_marketorders["Listings and orders<br/>[marketplace.js]"]
  node_subscriptionroutes["Plans and entitlements<br/>[subscriptions.js]"]
end

subgraph group_backend["API and administration"]
  node_backendapp["REST API router<br/>[app.js]"]
  node_authroutes["Identity and OTP<br/>[auth.js]"]
  node_adminroutes["Admin operations<br/>[admin.js]"]
end

subgraph group_state["Platform state"]
  node_localdb[("Offline cache and outbox<br/>[client.js]")]
  node_pg[("PostgreSQL<br/>[pool.js]")]
end

node_user(("Farmers and buyers"))
node_adminuser(("Administrators"))
node_ai_service{{"AI provider"}}
node_weather_service{{"Weather provider"}}
node_amis_service{{"AMIS source"}}

node_user -->|"uses"| node_mobileapp
node_adminuser -->|"uses"| node_adminui
node_mobileapp -->|"navigates"| node_authscreens
node_mobileapp -->|"navigates"| node_farmui
node_mobileapp -->|"navigates"| node_scanui
node_mobileapp -->|"navigates"| node_weatherui
node_mobileapp -->|"navigates"| node_marketui
node_mobileapp -->|"navigates"| node_plansui
node_authscreens -->|"requests"| node_apiclient
node_farmui -->|"requests"| node_apiclient
node_scanui -->|"requests"| node_apiclient
node_weatherui -->|"requests"| node_apiclient
node_marketui -->|"requests"| node_apiclient
node_plansui -->|"requests"| node_apiclient
node_adminui -->|"requests"| node_apiclient
node_farmui -.->|"caches offline"| node_localdb
node_marketui -.->|"queues offline"| node_localdb
node_apiclient -->|"HTTP requests"| node_backendapp
node_backendapp -->|"dispatches"| node_authroutes
node_backendapp -->|"dispatches"| node_farmroutes
node_backendapp -->|"dispatches"| node_airoutes
node_backendapp -->|"dispatches"| node_weatherprices
node_backendapp -->|"dispatches"| node_marketorders
node_backendapp -->|"dispatches"| node_subscriptionroutes
node_backendapp -->|"dispatches"| node_adminroutes
node_authroutes -->|"queries"| node_pg
node_authroutes -.->|"sends OTP email"| node_ai_service
node_farmroutes -->|"stores records"| node_pg
node_airoutes -.->|"requests analysis"| node_ai_service
node_weatherprices -.->|"gets forecasts"| node_weather_service
node_weatherprices -.->|"syncs prices"| node_amis_service
node_marketorders -->|"stores transactions"| node_pg
node_subscriptionroutes -->|"stores plans"| node_pg
node_adminroutes -->|"manages records"| node_pg

click node_mobileapp "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/_layout.jsx"
click node_authscreens "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(public)/login.jsx"
click node_farmui "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/(tabs)/farms.jsx"
click node_scanui "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/scan/index.jsx"
click node_weatherui "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/weather/index.jsx"
click node_marketui "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/marketplace/index.jsx"
click node_plansui "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/subscription/index.jsx"
click node_adminui "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(admin)/_layout.jsx"
click node_apiclient "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/api/client.js"
click node_localdb "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/db/client.js"
click node_backendapp "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/app.js"
click node_authroutes "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/auth.js"
click node_farmroutes "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/farms.js"
click node_airoutes "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/ai.js"
click node_weatherprices "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/market-prices.js"
click node_marketorders "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/marketplace.js"
click node_subscriptionroutes "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/subscriptions.js"
click node_adminroutes "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/admin.js"
click node_pg "https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/db/pool.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_mobileapp,node_authscreens,node_adminui,node_apiclient toneBlue
class node_farmui,node_scanui,node_weatherui,node_farmroutes,node_airoutes,node_weatherprices toneAmber
class node_marketui,node_plansui,node_marketorders,node_subscriptionroutes toneMint
class node_backendapp,node_authroutes,node_adminroutes toneRose
class node_localdb,node_pg,node_user,node_adminuser,node_ai_service,node_weather_service,node_amis_service toneIndigo
```

## Components

### Mobile app

- [Mobile navigation](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/_layout.jsx): `mobile/src/app/_layout.jsx`
- [Sign-in and onboarding](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(public)/login.jsx): `mobile/src/app/(public)/login.jsx`
- [Admin console](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(admin)/_layout.jsx): `mobile/src/app/(admin)/_layout.jsx`
- [API client](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/api/client.js): `mobile/src/api/client.js`

### Farm intelligence

- [Farm and crop screens](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/(tabs)/farms.jsx): `mobile/src/app/(app)/(tabs)/farms.jsx`
- [Disease scanning](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/scan/index.jsx): `mobile/src/app/(app)/scan/index.jsx`
- [Weather and prices](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/weather/index.jsx): `mobile/src/app/(app)/weather/index.jsx`
- [Farms and crops](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/farms.js): `backend/src/routes/farms.js`
- [AI crop analysis](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/ai.js): `backend/src/routes/ai.js`
- [Weather and AMIS](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/market-prices.js): `backend/src/routes/market-prices.js`

### Marketplace and plans

- [Marketplace and orders](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/marketplace/index.jsx): `mobile/src/app/(app)/marketplace/index.jsx`
- [Subscriptions](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/app/(app)/subscription/index.jsx): `mobile/src/app/(app)/subscription/index.jsx`
- [Listings and orders](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/marketplace.js): `backend/src/routes/marketplace.js`
- [Plans and entitlements](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/subscriptions.js): `backend/src/routes/subscriptions.js`

### API and administration

- [REST API router](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/app.js): `backend/src/app.js`
- [Identity and OTP](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Admin operations](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/routes/admin.js): `backend/src/routes/admin.js`

### Platform state

- [Offline cache and outbox](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/mobile/src/db/client.js): `mobile/src/db/client.js`
- [PostgreSQL](https://github.com/shawaiz-project/agrismart-mobile-and-web-app-v1/blob/main/backend/src/db/pool.js): `backend/src/db/pool.js`

### Other components

- **Farmers and buyers**
- **Administrators**
- **AI provider**
- **Weather provider**
- **AMIS source**

## Connections

- Farmers and buyers → Mobile navigation: uses
- Administrators → Admin console: uses
- Mobile navigation → Sign-in and onboarding: navigates
- Mobile navigation → Farm and crop screens: navigates
- Mobile navigation → Disease scanning: navigates
- Mobile navigation → Weather and prices: navigates
- Mobile navigation → Marketplace and orders: navigates
- Mobile navigation → Subscriptions: navigates
- Sign-in and onboarding → API client: requests
- Farm and crop screens → API client: requests
- Disease scanning → API client: requests
- Weather and prices → API client: requests
- Marketplace and orders → API client: requests
- Subscriptions → API client: requests
- Admin console → API client: requests
- Farm and crop screens → Offline cache and outbox: caches offline
- Marketplace and orders → Offline cache and outbox: queues offline
- API client → REST API router: HTTP requests
- REST API router → Identity and OTP: dispatches
- REST API router → Farms and crops: dispatches
- REST API router → AI crop analysis: dispatches
- REST API router → Weather and AMIS: dispatches
- REST API router → Listings and orders: dispatches
- REST API router → Plans and entitlements: dispatches
- REST API router → Admin operations: dispatches
- Identity and OTP → PostgreSQL: queries
- Identity and OTP → AI provider: sends OTP email
- Farms and crops → PostgreSQL: stores records
- AI crop analysis → AI provider: requests analysis
- Weather and AMIS → Weather provider: gets forecasts
- Weather and AMIS → AMIS source: syncs prices
- Listings and orders → PostgreSQL: stores transactions
- Plans and entitlements → PostgreSQL: stores plans
- Admin operations → PostgreSQL: manages records
