<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adrian Lawley</title>
    <description>The latest articles on DEV Community by Adrian Lawley (@adrian_lawley_486b7f7e84a).</description>
    <link>https://dev.to/adrian_lawley_486b7f7e84a</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4060974%2F1196762b-61fa-4e32-b8a0-305e5b7f3a10.png</url>
      <title>DEV Community: Adrian Lawley</title>
      <link>https://dev.to/adrian_lawley_486b7f7e84a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adrian_lawley_486b7f7e84a"/>
    <language>en</language>
    <item>
      <title>I Built a Lottery EV Tracker with Flutter, FastAPI, and DuckDB — Here's What I Learned</title>
      <dc:creator>Adrian Lawley</dc:creator>
      <pubDate>Mon, 03 Aug 2026 15:58:41 +0000</pubDate>
      <link>https://dev.to/adrian_lawley_486b7f7e84a/i-built-a-lottery-ev-tracker-with-flutter-fastapi-and-duckdb-heres-what-i-learned-2g4f</link>
      <guid>https://dev.to/adrian_lawley_486b7f7e84a/i-built-a-lottery-ev-tracker-with-flutter-fastapi-and-duckdb-heres-what-i-learned-2g4f</guid>
      <description>&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Lottery advice online is mostly folklore — "hot numbers," "your birthday is&lt;br&gt;
lucky," systems that don't change anything mathematically. I wanted the&lt;br&gt;
opposite: an app that tells you the truth about what you're actually buying.&lt;/p&gt;

&lt;p&gt;That became &lt;a href="https://strategy-tracker.lawley.de" rel="noopener noreferrer"&gt;Strategy Tracker&lt;/a&gt; — expected&lt;br&gt;
value per draw, historical number frequency, and a birthday-bias detector&lt;br&gt;
(a large share of players pick numbers 1–31, which measurably raises the odds&lt;br&gt;
you'll split a jackpot with someone else if you win).&lt;/p&gt;

&lt;p&gt;To be clear going in: &lt;strong&gt;no lottery has a positive EV, and nothing here changes&lt;br&gt;
your odds.&lt;/strong&gt; What changes is whether you understand the actual cost, and&lt;br&gt;
whether you're playing at a relatively better or worse moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Flutter&lt;/strong&gt; for the client — one codebase for iOS and web (Android next).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FastAPI + DuckDB&lt;/strong&gt; for the backend — draw history and stats live in
DuckDB, which is fast enough for the aggregation queries (frequency counts,
cold-streak detection, sum-distribution analysis) without needing a heavier
OLAP setup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Postgres&lt;/strong&gt; for auth/user accounts, kept separate from the DuckDB draw data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fly.io&lt;/strong&gt;, one small &lt;code&gt;shared-cpu-1x&lt;/code&gt; machine, scale-to-zero. Cheap enough
to run as a side project — real cost has been under $6/month.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Actions&lt;/strong&gt; drives everything on a schedule: scrapers pull each
lottery's result a few hours after the draw, EV recalculates the moment a
new jackpot is announced, and a separate pipeline generates per-lottery
statistics content automatically.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Supporting 9 different lotteries meant 9 different bonus-ball formats
&lt;/h2&gt;

&lt;p&gt;UK, Germany, Canada, Ireland, Austria, Switzerland, South Africa, Poland, and&lt;br&gt;
Eurojackpot don't agree on how many bonus numbers a draw has — most have one,&lt;br&gt;
Eurojackpot has two, Poland has none. That "none" case was the interesting&lt;br&gt;
one: a naive implementation defaults an absent value to 0, and 0 quietly&lt;br&gt;
looks like a valid drawn number everywhere in the UI until someone points out&lt;br&gt;
your Polish Lotto results are showing a bonus ball that doesn't exist.&lt;/p&gt;

&lt;h2&gt;
  
  
  The morning everything broke
&lt;/h2&gt;

&lt;p&gt;One small shared machine running scrapers, content generation, and live app&lt;br&gt;
traffic all at once has a failure mode: if enough scheduled jobs land in the&lt;br&gt;
same few minutes, they stampede the cold machine under memory pressure. That's&lt;br&gt;
exactly what happened — several unrelated cron jobs (in two different repos)&lt;br&gt;
ended up scheduled within seconds of each other, and DuckDB's write-locking&lt;br&gt;
meant they queued up and timed each other out. ~11 hours of "backend&lt;br&gt;
unreachable" failures across the content pipeline before I caught it.&lt;/p&gt;

&lt;p&gt;Fix was mostly boring: bump the machine's memory, and enforce a hard rule —&lt;br&gt;
every scheduled job that touches the backend has to be at least 30 minutes&lt;br&gt;
from every other one, across both repos. Wrote it down as a standing rule&lt;br&gt;
so it doesn't happen again as more lotteries get added.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;Android build, a proper iOS App Store listing, and expanding the EV math to&lt;br&gt;
a few more lotteries. If you're into "boringly honest" side projects or have&lt;br&gt;
opinions on DuckDB for this kind of workload, I'd love to hear from you.&lt;/p&gt;

&lt;p&gt;Try it: &lt;a href="https://strategy-tracker.lawley.de" rel="noopener noreferrer"&gt;https://strategy-tracker.lawley.de&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>duckdb</category>
      <category>fastapi</category>
      <category>claude</category>
    </item>
  </channel>
</rss>
