Hey hackers! I’m Abdoul-Hafiz. Today, I want to tell you about PharmaX, a project I developed for my Master's thesis in AI & Big Data—but mostly because it was a genuine engineering challenge.
The idea is simple: in Lomé, finding an on-duty pharmacy at 2 AM when a loved one is sick is a nightmare. Information is scattered across PDFs or random Facebook posts. So, we built a conversational agent that finds the nearest open pharmacy and guides you there.
Here is how I hacked it from A to Z, what made me proudest, and what I learned along the way.
My Contribution: Pure "Frugal" Full-Stack I didn't touch hardware; I built everything in pure software under a major constraint: no heavy servers, no GPUs, and sometimes flaky internet connections. I built the entire stack end-to-end:
Backend & API (Flask + SQLite): I wrote the REST API bridging the front end, the AI, and the database. SQLite was the perfect choice for prototyping: zero configuration, ultra-lightweight.
Scraping & ETL (Python / BeautifulSoup): INAM (the national health insurance) doesn't provide an API. So, I coded a scraper to pull the on-duty list directly from their website. Then came the big challenge: matching the scraped pharmacy names with my geolocated database. I used the Jaccard similarity index to compare text (after stripping accents, "Pharmacie de...", etc.).
Artificial Intelligence (scikit-learn): I trained a LinearSVC model on a 5,000-sentence corpus. No ChatGPT here! Just an ultra-lightweight TF-IDF model classifying text into 8 intents (emergency, route, search, etc.).
Frontend & Geo (Leaflet / OSRM): I used the browser's Geolocation API (W3C) along with Leaflet coupled with OSRM (Open Source Routing Machine) to trace real-time routes.
What I’m Most Proud Of It's not just the code itself, but the ingenuity driven by constraints:
Taming class imbalance: Normally, vital emergencies account for less than 3% of queries. A standard model would have ignored them. I used oversampling to force the AI to learn them. Result: 136 out of 137 emergencies detected on my final test set. When coding for healthcare, that number makes me truly proud.
Human-in-the-loop: Since scraping can break if INAM changes its layout, I built an admin dashboard. Validation is hybrid: if the Jaccard similarity score is 100%, it automatically publishes. If it's ambiguous, a human validates it manually. We combine machine speed with human reliability.
Measured real-world impact: I ran tests with real users (traditional method vs. PharmaX). Search time dropped from 18 minutes to 20 seconds, and the success rate doubled (from 40% to 80%). Proving that my code makes a concrete difference on the ground is my greatest pride.
What I Learned (The Hacker’s Lesson)
ML is 20% of the job; Data is 80%: Spending hours doing HTML parsing and text cleaning (ETL) taught me Garbage in, garbage out. AI is powerful, but it’s a slave to data quality.
Frugality is a feature, not a bug: In our African context, we don't need a 100-billion-parameter LLM that costs a fortune in API fees. A good old, well-trained LinearSVC runs in milliseconds, costs nothing, and works offline. That is meaningful innovation.
UX matters as much as the algorithm: The best model in the world is useless if a user panics and doesn't know where to tap. I learned to design for urgency (large buttons, clear guidance).
What’s next? Migrating to PostgreSQL/PostGIS to scale nationally, and adding voice recognition (for users who can't read or are too stressed to type).
All in all, PharmaX proved to me that with open-source tools, resourcefulness, and a deep understanding of local needs, you can hack solutions that can potentially save lives.