A medication-adherence + micro-pharmacy marketplace platform that solves medication inequity for low-income patients in Kenya
# Project Overview
PilBuddy is a medication-adherence + micro-pharmacy marketplace platform that solves medication inequity for low-income patients in Kenya (and eventually East Africa).
Patients get free/discounted pills through verified partners (chemists/pharmacies, NGOs, hospitals, corporate CSR programs).
They track adherence, earn “Adherent Points” (gamified currency), unlock discounts, refill prescriptions, and participate in a supportive community chat where they can gift points and motivate each other.
# PilBuddy Backend
This repository contains the **Node.js + Express backend** (Phase 1 – core API).
## Current Status (MVP Backend – as of March 2026)
### Implemented Features
#### Authentication & Users
- Register / login (phone-based, JWT)
- Role system: `patient`, `partner`, `ngo`, `admin`
- JWT middleware + role guard
#### Adherence & Gamification
- Daily check-in endpoint (`/api/adherence/check-in`)
- Points awarded: base 20 + streak bonus
- Streak tracking, last check-in date, history
- Get adherence status (`/api/adherence/status`)
#### Refill Flow
- Create refill request (`POST /api/refill`)
- List my refills (`GET /api/refill/my`) – patient or partner view
- Accept request (`PATCH /api/refill/:id/accept`)
- Manual fulfill for testing (`PATCH /api/refill/:id/manual-fulfill`)
- Get single refill detail (`GET /api/refill/:id`) with role-based access
#### Payments (PayHero integration)
- Initiate STK Push to partner phone (`POST /api/payments/initiate`)
- Webhook handler (`POST /api/payments/webhook`)
- Internal 10/10/10 fee split logic on success
- Transaction logging (platform/team/community)
#### Points & Discounts
- Redemption tiers (500 → 10%, 1000 → 20%, 2000 → 50%)
- Redeem points → create voucher (`POST /api/points/redeem`)
- List redemption options (`GET /api/points/tiers`)
- List patient's vouchers (`GET /api/vouchers`) – active / used / expired
- Get voucher by code (`GET /api/vouchers/:code`)
#### Partner Inventory Management
- Add …