Digital Kilimo Hub — Tanzania agricultural digital ecosystem (Node 20 + Express + PostgreSQL)
# 🌾 Digital Kilimo Hub
Tanzania agricultural digital ecosystem — Node.js 20 + Express + PostgreSQL API,
serving a farmer-facing web app from the same service.
## What's here
```
kilimo-hub-node/
├── src/
│ ├── server.js ← entry point (npm start)
│ ├── db/
│ │ ├── schema.sql ← full schema, auto-applied on every boot
│ │ └── pool.js ← Postgres connection pool
│ ├── middleware/auth.js ← JWT verification + role guards
│ ├── utils/ ← phone/password validation, user serialization
│ └── routes/
│ ├── auth.js ← register / login / me / logout
│ ├── users.js ← profile, password change, admin user management
│ ├── groups.js ← Social Collective Buying
│ ├── logistics.js ← Dynamic Logistics Link (backhaul matching)
│ ├── markets.js ← Agri-Intelligence: live crop prices
│ ├── loans.js ← Credit Scoring Engine
│ ├── alerts.js ← Agri-Intelligence: pest/weather/market alerts
│ └── admin.js ← dashboard stats, user/transaction summaries
└── public/
├── index.html ← marketing site (CTAs link to the farmer app)
├── app.html ← farmer-facing app (wired to the API above)
└── admin.html ← admin dashboard (wired to the API above)
```
Not yet in this repo: driver- and business-buyer-facing UI (the backend supports
those roles and a `/products` marketplace, but no frontend was uploaded for
them — only the farmer app and admin panel had mockups to wire up), and real
mobile-money integration (see Security notes below).
## Local setup
```bash
npm install
cp .env.example .env # then fill in DATABASE_URL, SECRET_KEY, etc.
npm start
```
Visit `
localhost` to confirm it's running, and
`
localhost` for the farmer app. The schema is created
automatically on boot — there's no separate migration step.
## Deploying on Render
1. Push this repo to GitHub.
2. On Rende …