# dabaly/agrilink architecture

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

- Interactive diagram: https://gitdiagram.com/dabaly/agrilink
- Repository: https://github.com/dabaly/agrilink

## Overview

AgriLink is a Flask agricultural marketplace. Farmers publish listings and buyers browse them, negotiate through persistent conversations and offers, and acceptance creates a confirmed order with a stock claim. The broader product also covers fulfillment, payments, disputes, reviews, notifications, and administrator operations. The graph uses documented capabilities and sampled call/import evidence; some later-stage routes and integrations are represented at their existing subsystem paths because their implementation excerpts were not available.

Main entry points: [`app/__init__.py`](https://github.com/dabaly/agrilink/blob/main/app/__init__.py) (Flask application), [`app/orders/services.py`](https://github.com/dabaly/agrilink/blob/main/app/orders/services.py) (Orders and fulfillment), [`app/notifications/services.py`](https://github.com/dabaly/agrilink/blob/main/app/notifications/services.py) (Notifications), [`app/marketplace/routes.py`](https://github.com/dabaly/agrilink/blob/main/app/marketplace/routes.py) (Marketplace routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Accounts and access"]
  node_auth["Accounts and OTP<br/>[services.py]"]
  node_otp["OTP delivery<br/>[otp.py]"]
end

subgraph group_market["Marketplace and trade"]
  node_listing["Listings and search<br/>[services.py]"]
  node_listing_routes["Marketplace routes<br/>[routes.py]"]
  node_images["Listing images<br/>[images.py]"]
  node_conversation["Conversations and offers<br/>[services.py]"]
  node_chat_routes["Chat routes and sockets<br/>[routes.py]"]
end

subgraph group_fulfillment["Orders and resolution"]
  node_orders["Orders and fulfillment<br/>[services.py]"]
  node_payments["Payment orchestration<br/>[services.py]"]
  node_payment_provider["Payment providers<br/>[providers.py]"]
  node_disputes["Dispute resolution<br/>[services.py]"]
  node_reviews["Reviews<br/>[services.py]"]
end

subgraph group_platform["Operations and messaging"]
  node_admin["Admin operations<br/>[services.py]"]
  node_audit["Audit records<br/>[services.py]"]
  node_notifications["Notifications<br/>[services.py]"]
end

node_visitor(("Visitor"))
node_farmer(("Farmer"))
node_buyer(("Buyer"))
node_administrator(("Administrator"))
node_webapp["Flask application<br/>[__init__.py]"]
node_data[("Application database<br/>[trading.py]")]

node_visitor -->|"browses"| node_webapp
node_farmer -->|"manages listings"| node_webapp
node_buyer -->|"uses marketplace"| node_webapp
node_administrator -->|"manages platform"| node_webapp
node_webapp -->|"registers"| node_auth
node_auth -->|"sends challenges"| node_otp
node_webapp -->|"registers"| node_listing_routes
node_listing_routes -->|"queries and updates"| node_listing
node_listing_routes -->|"serves images"| node_images
node_listing_routes -->|"loads summaries"| node_reviews
node_webapp -->|"registers"| node_chat_routes
node_chat_routes -->|"handles messages and offers"| node_conversation
node_conversation -->|"checks purchasability"| node_listing
node_conversation -->|"creates confirmed orders"| node_orders
node_webapp -->|"registers order routes"| node_orders
node_orders -->|"persists order state"| node_data
node_orders -->|"supports payment actions"| node_payments
node_payments -->|"queries and refunds"| node_payment_provider
node_webapp -->|"registers dispute routes"| node_disputes
node_disputes -->|"updates disputed orders"| node_orders
node_disputes -->|"requests refunds"| node_payments
node_webapp -->|"registers admin routes"| node_admin
node_admin -->|"records actions"| node_audit
node_webapp -->|"registers notification routes"| node_notifications
node_admin -->|"notifies users"| node_notifications
node_notifications -->|"stores notices"| node_data
node_orders -.->|"notifies participants"| node_notifications
node_reviews -.->|"notifies participants"| node_notifications
node_listing -->|"stores listings"| node_data
node_auth -->|"stores account challenges"| node_data

click node_webapp "https://github.com/dabaly/agrilink/blob/main/app/__init__.py"
click node_auth "https://github.com/dabaly/agrilink/blob/main/app/auth/services.py"
click node_otp "https://github.com/dabaly/agrilink/blob/main/app/integrations/otp.py"
click node_listing "https://github.com/dabaly/agrilink/blob/main/app/marketplace/services.py"
click node_listing_routes "https://github.com/dabaly/agrilink/blob/main/app/marketplace/routes.py"
click node_images "https://github.com/dabaly/agrilink/blob/main/app/marketplace/images.py"
click node_conversation "https://github.com/dabaly/agrilink/blob/main/app/chat/services.py"
click node_chat_routes "https://github.com/dabaly/agrilink/blob/main/app/chat/routes.py"
click node_orders "https://github.com/dabaly/agrilink/blob/main/app/orders/services.py"
click node_payments "https://github.com/dabaly/agrilink/blob/main/app/payments/services.py"
click node_payment_provider "https://github.com/dabaly/agrilink/blob/main/app/payments/providers.py"
click node_disputes "https://github.com/dabaly/agrilink/blob/main/app/disputes/services.py"
click node_reviews "https://github.com/dabaly/agrilink/blob/main/app/reviews/services.py"
click node_admin "https://github.com/dabaly/agrilink/blob/main/app/admin_ops/services.py"
click node_audit "https://github.com/dabaly/agrilink/blob/main/app/audit/services.py"
click node_notifications "https://github.com/dabaly/agrilink/blob/main/app/notifications/services.py"
click node_data "https://github.com/dabaly/agrilink/blob/main/app/models/trading.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_auth,node_otp toneBlue
class node_listing,node_listing_routes,node_images,node_conversation,node_chat_routes,node_data toneAmber
class node_orders,node_payments,node_payment_provider,node_disputes,node_reviews toneMint
class node_admin,node_audit,node_notifications toneRose
class node_visitor,node_farmer,node_buyer,node_administrator toneIndigo
class node_webapp toneTeal
```

## Components

### Accounts and access

- [Accounts and OTP](https://github.com/dabaly/agrilink/blob/main/app/auth/services.py): `app/auth/services.py`
- [OTP delivery](https://github.com/dabaly/agrilink/blob/main/app/integrations/otp.py): `app/integrations/otp.py`

### Marketplace and trade

- [Listings and search](https://github.com/dabaly/agrilink/blob/main/app/marketplace/services.py): `app/marketplace/services.py`
- [Marketplace routes](https://github.com/dabaly/agrilink/blob/main/app/marketplace/routes.py): `app/marketplace/routes.py`
- [Listing images](https://github.com/dabaly/agrilink/blob/main/app/marketplace/images.py): `app/marketplace/images.py`
- [Conversations and offers](https://github.com/dabaly/agrilink/blob/main/app/chat/services.py): `app/chat/services.py`
- [Chat routes and sockets](https://github.com/dabaly/agrilink/blob/main/app/chat/routes.py): `app/chat/routes.py`

### Orders and resolution

- [Orders and fulfillment](https://github.com/dabaly/agrilink/blob/main/app/orders/services.py): `app/orders/services.py`
- [Payment orchestration](https://github.com/dabaly/agrilink/blob/main/app/payments/services.py): `app/payments/services.py`
- [Payment providers](https://github.com/dabaly/agrilink/blob/main/app/payments/providers.py): `app/payments/providers.py`
- [Dispute resolution](https://github.com/dabaly/agrilink/blob/main/app/disputes/services.py): `app/disputes/services.py`
- [Reviews](https://github.com/dabaly/agrilink/blob/main/app/reviews/services.py): `app/reviews/services.py`

### Operations and messaging

- [Admin operations](https://github.com/dabaly/agrilink/blob/main/app/admin_ops/services.py): `app/admin_ops/services.py`
- [Audit records](https://github.com/dabaly/agrilink/blob/main/app/audit/services.py): `app/audit/services.py`
- [Notifications](https://github.com/dabaly/agrilink/blob/main/app/notifications/services.py): `app/notifications/services.py`

### Other components

- **Visitor**
- **Farmer**
- **Buyer**
- **Administrator**
- [Flask application](https://github.com/dabaly/agrilink/blob/main/app/__init__.py): `app/__init__.py`
- [Application database](https://github.com/dabaly/agrilink/blob/main/app/models/trading.py): `app/models/trading.py`

## Connections

- Visitor → Flask application: browses
- Farmer → Flask application: manages listings
- Buyer → Flask application: uses marketplace
- Administrator → Flask application: manages platform
- Flask application → Accounts and OTP: registers (evidence: `app/__init__.py`)
- Accounts and OTP → OTP delivery: sends challenges (evidence: `app/auth/services.py`)
- Flask application → Marketplace routes: registers (evidence: `app/__init__.py`)
- Marketplace routes → Listings and search: queries and updates (evidence: `app/marketplace/routes.py`)
- Marketplace routes → Listing images: serves images (evidence: `app/marketplace/routes.py`)
- Marketplace routes → Reviews: loads summaries (evidence: `app/marketplace/routes.py`)
- Flask application → Chat routes and sockets: registers (evidence: `app/__init__.py`)
- Chat routes and sockets → Conversations and offers: handles messages and offers (evidence: `app/chat/routes.py`)
- Conversations and offers → Listings and search: checks purchasability (evidence: `app/chat/services.py`)
- Conversations and offers → Orders and fulfillment: creates confirmed orders (evidence: `app/chat/services.py`)
- Flask application → Orders and fulfillment: registers order routes (evidence: `app/__init__.py`)
- Orders and fulfillment → Application database: persists order state (evidence: `app/orders/services.py`)
- Orders and fulfillment → Payment orchestration: supports payment actions (evidence: `app/orders/routes.py`)
- Payment orchestration → Payment providers: queries and refunds (evidence: `app/payments/services.py`)
- Flask application → Dispute resolution: registers dispute routes (evidence: `app/__init__.py`)
- Dispute resolution → Orders and fulfillment: updates disputed orders (evidence: `app/disputes/services.py`)
- Dispute resolution → Payment orchestration: requests refunds (evidence: `app/disputes/services.py`)
- Flask application → Admin operations: registers admin routes (evidence: `app/__init__.py`)
- Admin operations → Audit records: records actions (evidence: `app/admin_ops/services.py`)
- Flask application → Notifications: registers notification routes (evidence: `app/__init__.py`)
- Admin operations → Notifications: notifies users (evidence: `app/admin_ops/services.py`)
- Notifications → Application database: stores notices (evidence: `app/notifications/services.py`)
- Orders and fulfillment → Notifications: notifies participants (evidence: `app/orders/services.py`)
- Reviews → Notifications: notifies participants (evidence: `app/reviews/services.py`)
- Listings and search → Application database: stores listings (evidence: `app/marketplace/services.py`)
- Accounts and OTP → Application database: stores account challenges (evidence: `app/auth/services.py`)
