# acbayanbaja-spec/agrimarket architecture

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

- Interactive diagram: https://gitdiagram.com/acbayanbaja-spec/agrimarket
- Repository: https://github.com/acbayanbaja-spec/agrimarket

## Overview

AgriMarket is a multi-role agricultural marketplace with a web client, a native mobile client, and a shared Express REST backend backed by MySQL; the README also documents Socket.IO real-time functionality. The main buyer journey is product discovery, cart, checkout, and order tracking, alongside seller, delivery, admin, messaging, trade, and price-monitoring capabilities. The web route map and mobile store logic are excerpted; most backend and additional page implementations are not, so their internal links are limited to documented relationships.

Main entry points: [`web/src/App.tsx`](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/App.tsx) (Web application), [`backend/src/routes`](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/backend/src/routes) (REST API), [`mobile/app`](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/mobile/app) (Android application), [`mobile/src/context/StoreContext.tsx`](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/mobile/src/context/StoreContext.tsx) (Mobile store state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client applications"]
  node_web["Web application<br/>[App.tsx]"]
  node_mobile["Android application"]
end

subgraph group_commerce["Marketplace workflows"]
  node_webpages["Commerce pages"]
  node_mobilecommerce["Mobile commerce"]
  node_webstate["Web store state<br/>[StoreContext.tsx]"]
  node_mobilestate["Mobile store state<br/>[StoreContext.tsx]"]
  node_catalog["Mobile catalog<br/>[catalog.ts]"]
end

subgraph group_operations["Platform operations"]
  node_seller["Seller management"]
  node_admin["Admin oversight"]
  node_delivery["Delivery operations"]
  node_social["Social and trades"]
  node_insights["Analytics and prices"]
end

subgraph group_backend["Backend services"]
  node_backendapi["REST API"]
  node_auth["Authentication<br/>[authService.ts]"]
  node_realtime["Real-time messaging<br/>[index.ts]"]
end

subgraph group_persistence["Persistence"]
  node_mysqlpool["MySQL connection<br/>[database.ts]"]
  node_mysql[("MySQL database")]
  node_localstorage[("Mobile local storage")]
end

node_buyer(("Marketplace users"))

node_buyer -->|"uses"| node_web
node_buyer -->|"uses"| node_mobile
node_web -->|"routes to"| node_webpages
node_web -->|"routes to"| node_seller
node_web -->|"routes to"| node_admin
node_web -->|"routes to"| node_delivery
node_web -->|"routes to"| node_social
node_web -->|"routes to"| node_insights
node_webpages -.->|"uses state"| node_webstate
node_mobile -.->|"routes to"| node_mobilecommerce
node_mobilecommerce -.->|"uses state"| node_mobilestate
node_mobilestate -->|"loads products"| node_catalog
node_web -->|"REST requests"| node_backendapi
node_mobile -->|"REST requests"| node_backendapi
node_backendapi -.->|"queries"| node_mysqlpool
node_mysqlpool -->|"connects"| node_mysql
node_backendapi -.->|"authenticates"| node_auth
node_backendapi -.->|"real-time events"| node_realtime
node_mobilestate -->|"reads and writes"| node_localstorage

click node_web "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/App.tsx"
click node_mobile "https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/mobile/app"
click node_webpages "https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/web/src/pages"
click node_mobilecommerce "https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/mobile/app"
click node_webstate "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/context/StoreContext.tsx"
click node_mobilestate "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/mobile/src/context/StoreContext.tsx"
click node_catalog "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/mobile/src/data/catalog.ts"
click node_seller "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/pages/SellerDashboardPage.tsx"
click node_admin "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/pages/AdminDashboardPage.tsx"
click node_delivery "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/pages/DeliveryDashboardPage.tsx"
click node_social "https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/web/src/pages"
click node_insights "https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/web/src/pages"
click node_backendapi "https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/backend/src/routes"
click node_auth "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/backend/src/services/authService.ts"
click node_realtime "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/backend/src/sockets/index.ts"
click node_mysqlpool "https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/backend/src/config/database.ts"

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_web,node_mobile,node_buyer toneBlue
class node_webpages,node_mobilecommerce,node_webstate,node_mobilestate,node_catalog toneAmber
class node_seller,node_admin,node_delivery,node_social,node_insights toneMint
class node_backendapi,node_auth,node_realtime toneRose
class node_mysqlpool,node_mysql,node_localstorage toneIndigo
```

## Components

### Client applications

- [Web application](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/App.tsx): `web/src/App.tsx`
- [Android application](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/mobile/app): `mobile/app`

### Marketplace workflows

- [Commerce pages](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/web/src/pages): `web/src/pages`
- [Mobile commerce](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/mobile/app): `mobile/app`
- [Web store state](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/context/StoreContext.tsx): `web/src/context/StoreContext.tsx`
- [Mobile store state](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/mobile/src/context/StoreContext.tsx): `mobile/src/context/StoreContext.tsx`
- [Mobile catalog](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/mobile/src/data/catalog.ts): `mobile/src/data/catalog.ts`

### Platform operations

- [Seller management](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/pages/SellerDashboardPage.tsx): `web/src/pages/SellerDashboardPage.tsx`
- [Admin oversight](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/pages/AdminDashboardPage.tsx): `web/src/pages/AdminDashboardPage.tsx`
- [Delivery operations](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/web/src/pages/DeliveryDashboardPage.tsx): `web/src/pages/DeliveryDashboardPage.tsx`
- [Social and trades](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/web/src/pages): `web/src/pages`
- [Analytics and prices](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/web/src/pages): `web/src/pages`

### Backend services

- [REST API](https://github.com/acbayanbaja-spec/agrimarket/tree/deploy-ready/backend/src/routes): `backend/src/routes`
- [Authentication](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/backend/src/services/authService.ts): `backend/src/services/authService.ts`
- [Real-time messaging](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/backend/src/sockets/index.ts): `backend/src/sockets/index.ts`

### Persistence

- [MySQL connection](https://github.com/acbayanbaja-spec/agrimarket/blob/deploy-ready/backend/src/config/database.ts): `backend/src/config/database.ts`
- **MySQL database**
- **Mobile local storage**

### Other components

- **Marketplace users**

## Connections

- Marketplace users → Web application: uses
- Marketplace users → Android application: uses
- Web application → Commerce pages: routes to (evidence: `web/src/App.tsx`)
- Web application → Seller management: routes to (evidence: `web/src/App.tsx`)
- Web application → Admin oversight: routes to (evidence: `web/src/App.tsx`)
- Web application → Delivery operations: routes to (evidence: `web/src/App.tsx`)
- Web application → Social and trades: routes to (evidence: `web/src/App.tsx`)
- Web application → Analytics and prices: routes to (evidence: `web/src/App.tsx`)
- Commerce pages → Web store state: uses state
- Android application → Mobile commerce: routes to
- Mobile commerce → Mobile store state: uses state
- Mobile store state → Mobile catalog: loads products (evidence: `mobile/src/context/StoreContext.tsx`)
- Web application → REST API: REST requests
- Android application → REST API: REST requests
- REST API → MySQL connection: queries
- MySQL connection → MySQL database: connects (evidence: `backend/src/config/database.ts`)
- REST API → Authentication: authenticates
- REST API → Real-time messaging: real-time events
- Mobile store state → Mobile local storage: reads and writes (evidence: `mobile/src/context/StoreContext.tsx`)
