How chodisettiakshitha-code/agrochain-main works
AgroChain combines a farmer-to-consumer Algorand marketplace with a separate x402-paid agricultural-services API. The main marketplace flow is users connecting a wallet, browsing or listing produce, and purchasing through the frontend’s chain hook and the marketplace contract; the backend provides paid advisory, forecasting, quality-verification, and produce-purchase endpoints. The sampled frontend and contract code supports the wallet, state, and contract relationships shown. Backend-to-facilitator payment handling is documented in the server excerpt; unsampled frontend service wiring is left unspecified.
Main entry points: App.tsx Application shell · useAgroChain.ts Marketplace state hook · index.ts x402 API server · Marketplace.tsx Marketplace
Components 15
Marketplace frontend
- Application shell
frontend/src/App.tsx - Marketplace
frontend/src/pages/Marketplace.tsx - Farmer dashboard
frontend/src/pages/FarmerDashboard.tsx - Order history
frontend/src/pages/MyOrders.tsx - Agri services UI
frontend/src/pages/AgriServices.tsx - Wallet connection
frontend/src/components/WalletButton.tsx - Marketplace state hook
frontend/src/hooks/useAgroChain.ts - Chain access service
frontend/src/services/agrochain.ts
Algorand marketplace
- Contract client
frontend/src/contracts/AgroChainMarketplace.ts - Marketplace contract
contracts/smart_contracts/agrochain_marketplace/contract.py
Paid agricultural services
- x402 API server
backend/index.ts - Agriculture handlers
backend/handlers/agrochain.ts
Other components
- Farmer or consumer
- Algorand network
- x402 facilitator
Connections 18
- Farmer or consumer → Application shell: uses
- Application shell → Marketplace: renders
- Application shell → Farmer dashboard: renders
- Application shell → Order history: renders
- Application shell → Agri services UI: renders
- Application shell → Marketplace state hook: uses
- Application shell → Wallet connection: opens
- Marketplace → Marketplace state hook: requests purchases
- Farmer dashboard → Marketplace state hook: requests listings
- Order history → Marketplace state hook: displays orders
- Marketplace state hook → Wallet connection: uses signer
- Marketplace state hook → Chain access service: reads and records
- Marketplace state hook → Contract client: calls contract
- Contract client → Algorand network: submits transactions
- Algorand network → Marketplace contract: executes
- Agri services UI → x402 API server: requests paid services
- x402 API server → x402 facilitator: verifies payments
- x402 API server → Agriculture handlers: dispatches routes