# Kenya Citizen Pulse — API
Backend for the Kenya Citizen Pulse mobile app: an anonymous civic-sentiment
platform. Built with **Express + MongoDB (Mongoose)**.
## Setup
```bash
npm install
cp .env.example .env # then fill in MONGO_URI and JWT_SECRET
npm run seed # loads sample data matching the app mockups
npm run dev # starts on
localhost
```
You'll need a MongoDB connection string — the fastest path is a free
MongoDB Atlas cluster.
## Auth model
There are no user accounts, passwords, or personal data. On first launch,
the app calls `POST /api/users/register-anon`, which creates a random
`anonId` and returns a long-lived JWT. The app stores that token locally
(e.g. SecureStore / Keychain) and sends it as `Authorization: Bearer `
on any write request. This is what lets us track streaks and achievements
without identifying anyone.
## Endpoints
| Screen | Method & Path | Notes |
|---|---|---|
| Home Dashboard | `GET /api/home/summary` | Kenya Mood Index, trending, AI daily summary |
| Home Dashboard | `GET /api/questions/today` | Today's question + category options |
| Home Dashboard | `POST /api/responses` 🔒 | "Submit My Voice" — updates streak/achievements |
| Home Dashboard | `GET /api/counties` | All counties for the mood map |
| County View | `GET /api/counties/:name` | Mood score, top issues, trend, sub-county breakdown |
| Community Insights | `GET /api/community?scope=all\|county&county=X` | Paginated feed |
| Community Insights | `POST /api/community` 🔒 | "Share an Insight" |
| Community Insights | `POST /api/community/:id/agree` 🔒 | Heart / agree action |
| My Contribution | `GET /api/users/me/contribution` 🔒 | Today's status, streak, achievements |
| Onboarding | `POST /api/users/register-anon` | First-launch anonymous identity |
| Onboarding | `PATCH /api/users/me/county` 🔒 | Set home county |
🔒 = requires `Authorization: Bearer `
## Project structure
```
config/ MongoDB connection
models/ …