MedFind — AI-assisted pharmacy finder for Ethiopia that learns which pharmacy actually has your medicine, using a self-trained Bayesian/Thompson Sampling engine on crowdsourced outcomes (no inventory API needed). Claude API used only for NLU and reply phrasing, never for recommendations.
# Medfind
Medicine finding for Ethiopia.
## Project structure
Single Next.js app (App Router). See the Master Build Blueprint for phase ownership and shared contracts.
```
/app → Next.js app router pages
/ → landing / consent
/chat → Phase 1 chat UI
/medications → Phase 2 companion UI
/pharmacy → Phase 3 SaaS dashboard (separate auth)
/app/api → Next.js API routes
/lib
/matching → embedding + cosine similarity (Phase 1)
/reliability → Thompson Sampling engine (Phase 1)
/parsing → instruction extraction (Phase 2)
/integrations → Gemini, Addis AI, ElevenLabs, Telebirr
/db → Supabase client + query helpers
types.ts → shared API + DB types (Section 0.3)
/scripts
seed.ts → DB seeding
/seed-data → curated CSV/JSON sources
/supabase
/migrations → numbered SQL migrations
```
## Day-0 setup
1. `npm install`
2. Copy `.env.example` → `.env.local` and fill credentials (optional for UI mocks).
3. `npm run dev` — consent → chat works against local mocks by default (`NEXT_PUBLIC_USE_MOCKS` defaults on).
4. Shared types live in `lib/types.ts` — do not duplicate shapes elsewhere.
5. Work on `feature/*` branches; PR into `dev`, never push directly to `dev` or `main`.
## Frontend (Phase 1)
- `/` — consent screen, then chat shell
- Consent calls real `POST /api/session` (2t); stores anonymous `userId` + `sessionToken` in localStorage (and a SameSite cookie)
- `/api/query` still mockable via `NEXT_PUBLIC_USE_MOCKS` until 3t lands
- Brand UI tokens: green ink `#0b6e4f`, warm cream neutrals
## Local environment parity (Section 0.6)
| Decision | Choice | Where it is pinned |
| --------------- | ---------------------- | ------------------------- …