Skip to content

Repository files navigation

ClaimFarm

Crop-insurance claims for the next 500 million smallholder farmers. One WhatsApp / Telegram photo, one filed claim, in any language — built on Qwen Cloud + Alibaba Cloud.

License: MIT Python 3.11+ Built on Qwen Cloud Backend: Alibaba Cloud Next.js 16

Submitted to the Global AI Hackathon Series with Qwen Cloud — Track 4: Autopilot Agent.

URL
Marketing + adjuster console https://claimfarm-dashboard.vercel.app
API + agent backend https://claimfarm-api-wovsxktpbk.ap-southeast-1.fcapp.run
Live Telegram bot https://t.me/claimfarm_demo_bot
Docs Architecture · Deployment · API · Security · Onboarding

Architecture

ClaimFarm architecture: Telegram farmers → FastAPI on Alibaba Function Compute → Qwen Cloud (VL-Max, Max, embeddings), Neon Postgres, DashVector, Open-Meteo, Resend → Next.js adjuster console on Vercel

Full walkthrough with the request flow and storage layout in docs/architecture.md.

Why

~500 million smallholder farmers globally lose crops to weather and pests every year. Less than 20% of eligible farmers ever file an insurance claim, because the forms are in the wrong language, demand structured evidence they cannot easily produce, and assume domain literacy. ClaimFarm collapses that workflow to a single photo.

What it does

  1. Farmer sends a damaged-crop photo (and optionally a few words in any language) to a Telegram or WhatsApp number.
  2. Qwen-VL-Max assesses the photo: crop type, damage cause, severity, affected area, visible indicators.
  3. Photo forensics layer (EXIF + Qwen-VL authenticity prompt + perceptual hashing) flags downloaded stock images, screenshots, AI generations, watermarks.
  4. Open-Meteo historical weather is cross-referenced against the farmer's GPS and the photo's capture date to corroborate the diagnosis.
  5. Qwen embeddings + Alibaba DashVector retrieve similar past claims, relevant agronomy guides, and possible fraud patterns.
  6. Qwen-Max drafts a pre-filled claim PDF (WeasyPrint).
  7. The claim lands in an adjuster's Next.js console for human review and approval.
  8. On approval the claim is submitted to a mock insurer API; the farmer is notified in their own language.

What's built

The product surface is a real, sellable SaaS:

  • Marketing site/, /pricing, /about, /faq, /blog, /contact, /farmer, /legal/terms, /legal/privacy
  • Auth — sign-up, sign-in, sign-out, password reset, email verification, server-side sessions, RBAC (owner > admin > moderator > reviewer > farmer), audit log
  • Identity verification — provider abstraction (MockProvider by default; Persona, Veriff, Onfido subclasses ready)
  • Adjuster console/admin: queue, AI assessment, weather corroboration, photo forensics, similar past claims, fraud flags, localized farmer message, decision controls
  • User dashboard/dashboard: overview, billing (disabled by default), team + RBAC, API & webhooks, notifications, settings
  • Channels — Telegram (working end-to-end), Twilio + Bird WhatsApp (code shipped, trial-tier limits documented)
  • Payments — merchant-of-record abstraction (Paddle / LemonSqueezy / Razorpay), PAYMENTS_PROVIDER=none by default
  • Notifications — multi-channel dispatcher (email, SMS, in-app) with templates
  • DevOps — Dockerfile, docker-compose.yml, GitHub Actions for backend lint+test and web typecheck+build, dual-push to Alibaba ACR + ghcr.io
  • Docs — architecture, deployment, API reference, security + threat model, developer onboarding, demo video script

Tech stack

Layer Choice
Language (backend) Python 3.11
Backend framework FastAPI
Web (marketing + dashboard) Next.js 16 (App Router, Turbopack) + Tailwind v4 + shadcn/ui
Auth Argon2id + opaque server-side sessions; invite-only staff access (owner-issued invites)
Vision Qwen-VL-Max
Reasoning Qwen-Max
Embeddings Qwen text-embedding-v3 (1024-dim)
Vector DB Alibaba DashVector (primary), Chroma local for dev
Relational Neon Postgres (serverless, ap-southeast-1) in production; SQLite in dev
File storage Claim photos in Postgres (claim_photos); Alibaba OSS as optional archive
Email Resend (verified domain) with branded HTML templates + claim-PDF attachments
Farmer channels Telegram Bot API, Twilio Programmable Messaging, Bird Conversations
Weather Open-Meteo historical archive
PDF WeasyPrint
Identity verification Provider abstraction (Persona / Veriff / Onfido)
Payments Provider abstraction (Paddle / LemonSqueezy / Razorpay) — disabled by default
Deployment Alibaba Function Compute 3.0 (backend) + Vercel (web)

Local setup

git clone https://github.com/hemnaath04/claimfarm.git
cd claimfarm
cp .env.example .env       # fill QWEN_API_KEY at minimum
uv sync

# Terminal 1: FastAPI
uv run uvicorn app.main:app --port 8000 --reload

# Terminal 2: Streamlit fallback (optional)
uv run streamlit run dashboard/main.py

# Terminal 3: Next.js dashboard
cd web && pnpm install && pnpm dev

Or with Docker Compose:

docker compose up --build
# api at http://localhost:8000  ·  web at http://localhost:3000

Repo layout

claimfarm/
├── app/                        # FastAPI orchestrator
│   ├── agents/                 # damage_assessor, weather_corroborator,
│   │                           # photo_forensics, past_claim_rag, agronomy_rag,
│   │                           # fraud_check, multilingual, claim_drafter,
│   │                           # whatsapp_intake (channel-agnostic)
│   ├── auth/                   # passwords, sessions, one-time tokens, routes
│   ├── clients/                # qwen, weather, vector_store, embeddings,
│   │                           # alibaba_oss, insurer, twilio_client, bird_client,
│   │                           # telegram_client, identity_verification,
│   │                           # perceptual_hash, notifications, payments
│   ├── models/                 # pydantic schemas (damage, weather, claim,
│   │                           # forensics, user)
│   ├── storage/                # SQLModel repos: claims, users, farmer_profiles,
│   │                           # audit_log
│   ├── api_admin.py            # admin API (user search/suspend/role/audit)
│   ├── api_billing.py          # payments checkout + webhook
│   ├── api_claims.py           # adjuster console API
│   ├── api_identity.py         # KYC session + result
│   ├── main.py                 # FastAPI app composition
│   └── middlewares.py          # rate limiting + security headers
├── mock_insurer/               # Stand-in insurer carrier (mounted at /insurer)
├── dashboard/                  # Streamlit fallback (mature, retained)
├── web/                        # Next.js 16 marketing + admin + dashboard
│   ├── src/app/                #   /, /pricing, /about, /faq, /blog, /contact,
│   │                           #   /farmer, /legal/*, /auth/*, /admin, /dashboard
│   ├── src/components/         # marketing + shadcn UI primitives
│   └── src/lib/api.ts          # typed client for the FastAPI JSON API
├── scripts/                    # seed_agronomy_kb, seed_demo_claim, reindex_claims,
│                               # test_damage, test_weather, test_claim_pdf,
│                               # test_rag, test_multilingual, test_forensics
├── deploy/                     # Function Compute config + env template
├── docs/                       # architecture, deployment, api, security,
│                               # onboarding, demo-video-script
├── data/                       # demo_seed.json (3 canned claims for FC cold start)
├── Dockerfile                  # python:3.11-slim + pango/cairo + uvicorn
├── docker-compose.yml          # full stack for local dev
└── .github/workflows/          # docker-build.yml (image), ci.yml (lint + test)

Hackathon submission artifacts

License

MIT

About

AI agent that turns a smallholder farmer's WhatsApp photo into a filed crop insurance claim — Qwen Cloud hackathon Track 4 submission

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages