Hacker

Srikar Duvvuri

@srikarduvvuri

Joined Nov 2026Senior Software Engineer at WowtownAIIndia

Projects

  • streamlit-flagsmith: trustworthy A/B tests for Streamlit with Flagsmith

    Flagsmith Experimentation HackathonNov 2026

    The problem: an A/B test needs to recognise each visitor consistently, but Streamlit forgets visitors on every refresh. With the usual hand-rolled code (session_state + random.choice), one person becomes several "visitors", can flip between A and B, and the test results are quietly wrong, with no error anywhere. Wiring Flagsmith in by hand has more silent traps: a network call on every rerun, conversions dropped because of a mismatched ID or an event-name typo, and the SDK sending events to Flagsmith Cloud instead of your self-hosted server. What I built: streamlit-flagsmith, an open-source Python package (a Streamlit component) that makes Flagsmith A/B testing and segment targeting work correctly in Streamlit apps. It's self-hosted-first and tested against Flagsmith v2.294.0 in Docker. Who would use it: Python and data people who build dashboards and apps in Streamlit and want to A/B test or roll out features safely, without writing their own visitor tracking. How it works: a tiny browser component stores an anonymous visitor ID in a first-party cookie, so the same person keeps the same variant across clicks, refreshes, new tabs and later visits. The Python side asks Flagsmith once per visitor, caches the answer, records the exposure when the variant is actually shown, and sends conversions with the same ID (catching typos). It sends events to your own server and falls back safely to the control if Flagsmith is down. In three lines: exp = Experiment("flag"), if exp.variant == "B", exp.track("event"). It can also send browser traits (device, locale, timezone) so Flagsmith segments can target visitors, for example a compact layout for phones. I proved it end to end on my own Streamlit app: a 50/50 experiment with 400 simulated visitors through the real SDK, where Flagsmith picked B (+39.3%, 98% chance to be best), and then I rolled B out to everyone with the same flag, with no redeploy.