# santhoshbandrapalli58-creator/farm2market architecture

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

- Interactive diagram: https://gitdiagram.com/santhoshbandrapalli58-creator/farm2market
- Repository: https://github.com/santhoshbandrapalli58-creator/farm2market

## Overview

Farm2Market connects customers and farmers through two Android apps sharing a Compose runtime and Supabase repository. Customers authenticate, browse nearby produce, build a cart, place seller-specific orders, and track status; farmers manage listings and stock and advance assigned orders. The shared coordinator handles location, session/profile setup, refresh, and realtime subscriptions. Supabase Auth and the SQL-defined Postgres functions, policies, and triggers provide identity and transactional marketplace behavior. The README documents backend capabilities not visible in sampled SQL; edges reflect only shown calls or documented relationships.

Main entry points: [`native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt) (App coordinator), [`native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt`](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt) (Marketplace repository), [`supabase/schema.sql`](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/supabase/schema.sql) (Marketplace database), [`customer_app/android/app/src/main/kotlin/com/farm2market/customer/MainActivity.kt`](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/customer_app/android/app/src/main/kotlin/com/farm2market/customer/MainActivity.kt) (Customer entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Android apps"]
  node_customer_entry["Customer entry<br/>[MainActivity.kt]"]
  node_farmer_entry["Farmer entry<br/>[MainActivity.kt]"]
end

subgraph group_shared["Shared application"]
  node_coordinator["App coordinator<br/>[Farm2MarketApp.kt]"]
  node_auth_ui["Sign-in and profile<br/>[NameEntryScreen.kt]"]
  node_customer_market["Shop and orders<br/>[CustomerApp.kt]"]
  node_farmer_market["Farm listings and orders<br/>[FarmerApp.kt]"]
  node_theme["Shared theme<br/>[Theme.kt]"]
  node_repository["Marketplace repository<br/>[FarmRepository.kt]"]
  node_location["Device location<br/>[Farm2MarketApp.kt]"]
end

subgraph group_backend["Supabase backend"]
  node_supabase_auth["Supabase Auth"]
  node_postgrest["PostgREST RPC"]
  node_realtime["Supabase Realtime"]
end

subgraph group_data["Marketplace data"]
  node_database[("Marketplace database<br/>[schema.sql]")]
end

node_customer(("Customer"))
node_farmer(("Farmer"))

node_customer -->|"uses"| node_customer_entry
node_farmer -->|"uses"| node_farmer_entry
node_customer_entry -->|"launches"| node_coordinator
node_farmer_entry -->|"launches"| node_coordinator
node_coordinator -->|"renders"| node_auth_ui
node_coordinator -->|"renders"| node_customer_market
node_coordinator -->|"renders"| node_farmer_market
node_coordinator -->|"uses"| node_repository
node_coordinator -->|"requests"| node_location
node_customer_market -->|"loads marketplace data"| node_repository
node_farmer_market -->|"updates listings"| node_repository
node_auth_ui -->|"submits credentials"| node_coordinator
node_repository -->|"authenticates"| node_supabase_auth
node_repository -->|"calls RPCs"| node_postgrest
node_postgrest -->|"queries and mutates"| node_database
node_repository -->|"subscribes"| node_realtime
node_realtime -->|"signals refresh"| node_repository
node_database -->|"publishes changes"| node_realtime
node_repository -->|"reads and updates tables"| node_database
node_coordinator -->|"applies"| node_theme

click node_customer_entry "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/customer_app/android/app/src/main/kotlin/com/farm2market/customer/MainActivity.kt"
click node_farmer_entry "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/farmer_app/android/app/src/main/kotlin/com/farm2market/farmer/MainActivity.kt"
click node_coordinator "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt"
click node_auth_ui "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/NameEntryScreen.kt"
click node_customer_market "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/CustomerApp.kt"
click node_farmer_market "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/FarmerApp.kt"
click node_theme "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/Theme.kt"
click node_repository "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt"
click node_location "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt"
click node_database "https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/supabase/schema.sql"

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_customer_entry,node_farmer_entry toneBlue
class node_coordinator,node_auth_ui,node_customer_market,node_farmer_market,node_theme,node_repository,node_location toneAmber
class node_supabase_auth,node_postgrest,node_realtime toneMint
class node_database toneRose
class node_customer,node_farmer toneIndigo
```

## Components

### Android apps

- [Customer entry](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/customer_app/android/app/src/main/kotlin/com/farm2market/customer/MainActivity.kt): `customer_app/android/app/src/main/kotlin/com/farm2market/customer/MainActivity.kt`
- [Farmer entry](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/farmer_app/android/app/src/main/kotlin/com/farm2market/farmer/MainActivity.kt): `farmer_app/android/app/src/main/kotlin/com/farm2market/farmer/MainActivity.kt`

### Shared application

- [App coordinator](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt): `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`
- [Sign-in and profile](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/NameEntryScreen.kt): `native_shared/src/main/kotlin/com/farm2market/shared/NameEntryScreen.kt`
- [Shop and orders](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/CustomerApp.kt): `native_shared/src/main/kotlin/com/farm2market/shared/CustomerApp.kt`
- [Farm listings and orders](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/FarmerApp.kt): `native_shared/src/main/kotlin/com/farm2market/shared/FarmerApp.kt`
- [Shared theme](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/Theme.kt): `native_shared/src/main/kotlin/com/farm2market/shared/Theme.kt`
- [Marketplace repository](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt): `native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt`
- [Device location](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt): `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`

### Supabase backend

- **Supabase Auth**
- **PostgREST RPC**
- **Supabase Realtime**

### Marketplace data

- [Marketplace database](https://github.com/santhoshbandrapalli58-creator/farm2market/blob/main/supabase/schema.sql): `supabase/schema.sql`

### Other components

- **Customer**
- **Farmer**

## Connections

- Customer → Customer entry: uses (evidence: `README.md`)
- Farmer → Farmer entry: uses (evidence: `README.md`)
- Customer entry → App coordinator: launches (evidence: `customer_app/android/app/src/main/kotlin/com/farm2market/customer/MainActivity.kt`)
- Farmer entry → App coordinator: launches (evidence: `farmer_app/android/app/src/main/kotlin/com/farm2market/farmer/MainActivity.kt`)
- App coordinator → Sign-in and profile: renders (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`)
- App coordinator → Shop and orders: renders (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`)
- App coordinator → Farm listings and orders: renders (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`)
- App coordinator → Marketplace repository: uses (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`)
- App coordinator → Device location: requests (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`)
- Shop and orders → Marketplace repository: loads marketplace data (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/CustomerApp.kt`)
- Farm listings and orders → Marketplace repository: updates listings (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/FarmerApp.kt`)
- Sign-in and profile → App coordinator: submits credentials (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`)
- Marketplace repository → Supabase Auth: authenticates (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt`)
- Marketplace repository → PostgREST RPC: calls RPCs (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt`)
- PostgREST RPC → Marketplace database: queries and mutates (evidence: `README.md`)
- Marketplace repository → Supabase Realtime: subscribes (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt`)
- Supabase Realtime → Marketplace repository: signals refresh (evidence: `README.md`)
- Marketplace database → Supabase Realtime: publishes changes (evidence: `README.md`)
- Marketplace repository → Marketplace database: reads and updates tables (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/FarmRepository.kt`)
- App coordinator → Shared theme: applies (evidence: `native_shared/src/main/kotlin/com/farm2market/shared/Farm2MarketApp.kt`)
