Inspiration

Food aid often travels thousands of kilometres. A dollar given to feed families in northern Kenya can end up buying imported rice shipped through Mombasa, while farmers a few hundred kilometres away have sorghum, cowpeas and maize to sell. Donors rarely see what their money bought, who was paid, or whether anything arrived.

I wanted a donation that does two good things at once: feed people who need food, and put cash in the hands of the farmers closest to them. I also wanted every step to be visible.

What it does

Plantago turns a PayPal donation into food grown or bought as close as possible to the people who need it.

  1. Give. A donor picks a place in northern Kenya on a map, such as Lodwar in Turkana, where need is at emergency level. They can search for any town, grower or country. They choose what to send from a plant catalog (food now, drought-tolerant seed to plant, or tools like storage bags and drip kits) or let the AI planner choose. Then they pay with PayPal Checkout.
  2. Plan. An AI planner searches the network of growers and compares buying ready food now with sending seed to plant for the coming rains, and local growers with imported rice. It explains its choice in plain words. In my demo, a $50 donation became 409 meals now, 2.14× what imported rice would buy, plus about 691 meals expected at harvest.
  3. Pay farmers. PayPal Payouts pays each grower in the plan directly, in batches, as soon as the plan is approved rather than months later on delivery.
  4. Deliver. A dispatch planner groups shipments into truck runs along real Kenyan highways and recommends a dedicated truck or part loads on scheduled lorries, whichever costs less.
  5. See it land. The donor's page shows every step ticked: paid with PayPal, plan ready, growers paid, food delivered. It also shows the PayPal transaction IDs. A public ledger lists every dollar in and every dollar out.

It also closes the loop for farmers:

  • Harvest buy-back. Families who receive seed get a promise that Plantago buys 30% of their harvest at a fair price, so a donation becomes seed, then income, then food grown locally.
  • Farmer shop. Farmers can spend their own earnings on tools and seed through PayPal checkout, with no fee added.

Payments in the demo are real PayPal sandbox transactions. Growers are fictional (their towns are real), and deliveries are simulated.

How I built it

  • Stack: TypeScript end to end. Express and SQLite on the server; React on the front end.
  • Sponsor tool: AG Grid for the operator console and the public ledger.
  • Maps: Leaflet with Natural Earth country shapes for the 2D maps, and react-globe.gl for a 3D globe of the whole network.
  • PayPal:
    • Orders v2 with the JS SDK buttons for donations.
    • Payouts (create and track batches) to pay growers.
    • Payments refunds for donations that can't be fulfilled.
    • Webhooks with signature verification to confirm payments and payout status.
  • AI planner: DeepSeek (deepseek-flash) through the OpenAI SDK, running a tool loop: read the destination's profile, list food-now options, list grow-there options, cost an allocation, submit a plan. The AI chooses, the code does the maths. The budget is fixed on the server, every tool argument is validated, and the model can only submit an allocation the optimizer has priced. If the AI is unavailable, a rule-based planner uses the same optimizer.
  • Roads and dispatch:
    • A graph of about 60 towns, border posts and the Mombasa port, with Dijkstra shortest paths by driving time. These road distances drive every price, delivery estimate and map line.
    • Dispatch clusters drop-offs, packs 3-tonne trucks, orders the stops with nearest-neighbour plus 2-opt, and compares truck and part-load costs.
  • Money safety:
    • All amounts are integer cents.
    • Every PayPal call that moves money carries an idempotency key.
    • Orders are claimed inside a database transaction before a payout is sent, so nobody is paid twice.
    • The ledger must balance (received − refunded − paid out = held), and the tests check it.
  • Hosting: Render.

Challenges I ran into

  • Keeping the AI away from the money. Language models are good at weighing options and explaining a choice, and unreliable at arithmetic. I split the work: the AI picks a strategy and writes the explanation, and deterministic code computes every kilogram, cent and meal.
  • Paying twice is worse than not paying. Retries, double clicks and duplicate webhooks can all cause double payments. I used PayPal's request IDs, used my own batch IDs as sender_batch_id, and claimed orders in one transaction before calling PayPal.
  • Real payouts don't finish instantly. Sandbox payouts come back PENDING or UNCLAIMED, so the server keeps checking open batches with PayPal until every item reaches its final status.
  • Making distance honest. Straight-line distance made far-away growers look cheap. Routing on a real road graph, with rough roads slower and dearer, border fees and sea freight via Mombasa, changed which growers win.
  • Front-end performance. The PayPal button reloaded on every keystroke in the donor's note. Animated "on the road" routes made the map lag when zoomed in. I fixed both: the button reads the form through a ref, and moving routes draw in their own layer.

Accomplishments that I'm proud of

  • The whole loop works end to end on a live site: a donor's click, a PayPal capture, an AI plan, PayPal Payouts to growers, dispatch, delivery and a public ledger. Every step has real sandbox transaction IDs.
  • Real impact numbers. In my recorded demo, a $50 donation fed 2.14 times as many people as imported rice would have, and the money went to Kenyan and East African growers instead of a distant supplier.
  • Explainable AI. Every plan says what it buys, from whom, how far away, and why it beat the alternatives.
  • Farmers are paid when the plan is approved, not on delivery. The ledger shows the time from a donor's payment to a supplier's cash.
  • Built solo, from idea to live site and demo video, within the hackathon.

What I learned

  • Transport often decides who should supply food. Being close beats being cheap per kilo surprisingly often.
  • An AI planner is most trustworthy when it can only choose between options the code has already priced.
  • A payout is a process, not a single API call: pending, unclaimed, succeeded, returned. A trustworthy ledger has to follow each one to the end.
  • Transparency is a feature. The public ledger and plain-language plans answer most trust questions before anyone asks them.

What's next for Plantago

  • Real growers and partners. Onboard farmer co-ops with PayPal sign-in, and work with local logistics partners and community kitchens to make real deliveries.
  • Cash straight to phones. Send payouts to farmer groups' members through mobile wallets (Xoom to M-Pesa).
  • Monthly giving with PayPal Subscriptions, so a destination gets steady support through each season.
  • Live data. Use market prices and need levels from public sources such as FAO, WFP and FEWS NET instead of seeded estimates.
  • More regions. The network already includes suppliers in Uganda, Tanzania, India and South Africa. The next step is destinations beyond northern Kenya, with seed import certification (KEPHIS) handled properly.

Built With

Share this project:

Updates

Submission history