Inspiration

Nigeria's agricultural sector employs over 35% of the workforce, yet farmers consistently struggle to access institutional investment and loans. The problem isn't productivity — Nigerian farmers grow billions in crops every year. The problem is trust. When a smallholder farmer walks into a bank, they have receipts, photos on a phone, and word of mouth. None of it is verifiable. None of it is structured. Investors can't evaluate what they can't see.

I built Grains to change that.

What it does

Grains is an agricultural intelligence and transparency platform built specifically for Nigerian farmers and investors.

For farmers: Register your farm with GPS-verified coordinates, log every planting, fertilizer application, inspection, and harvest as a structured, timestamped activity. Your farm builds a credibility profile automatically — a portable, verifiable record that follows you to every loan application and investor conversation.

For investors: Browse verified farms filtered by region, crop type, and risk level. View real-time predictions, live weather data, transparency scores, and full activity histories. Save farms to a watchlist and monitor them over time.

For administrators: Review and approve farms through a verification queue, monitor platform-wide agricultural analytics by region and crop type, and maintain data integrity across the system.

How I built it

I used MeDo to build the entire full-stack application through natural language conversations — describing features, iterating on UI, fixing bugs, and deploying — without writing code manually.

The technical stack that MeDo generated and assembled:

  • Frontend: React + TypeScript with Tailwind CSS and shadcn/ui components
  • Backend: Supabase (PostgreSQL with Row Level Security, Auth, Storage, Edge Functions)
  • ML Prediction Engine: XGBoost models trained on real Nigerian agricultural data, deployed on Railway via Docker, served through a FastAPI endpoint
  • External APIs: OpenWeather API (live weather + AI overview), NASA POWER API (historical climate data), iSDA Africa API (soil chemistry by GPS coordinate)
  • Training Data: FAOSTAT crop yield statistics (2010–2023), NASA POWER daily weather data for all 37 Nigerian states/FCT (2019–2024), iSDA Africa soil profiles (pH, nitrogen, clay content, carbon, phosphorus, potassium)

The ML engine predicts yield in kg, drought risk score (0–100), crop health score (0–100), and prediction confidence — all based on real farm inputs. When a farmer captures their GPS coordinates, the platform silently enriches their farm record with real soil chemistry from iSDA and historical climate data from NASA POWER — no farmer input required.

Challenges I ran into

The trust gap in the data: Nigerian smallholder farms are rarely in any dataset. I had no actual farm-level yield records to train on. The solution was to build a synthetic training dataset grounded in real scientific priors — FAOSTAT yield ranges per crop, NASA POWER regional weather profiles, and iSDA soil measurements — then generate 2,000 realistic farm rows from those distributions. The model's R² of 0.937 for yield prediction suggests the approach worked.

CORS and the browser-to-Railway gap: The ML API on Railway couldn't be called directly from the browser due to cross-origin restrictions. The fix was routing the call through a Supabase Edge Function — a server-to-server call that bypasses CORS entirely while keeping the API response seamless.

Designing for farmers, not developers: Every form field, every label, every question had to be written in plain language a Nigerian smallholder farmer would understand. "Irrigation method" became "How does your farm get water?" The constraint made everything better.

Accomplishments that I am proud of

The ML prediction engine is the thing I'm most proud of. Training a real XGBoost model on Nigerian agricultural data — pulling soil chemistry from iSDA Africa, climate data from NASA POWER, and crop yield statistics from FAOSTAT — and getting it to produce predictions with an R² of 0.937 for yield forecasting is a genuine technical result. It's not a simulation. It responds correctly to soil quality, irrigation method, regional climate differences between northern and southern Nigeria, and farming practices. That took real work.

I'm also proud of the automatic farm enrichment system. The moment a farmer captures their GPS coordinates, the platform silently calls two external APIs in the background — fetching real soil pH, nitrogen levels, clay content, phosphorus, and potassium for that exact location from iSDA Africa, and pulling historical rainfall and temperature averages from NASA POWER. The farmer taps one button and their farm record is enriched with scientific data they would never have access to otherwise. That feels like genuine value.

Building a full-stack platform — database schema, authentication, role-based access control, Edge Functions, ML pipeline, external API integrations, and a complete multi-role UI — entirely through natural language conversations with MeDo, and having it actually work in production, is something I didn't think was possible six weeks ago.

What I learned

MeDo's ability to hold architectural context across a complex multi-layer system — database schema, RLS policies, Edge Functions, React components, TypeScript types — is genuinely impressive. The most valuable skill was learning to write prompts that are specific enough to be unambiguous but flexible enough to let MeDo make good decisions. Precision in language produces precision in code.

I also learned that synthetic training data, when grounded in real scientific sources, can produce models that behave meaningfully — even without historical actuals. The v2_xgboost engine produces predictions that respond correctly to soil quality, irrigation method, regional climate, and farming practices. That's a real result, not a simulation.

What's next for Grains

Real blockchain verification. The current system generates verification records with transaction hashes stored in a database. The next version will anchor those hashes to an actual blockchain — a lightweight proof-of-existence protocol where each activity verification is cryptographically linked to the previous one. This makes the audit trail genuinely tamper-evident, not just database-backed.

Fractional farm investment. The long-term vision for Grains is removing the bank from the equation entirely. Investors on the platform will be able to fund farms directly — contributing fractional amounts to specific farms they've vetted through the intelligence dashboard. A farmer needing ₦500,000 for a planting season could receive it from 10 investors contributing ₦50,000 each, with returns tied to verified harvest outcomes. The credibility score, activity history, yield predictions, and transparency metrics that Grains already generates are exactly the data layer this kind of investment requires to work safely. The infrastructure is already being built — the investment layer sits on top of it.

Model retraining on real farmer data. The current XGBoost models were trained on synthetic data grounded in real scientific priors. As farmers log actual harvests and record actual yields, those records become ground truth. The plan is to retrain the models quarterly as real Nigerian farm-level yield data accumulates — progressively replacing synthetic priors with observed actuals.

Satellite imagery integration. NDVI (Normalized Difference Vegetation Index) data from Sentinel-2 will be pulled automatically for every registered farm. This enables two things: independent verification that crops are actually growing at the declared location, and a continuous crop health signal that doesn't depend on the farmer logging activities.

Agricultural credit scoring. The credibility and transparency scores are already structured to support lending decisions. The next step is formalizing a credit scoring model that banks and microfinance institutions can use directly — turning a farmer's Grains profile into a portable creditworthiness record.

Built With

Share this project:

Updates

Submission history