Inspiration
Meet Meena. She delivers food for a living, and on a good day she takes home about ₹800. That money pays her share of the rent, her groceries, and her phone EMI.
Then one day it rains so hard that her area floods. She can't ride, orders dry up, and she earns nothing. Her bills don't care. Insurance would ask for forms, proof of loss, and weeks of waiting, and it is rarely built for someone earning ₹800 a day. Her platform offers nothing either. So she borrows, and one bad day becomes a debt.
We kept asking one question: why should she have to prove a storm happened, when the sky already did?
That led us to parametric cover, an idea from catastrophe insurance. Instead of judging each person's claim, you agree on a measurable line in advance, like a certain amount of rainfall, and pay everyone covered once the line is crossed. We combined that idea with AI and PayPal's programmable payouts to make it simple to join and instant to receive.
What it does
RAIN CHECK is a community protection pool for gig workers. When bad weather hits, members are paid automatically, with no claim form and no adjuster.
- Describe. A worker types one sentence: "If 50 mm of rain falls in 24h, pay me ₹500, up to 3 days a month."
- Bound. AI proposes a structured policy, then our code clamps every value to hard limits: 5 to 300 mm, ₹50 to ₹2,000, one payout per day, 1 to 3 days per month, and a 24 to 168 hour waiting period. The model cannot widen these limits.
- Screen. Duplicate payout addresses, shared devices, signup bursts, and unverified accounts are flagged before activation and again at payout time.
- Trigger. Open-Meteo's 24-hour rainfall is turned into a standard event. A unique event key makes the run idempotent, so replaying a storm pays nobody twice.
- Decide. A deterministic rule engine returns
APPROVE,DENY, orHOLD_FOR_REVIEW, each with one reason code. - Pay. Approved payouts go to PayPal Payouts in a batch. The pool is spent payout-box first, then reserve, and can never go negative.
- Explain. Every payout produces a plain-language receipt and an audit log entry.
The one rule we never break: AI recommends and explains. Deterministic code authorizes money movement. The AI can never move money, and our tests check that boundary instead of just claiming it.
How we built it
PayPal (sandbox):
- Orders API (Checkout) lets members fund the shared pool.
- Payouts API sends money to workers, with unique
sender_batch_idandsender_item_idvalues so retries can never pay twice. PayPal Payouts doesn't support INR, so we send USD at a configurable demo rate and show both amounts. - Webhooks with signature verification confirm what actually happened before we update any status.
AI: [AI model name, e.g. gpt-4o-mini] through an OpenAI-compatible API, with three jobs: the policy parser, an advisory risk review, and receipt translation. A numeric guard rejects any translation that changes a number. With no API key, a deterministic parser takes over and every response says whether it came from the model or from rules.
Backend: FastAPI, SQLAlchemy 2, and SQLite. Money is stored as whole paise to avoid rounding bugs.
Frontend: React 18, Vite, and TypeScript, with an AG Grid live payout ledger and a mobile card-list fallback.
Data: Open-Meteo rainfall, plus a clearly labelled Simulate storm button that runs through the exact same pipeline, so the demo never depends on real weather.
Sponsor tools: AG Grid (payout ledger), Postman (a 25-request, 84-assertion Newman collection), and Render (a single Docker image on the free plan).
The money model. Each month, \( N \) members each pay \( c \), and PayPal takes a fee rate \( f_{in} \). The pool receives:
$$P = N \cdot c \cdot (1 - f_{in})$$
A storm costs:
$$C_{event} = n_{hit} \cdot a \cdot d \cdot (1 + f_{out})$$
where \( n_{hit} \) is the number of affected members, \( a \) is the payout per day, and \( d \) is the number of days. Payouts come from the payout box first, then the reserve. If both run low, the rules deny or hold instead of promising money that isn't there. (The fee rates in our examples are illustrative assumptions, not PayPal's real pricing.)
Fraud defences:
- A waiting period, so nobody joins just before a storm they already know is coming.
- One payout address per account, plus device and signup-velocity checks.
- Caps per person and per day, and a pool balance check before every payout.
- Fail-closed weather data: if the feed is down, nothing is paid.
- Idempotent events and verified webhooks against replays and spoofing.
- A pause switch and a permanent audit log.
Challenges we ran into
- Keeping AI away from the money. A cleverly written sentence must never produce a generous rule, so the hard bounds live in code, not in the prompt.
- Preventing double payments. Retries, duplicate events, and repeated webhooks all threaten this. Unique event keys and idempotent payout batches solved it.
- A demo that never fails. Real weather is unpredictable, so we built a labelled simulator that uses the same pipeline as live data.
- PayPal limits. Payouts don't support INR, so we convert to USD at a configurable rate.
- Basis risk. Open-Meteo's grid cell may stay below the threshold while a worker's street floods, or pay when her street stayed dry. No simple trigger is perfect, so we disclose this in the app and docs.
- Teamwork. We are six people, two of them beginners, with under four weeks to build. Agreeing early on one policy schema and API contract let everyone work in parallel on separate branches.
Accomplishments that we're proud of
- A complete flow that works from start to finish: describe, fund, trigger, decide, pay, receipt, and audit.
- Safety you can see: caps, idempotency, a pause switch, and fraud flags all appear in the demo.
- Real test evidence: 140 passing tests, 30 of 30 labelled parser sentences, and a Newman run of 25 requests with 84 assertions and 0 failures, plus a clean secret scan.
- A seeded demo pool of 10,000 members across six zones, including a simulated fraud ring.
- [Add a real measured result, e.g. "payouts reached the ledger about X seconds after the trigger".]
What we learned
- A fresh idea often comes from the mechanism, not the industry. Borrowing the parametric idea from insurance changed our whole product.
- AI is most trustworthy when it handles structure and explanation, while plain code makes the decisions that matter.
- Idempotency keys, verified webhooks, and audit logs aren't extras. They are what make automatic payments safe.
- Being honest about limits makes a project stronger, not weaker.
What's next for RAIN CHECK
- More triggers on the same engine: heat, floods, earthquakes, and flight delays.
- Better data: quality-controlled observations (such as IMD data), multiple gauges, and a data provider with an SLA instead of a forecast feed.
- Partnerships with gig platforms, cooperatives, and NGOs to run real pools, including worker-payout products like Hyperwallet for wider reach.
- Smarter pricing: contributions and reserves set from real historical weather data.
- Production readiness: KYC and sanctions screening, legal and regulatory review, and a licensed partner before any real-money launch.
RAIN CHECK is a sandbox prototype of a community protection pool, not a licensed insurance product. Parametric insurance already exists for larger customers. What we built is a conversational, AI-assisted, small-payout version on PayPal, designed for people like Meena.
Built with: PayPal Orders API, PayPal Payouts API, PayPal Webhooks, [AI model], FastAPI, SQLAlchemy, SQLite, React, TypeScript, Vite, AG Grid, Postman, Newman, Render, Docker, Open-Meteo, pytest
Built With
- ag-grid
- ai
- docker
- fastapi
- llm
- newman
- open-meteo
- openai-compatible-api
- paypal
- paypal-orders
- paypal-payouts
- paypal-webhooks
- postman
- pytest
- python
- react
- render
- rest-api
- sqlalchemy
- sqlite
- typescript
- vite