Skip to content
storbazPublic

About

Find medications in pharmacies near you - built for developing countries

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

MedStock

Find medications in pharmacies near you. Built for developing countries where drug shortages are a daily problem.

What it does

  • 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

Stack (100% free)

Component Technology
Backend FastAPI (Python)
Database Supabase (PostgreSQL)
Frontend Vanilla JS + Leaflet maps
Hosting Render.com (free tier)
WhatsApp Twilio / manual

Quick Start

1. Clone and setup

git clone https://github.com/storbaz/MedStock.git
cd MedStock
cp .env.example backend/.env

2. Create Supabase project

  1. Go to supabase.com and create a free project
  2. Run the SQL migrations (see below)
  3. Copy your URL and keys to backend/.env

3. Database schema

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;

4. Run locally

cd backend
pip install -r requirements.txt
uvicorn main:app --reload

Open http://localhost:8000

5. Deploy to Render

Push to GitHub and connect to Render.com. It will auto-deploy using render.yaml.

API Endpoints

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

Project Structure

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

Contributing

  1. Fork the repo
  2. Create a feature branch
  3. Make your changes
  4. Submit a PR

License

MIT

About

Find medications in pharmacies near you - built for developing countries

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages