AI-assisted alternative credit scoring for smallholder farmers in Nigeria, built for the Google Solution Challenge 2026. React, TypeScript, Vite, Firebase.
# FarmCredit AI
AI-assisted alternative credit scoring for smallholder farmers in Nigeria — built for the Google Solution Challenge 2026.
## What it does
Farmers sign up with their phone number, fill in a short farm profile (farm size, crop type, location, years of experience), and instantly get a **FarmCredit Score (300-850)** plus a pre-approved loan amount — no collateral or bank history needed.
## Tech stack
- **React + TypeScript + Vite**
- **Firebase Authentication** (phone OTP)
- **Cloud Firestore** (farmer profiles, loan records)
- Custom rule-based credit scoring engine (`src/lib/scoring.ts`) — transparent and explainable, designed as a starting point for a future ML model
## Running locally
```bash
npm install
npm run dev
```
The app runs in **demo mode** by default (no Firebase config needed): OTP accepts any 6-digit code, and data is stored in `localStorage`. To enable real Firebase Auth + Firestore, fill in your config in `src/lib/firebase.ts`.
## Environment variables
Copy `.env.example` to `.env` and fill in:
| Variable | Where it's used | Notes |
|---|---|---|
| `API_NINJAS_KEY` | `api/commodity.js` (server-side only) | **Not** prefixed with `VITE_` — it must never ship in client JS. Free key at api-ninjas.com. Their free tier is non-commercial use only. |
| `ALLOWED_ORIGINS` | `api/commodity.js` | Optional. Comma-separated extra CORS origins (e.g. a custom domain). Your Vercel deployment URL is allowed automatically. |
| `VITE_USD_TO_NGN` | `src/lib/commodities.ts` (client-side) | Display-only conversion rate, safe to expose. |
On Vercel: **Project Settings → Environment Variables**, add `API_NINJAS_KEY` there (not in `.env` committed to git — `.env` is gitignored already).
If the Market screen shows "Live prices are unavailable," check the function logs (`vercel logs` or the Vercel dashboard → your deployment → Functions → `/api/commodity`) — the handler logs a structured JSON reason (missing key, CORS block, upstream error/timeout) fo …