Community
Achieng Odhiambo
Achieng OdhiamboTech
Oct 9

What stack did you use to build a health dashboard for a Kenyan NGO?

I built a dashboard for a health NGO in Kisumu that shows patient visit trends and medication stock levels. Metabase on the front end, with a Python/pandas pipeline pulling from PostgreSQL and scheduled with cron. I kept hitting Postgres timeouts on flaky 3G, then bumped the connection timeout and added SET statement_timeout = 30000; and that sorted it. Curious what everyone else runs for this kind of thing.

6

Replies

6
AM
AmaniOct 9

Hey, thanks for sharing your stack. To further guard against flaky 3G links, try wrapping your PostgreSQL calls in a retry library like tenacity, or add a connection pooler such as pgBouncer to smooth out the timeouts.

Brian Otieno
Brian OtienoOct 9

The timeouts are usually the connection staying open too long when the 3G link drops, so try a small pgBouncer pool (min 2, max 5) and wrap the DB calls in a retry decorator like @tenacity.retry. Also keep an eye on pg_hba.conf so you're not opening more connections than the network can sustain. ```python import tenacity, psycopg2 @tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_fixed(2)) def run_query(): conn = psycopg2.connect(dsn, connect_timeout=5) with conn.cursor() as cur: cur.execute("SELECT ...") return cur.fetchall() ```

Sarah Njeri
Sarah NjeriOct 10

Good stack, and that timeout fix is a classic. Since the others already covered retries and pgBouncer, one extra tip: if the 3G is really unpredictable, consider caching the dashboard data locally and only refreshing it once or twice a day. That way your team in Kisumu isn't fighting the network every time they load the page. What are they viewing it on mostly, phones or laptops?

Dennis Kipkorir
Dennis KipkorirOct 11

Yeah, phones are almost always the main thing in Kisumu, that data connection is rough. If you can cache the heavy queries into a local SQLite file once a day and let Metabase read from that, it’ll load instantly even on 2G. Saves you from chasing timeouts every refresh.

Wanjiru Kamau
Wanjiru KamauOct 12

Nice one! Since the others already covered the tech fixes, I'll just second the caching idea. For a small NGO team, even a simple daily email with the key numbers can save them from fighting 3G altogether. Have you thought about what the nurses actually need to see first thing in the morning?

Collins Omondi
Collins OmondiOct 13

Yeah, the daily email idea hits home, a lot of nurses in Kisumu check WhatsApp first thing, so even a simple message with stock alerts would go a long way. Have you asked them what they actually open most, the dashboard or their phone notifications?