Find medications in pharmacies near you. Built for developing countries where drug shortages are a daily problem.
- Patients: Search for medications and find nearby pharmacies that have them in stock
- Pharmacies: Report their medication inventory for free, get patients directed to them
- WhatsApp: Search medications via WhatsApp (the dominant channel in developing countries)
- Alerts: Get notified when a medication becomes available
| Component | Technology |
|---|---|
| Backend | FastAPI (Python) |
| Database | Supabase (PostgreSQL) |
| Frontend | Vanilla JS + Leaflet maps |
| Hosting | Render.com (free tier) |
| Twilio / manual |
git clone https://github.com/storbaz/MedStock.git
cd MedStock
cp .env.example backend/.env- Go to supabase.com and create a free project
- Run the SQL migrations (see below)
- Copy your URL and keys to
backend/.env
Run this in the Supabase SQL editor:
-- Medicines table
CREATE TABLE medicines (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL,
generic_name TEXT,
active_ingredient TEXT,
category TEXT,
country TEXT DEFAULT 'CO',
image_url TEXT,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Pharmacies table
CREATE TABLE pharmacies (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL,
address TEXT NOT NULL,
city TEXT NOT NULL,
country TEXT DEFAULT 'CO',
latitude FLOAT,
longitude FLOAT,
phone TEXT,
whatsapp TEXT,
email TEXT,
owner_name TEXT,
is_verified BOOLEAN DEFAULT FALSE,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMPTZ DEFAULT NOW(),
last_stock_update TIMESTAMPTZ
);
-- Stock table
CREATE TABLE stock (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
medicine_id UUID REFERENCES medicines(id) ON DELETE CASCADE,
pharmacy_id UUID REFERENCES pharmacies(id) ON DELETE CASCADE,
level TEXT CHECK (level IN ('available', 'low', 'out_of_stock')),
price FLOAT,
quantity_approx INTEGER,
notes TEXT,
last_verified TIMESTAMPTZ,
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(medicine_id, pharmacy_id)
);
-- Indexes
CREATE INDEX idx_medicines_name ON medicines USING gin(name gin_trgm_ops);
CREATE INDEX idx_medicines_generic ON medicines USING gin(generic_name gin_trgm_ops);
CREATE INDEX idx_pharmacies_city ON pharmacies(city);
CREATE INDEX idx_pharmacies_country ON pharmacies(country);
CREATE INDEX idx_stock_medicine ON stock(medicine_id);
CREATE INDEX idx_stock_pharmacy ON stock(pharmacy_id);
CREATE INDEX idx_stock_level ON stock(level);
-- Enable trigram for fuzzy search
CREATE EXTENSION IF NOT EXISTS pg_trgm;cd backend
pip install -r requirements.txt
uvicorn main:app --reloadPush to GitHub and connect to Render.com. It will auto-deploy using render.yaml.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/medicines/search?q=paracetamol |
Search medications |
| GET | /api/medicines/{id}/availability |
Get pharmacy availability |
| POST | /api/medicines |
Create medication |
| GET | /api/pharmacies |
List pharmacies |
| POST | /api/pharmacies |
Register pharmacy |
| GET | /api/stock/by-pharmacy/{id} |
Get pharmacy stock |
| POST | /api/stock |
Report stock |
| POST | /api/stock/bulk |
Report stock (multiple) |
| GET | /api/health |
Health check |
| GET | /api/stats |
Platform stats |
MedStock/
├── backend/ # FastAPI application
│ ├── main.py # App entry point
│ ├── config.py # Environment settings
│ ├── database.py # Supabase connection
│ ├── models/ # Pydantic models
│ ├── routers/ # API endpoints
│ └── services/ # Business logic
├── frontend/ # Static frontend
│ ├── index.html # Landing page (patient)
│ ├── farmacia/ # Pharmacy panel
│ ├── css/ # Styles
│ └── js/ # Client-side logic
├── whatsapp/ # WhatsApp bot
├── scripts/ # Scraping tools
└── docs/ # Documentation
- Fork the repo
- Create a feature branch
- Make your changes
- Submit a PR
MIT