<?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: Akuma Vencent</title>
    <description>The latest articles on DEV Community by Akuma Vencent (@akuma_vencent_d5795f5572f).</description>
    <link>https://dev.to/akuma_vencent_d5795f5572f</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%2F4093851%2F8684ee15-2d03-4a72-bce0-8f131d8f3277.jpg</url>
      <title>DEV Community: Akuma Vencent</title>
      <link>https://dev.to/akuma_vencent_d5795f5572f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akuma_vencent_d5795f5572f"/>
    <language>en</language>
    <item>
      <title>How I Built an Automated App Store &amp; Google Play ASO Diff + 1★ Crash Radar in Python (&lt;$0.01/week in AI)</title>
      <dc:creator>Akuma Vencent</dc:creator>
      <pubDate>Fri, 27 Nov 2026 11:34:17 +0000</pubDate>
      <link>https://dev.to/akuma_vencent_d5795f5572f/how-i-built-an-automated-app-store-google-play-aso-diff-1-crash-radar-in-python-001week-2ecg</link>
      <guid>https://dev.to/akuma_vencent_d5795f5572f/how-i-built-an-automated-app-store-google-play-aso-diff-1-crash-radar-in-python-001week-2ecg</guid>
      <description>&lt;p&gt;Most App Store Optimization (ASO) SaaS tools charge &lt;strong&gt;$49–$199/month&lt;/strong&gt; just to tell you two things an indie mobile developer actually needs every week:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Did a top competitor change their App Store / Google Play title, subtitle, description keywords, or storefront icon?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Did my latest build trigger a sudden wave of 1–2★ crash or billing complaints before my average rating tanks?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of paying for another heavy web dashboard I forget to open, I built &lt;strong&gt;&lt;a href="https://t.me/AppASORadarBot?start=devto_aso" rel="noopener noreferrer"&gt;App ASO &amp;amp; Review Radar (&lt;code&gt;@AppASORadarBot&lt;/code&gt;)&lt;/a&gt;&lt;/strong&gt; — a lightweight Python + PostgreSQL + Redis + Gemini 2.5 Flash-Lite monitoring engine that tracks &lt;strong&gt;100 live iOS &amp;amp; Android apps across 10 countries&lt;/strong&gt; and sends instant diff alerts straight into Telegram (plus a free live public feed at &lt;strong&gt;&lt;a href="https://t.me/AppStore_ASO_Pulse" rel="noopener noreferrer"&gt;@AppStore_ASO_Pulse&lt;/a&gt;&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;Here is the exact engineering breakdown — including how we keep AI API spend near &lt;strong&gt;$0.0005/day&lt;/strong&gt; using hash-gated diffing.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Zero-Token Rule: Hash First, LLM Only on Meaningful Diffs
&lt;/h2&gt;

&lt;p&gt;If you naively pass every scraped store page to an LLM on a cron schedule, you burn tokens re-summarizing identical store descriptions 24 times a day.&lt;/p&gt;

&lt;p&gt;Instead, every tracked &lt;code&gt;(platform, app_id, country)&lt;/code&gt; runs through a strict 3-stage pipeline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Global Deduplicated Scraping&lt;/strong&gt;: Even if 10 users track the same competitor (&lt;code&gt;com.canva.editor&lt;/code&gt; in &lt;code&gt;us&lt;/code&gt;), the worker scrapes it &lt;strong&gt;once&lt;/strong&gt; at the highest-tier subscriber's polling frequency (&lt;code&gt;24h&lt;/code&gt; Free / &lt;code&gt;3h&lt;/code&gt; Indie / &lt;code&gt;1h&lt;/code&gt; Studio).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic Content &amp;amp; Icon Hashing&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Text fields (&lt;code&gt;title&lt;/code&gt;, &lt;code&gt;subtitle&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;whats_new&lt;/code&gt;, &lt;code&gt;version&lt;/code&gt;) are normalized and compared field-by-field against &lt;code&gt;app_snapshots&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Storefront icons are fingerprinted so we catch silent icon A/B tests and seasonal redesigns automatically.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If nothing changed → &lt;code&gt;0&lt;/code&gt; Gemini tokens consumed.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Noise-Filtered Event Classification&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Pure minor version bumps (&lt;code&gt;version_only&lt;/code&gt;) don't need expensive AI analysis unless paired with major copy/icon shifts (&lt;code&gt;aso_major&lt;/code&gt;, &lt;code&gt;icon&lt;/code&gt;) or new 1–2★ negative reviews.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Real Storefront Diffs Caught Live Today (Nov 27, 2026)
&lt;/h3&gt;

&lt;p&gt;From our 100-app production pool running on Oracle Cloud ARM64:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;AdGuard VPN: Free Your Privacy&lt;/code&gt; (iOS US)&lt;/strong&gt;: Caught storefront icon fingerprint swap (&lt;code&gt;41810fff&lt;/code&gt; → &lt;code&gt;4fd71c42&lt;/code&gt;) + &lt;code&gt;v2.17.2 → v2.17.3&lt;/code&gt; release notes shift. Gemini 2.5 Flash-Lite flagged the intent in 1 second: &lt;em&gt;"Pivoting release messaging toward technical reliability &amp;amp; VPN connection stability rather than new feature hype."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ShortMax - Short Dramas &amp;amp; TV&lt;/code&gt; (Google Play US)&lt;/strong&gt;: Caught an &lt;code&gt;aso_major&lt;/code&gt; description rewrite fixing a typo (&lt;code&gt;favoriate → favorite&lt;/code&gt;) while injecting high-intent sub-genre keywords (&lt;code&gt;contemporary romance&lt;/code&gt;, &lt;code&gt;werewolf romance&lt;/code&gt;, &lt;code&gt;mafia dramas&lt;/code&gt;, &lt;code&gt;revenge&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ExpressVPN&lt;/code&gt; (iOS US)&lt;/strong&gt;: Caught silent icon hash change (&lt;code&gt;b385dcf9 → 9070bb82&lt;/code&gt;) alongside &lt;code&gt;v13.0.2 → v13.0.3&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Total Gemini cost across &lt;strong&gt;41 detected store change events&lt;/strong&gt; over the past week? &lt;strong&gt;$0.007 USD&lt;/strong&gt; (less than a penny).&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Dual-Store Scraping Without Fragile Paid Wrappers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Apple App Store&lt;/strong&gt;: Combines Apple's official iTunes Lookup endpoint (&lt;code&gt;itunes.apple.com/lookup&lt;/code&gt;), country-scoped App Store HTML metadata parsing (to capture subtitle &amp;amp; promotional text), and Apple's public customer-review RSS feed sorted by most recent to catch 1–2★ spikes fast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Play&lt;/strong&gt;: Uses a Redis-throttled scraper lock + automatic circuit breaker so bursts of user requests never trigger IP throttling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3-Second Instant Diagnosis + 24h Global Cache&lt;/strong&gt;: When a developer pastes any App Store link, Google Play URL, numeric iOS App ID, or Android package name into &lt;code&gt;@AppASORadarBot&lt;/code&gt;, we return a structured ASO health check in ~3 seconds — and cache the result globally for 24 hours so repeated lookups serve in milliseconds with zero scraper or LLM overhead.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Turning Alerts Into Team Workflows (Zero Login Needed)
&lt;/h2&gt;

&lt;p&gt;Most solo builders and small app studios already live in a Telegram group with their designer or co-founder.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instant Personal Audit&lt;/strong&gt;: Drop any app link into &lt;a href="https://t.me/AppASORadarBot?start=devto_aso" rel="noopener noreferrer"&gt;@AppASORadarBot&lt;/a&gt; — free users get &lt;strong&gt;3 live diagnoses/day&lt;/strong&gt; + 1 permanently tracked app (&lt;code&gt;24h&lt;/code&gt; polling) with zero signup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public Live Competitor Stream&lt;/strong&gt;: Just want to watch how top apps like ChatGPT, Canva, Duolingo, and Notion tweak their listings? Lurk for free in &lt;a href="https://t.me/AppStore_ASO_Pulse" rel="noopener noreferrer"&gt;@AppStore_ASO_Pulse&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Group &lt;code&gt;/bind&lt;/code&gt; + AI Reply Drafts&lt;/strong&gt;: For indie studios tracking 5–25 apps across up to 10 store countries, alerts (including AI-drafted diplomatic replies for 1–2★ reviews) pipe straight into a team Telegram group via &lt;code&gt;/bind&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It On Your Own App (Takes 3 Seconds)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instant Free App Store / Google Play Audit&lt;/strong&gt;: &lt;a href="https://t.me/AppASORadarBot?start=devto_aso" rel="noopener noreferrer"&gt;t.me/AppASORadarBot&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free Live Public ASO Diff Channel&lt;/strong&gt;: &lt;a href="https://t.me/AppStore_ASO_Pulse" rel="noopener noreferrer"&gt;t.me/AppStore_ASO_Pulse&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Companion Productivity Bots on the Same Stack&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Zero-spam AI &amp;amp; SaaS deal radar: &lt;a href="https://t.me/AISaaSDealsPulse" rel="noopener noreferrer"&gt;@AISaaSDealsPulse&lt;/a&gt; / &lt;a href="https://www.aisubdeal.com/" rel="noopener noreferrer"&gt;aisubdeal.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Forward PDFs &amp;amp; voice notes for instant TL;DR: &lt;a href="https://t.me/DocVoiceAIBot?start=devto_doc" rel="noopener noreferrer"&gt;@DocVoiceAIBot&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;If you're an indie iOS or Android developer&lt;/strong&gt;: what store change hurts you the most when you miss it — a competitor stealing your core subtitle keyword, an icon redesign, or a quiet 1★ crash spike in a non-English storefront? Let me know in the comments!&lt;/p&gt;

</description>
      <category>ios</category>
      <category>android</category>
      <category>indiedev</category>
      <category>python</category>
    </item>
    <item>
      <title>How I Built a 4-Bot Telegram AI Engine (&lt;1.6GB OCI ARM64) with Redis Lua USD Budget Locks &amp; Gemini Flash-Lite</title>
      <dc:creator>Akuma Vencent</dc:creator>
      <pubDate>Fri, 27 Nov 2026 07:34:37 +0000</pubDate>
      <link>https://dev.to/akuma_vencent_d5795f5572f/how-i-built-a-4-bot-telegram-ai-engine-16gb-oci-arm64-with-redis-lua-usd-budget-locks-gemini-7j3</link>
      <guid>https://dev.to/akuma_vencent_d5795f5572f/how-i-built-a-4-bot-telegram-ai-engine-16gb-oci-arm64-with-redis-lua-usd-budget-locks-gemini-7j3</guid>
      <description>&lt;p&gt;If you build production Telegram bots powered by modern LLMs, you hit two brutal walls almost immediately:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Runaway token bills&lt;/strong&gt; — one free-tier user spamming a 50-page PDF, a cache-miss stampede on a hot token address, or a cron job repeatedly triaging rejected feed items can quietly burn through $50–$200/month.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure sprawl&lt;/strong&gt; — spinning up a separate server, database, and worker per bot turns side projects into an expensive ops nightmare.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Over the last few weeks, I built and deployed a &lt;strong&gt;4-bot Telegram AI production matrix&lt;/strong&gt; running on a single Oracle Cloud ARM64 box — with the core 5-container multi-tenant stack capped under &lt;strong&gt;1.6 GB RAM&lt;/strong&gt; and a &lt;strong&gt;hard Fail-Closed USD budget ceiling&lt;/strong&gt; across all 4 bots.&lt;/p&gt;

&lt;p&gt;Here is the real architecture, the anti-abuse loopholes I caught and closed in production, and the live bots you can test right now with zero signup.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Architecture: One Multi-Tenant Core, 4 Distinct Bots
&lt;/h2&gt;

&lt;p&gt;Instead of maintaining separate codebases for every idea, three bots share a single async Python core (&lt;code&gt;aiohttp&lt;/code&gt; + &lt;code&gt;aiogram 3&lt;/code&gt; + &lt;code&gt;SQLAlchemy 2&lt;/code&gt; + &lt;code&gt;ARQ&lt;/code&gt; + &lt;code&gt;PostgreSQL 16&lt;/code&gt; + &lt;code&gt;Redis 7&lt;/code&gt;), while a fourth specialized App Store / Google Play tracker runs in its own isolated container stack on the same host and feeds into a unified read-only executive dashboard:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Horse #1 — &lt;a href="https://t.me/DocVoiceAIBot?start=devto_doc" rel="noopener noreferrer"&gt;@DocVoiceAIBot&lt;/a&gt;&lt;/strong&gt;: 5-language (&lt;code&gt;EN/RU/ES/PT/AR&lt;/code&gt;) Telegram-native PDF (up to 50 pages), DOCX, and voice note assistant (translation, bilingual summary, or structured action-item checklist). Two-tier routing sends routine DOCX/voice/text PDFs to &lt;code&gt;Gemini 3.5 Flash-Lite&lt;/code&gt; and only escalates scanned PDFs or contract clause checklists to &lt;code&gt;Gemini 3.8 Flash&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Horse #2 — &lt;a href="https://t.me/AISaaSDealsPulse" rel="noopener noreferrer"&gt;@AISaaSDealsPulse&lt;/a&gt; &amp;amp; &lt;a href="https://t.me/AISaaSDealsRadarBot?start=devto_deals" rel="noopener noreferrer"&gt;@AISaaSDealsRadarBot&lt;/a&gt;&lt;/strong&gt;: Zero-spam curated radar for newly free flagship AI models (OpenRouter), API price drops, and real SaaS discounts — paired with my 20-country AI subscription price tracker at &lt;a href="https://www.aisubdeal.com/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=tg_engine" rel="noopener noreferrer"&gt;aisubdeal.com&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Horse #3 — &lt;a href="https://t.me/ChainRiskRadarBot?start=devto_chain" rel="noopener noreferrer"&gt;@ChainRiskRadarBot&lt;/a&gt;&lt;/strong&gt;: 3-second Solana &amp;amp; EVM (&lt;code&gt;ETH / Base / BSC / Arbitrum&lt;/code&gt;) contract risk card combining DexScreener + GeckoTerminal v2 market fallback with GoPlus + RugCheck + Honeypot.is security checks (zero wallet connect required).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Horse #4 — &lt;a href="https://t.me/AppASORadarBot?start=devto_aso" rel="noopener noreferrer"&gt;@AppASORadarBot&lt;/a&gt;&lt;/strong&gt;: Tracks App Store &amp;amp; Google Play competitor metadata changes, version drops, and bad-review spikes with AI diagnosis cards.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Total memory ceiling for the 5-container multi-tenant engine (&lt;code&gt;hr-postgres&lt;/code&gt;, &lt;code&gt;hr-redis&lt;/code&gt;, &lt;code&gt;hr-bot-gateway&lt;/code&gt;, &lt;code&gt;hr-worker-scheduler&lt;/code&gt;, &lt;code&gt;hr-backup&lt;/code&gt;): &lt;strong&gt;1,600 MiB&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Config-Driven Zero-Proxy Ingestion (&lt;code&gt;data/deal_sources.json&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Headless browsers and residential proxies are the #1 reason hobby deal aggregators die within a week. For &lt;code&gt;@AISaaSDealsPulse&lt;/code&gt;, every upstream feed is a structured endpoint declared in JSON with per-source fault isolation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"openrouter_models"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"OpenRouter AI Models &amp;amp; Free Tiers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"openrouter_pricing"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://openrouter.ai/api/v1/models"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"enabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"category_hint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ai_api"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"max_items"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"ignore_http_errors"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We poll OpenRouter's model pricing API, Hacker News Algolia (&lt;code&gt;show_hn&lt;/code&gt;), Product Hunt Atom, and curated developer-tool GitHub Releases concurrently. Any transient &lt;code&gt;429&lt;/code&gt; or timeout on an optional RSS feed is isolated so it never breaks the rest of the cycle.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Subtle Token Burn Bug I Caught in Production
&lt;/h3&gt;

&lt;p&gt;In our first 6 hours live, our deals ingestor burned &lt;strong&gt;$0.167&lt;/strong&gt; (&lt;code&gt;~$20/month&lt;/code&gt; projected) even though almost nothing was published. Why?&lt;/p&gt;

&lt;p&gt;We were only deduplicating &lt;strong&gt;approved&lt;/strong&gt; deals stored in PostgreSQL — meaning every 30-minute cron cycle kept re-sending the exact same &lt;strong&gt;rejected&lt;/strong&gt; items back to Gemini!&lt;/p&gt;

&lt;p&gt;The fix dropped our daily burn by &lt;strong&gt;&amp;gt;95%&lt;/strong&gt; (down to &lt;code&gt;&amp;lt;$0.04/day&lt;/code&gt;):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Store a &lt;strong&gt;14-day Redis seen-ID set&lt;/strong&gt; for &lt;strong&gt;both approved and rejected&lt;/strong&gt; candidates before invoking Gemini.&lt;/li&gt;
&lt;li&gt;Instruct the triage model to output &lt;code&gt;summary_en=null&lt;/code&gt; on rejected items and keep batch sizes tight (&lt;code&gt;6&lt;/code&gt; candidates per call) so structured JSON never truncates under strict &lt;code&gt;max_output_tokens&lt;/code&gt; caps.&lt;/li&gt;
&lt;li&gt;Enforce a hard &lt;strong&gt;max 2 high-signal drops per cycle&lt;/strong&gt; to the public channel and explicitly reject routine patch releases (&lt;code&gt;v1.x.y bug fixes&lt;/code&gt;) and consumer hobby projects so subscribers never mute the feed.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  3. Atomic Redis 7 Lua Pre-Flight USD Budget Locks
&lt;/h2&gt;

&lt;p&gt;Post-call spend checks are vulnerable to concurrency bursts: 20 simultaneous requests can all pass &lt;code&gt;if spent &amp;lt; limit&lt;/code&gt; before the first one finishes.&lt;/p&gt;

&lt;p&gt;Instead, every Gemini call goes through a &lt;strong&gt;two-phase atomic Redis 7 Lua reservation&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pre-flight reserve&lt;/strong&gt;: Atomically add the worst-case estimated USD cost into &lt;code&gt;inflight&lt;/code&gt; (with a 180s safety TTL) while checking:

&lt;ul&gt;
&lt;li&gt;Global daily USD cap (&lt;code&gt;$3.50/day&lt;/code&gt;) &amp;amp; monthly USD cap (&lt;code&gt;$50.00/mo&lt;/code&gt; for the 3-bot core + &lt;code&gt;$50.00/mo&lt;/code&gt; for ASO Radar = strict &lt;code&gt;$100/mo&lt;/code&gt; shared key ceiling)&lt;/li&gt;
&lt;li&gt;Per-bot daily sub-caps (&lt;code&gt;deals_bot=$0.30&lt;/code&gt;, &lt;code&gt;doc_bot=$1.50&lt;/code&gt;, &lt;code&gt;chain_bot=$2.00&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;80% Free-Tier Cutoff&lt;/strong&gt;: Once spend crosses &lt;code&gt;80%&lt;/code&gt;, free-tier requests and background cron tasks auto-degrade cleanly while preserving the remaining &lt;code&gt;20%&lt;/code&gt; exclusively for paying Telegram Stars VIP users.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guaranteed &lt;code&gt;finally:&lt;/code&gt; settle&lt;/strong&gt;: Release the &lt;code&gt;inflight&lt;/code&gt; reservation and commit the exact token cost (including billable thinking tokens on &lt;code&gt;gemini-3.8-flash&lt;/code&gt;) to Redis + PostgreSQL &lt;code&gt;ai_usage_logs&lt;/code&gt;. On gateway/worker startup, Redis counters automatically re-hydrate from PostgreSQL so restarts can never reset spend limits.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Three More Real-World Anti-Abuse Guards Worth Copying
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero-token bogus-CA guard (&lt;code&gt;@ChainRiskRadarBot&lt;/code&gt;)&lt;/strong&gt;: If a user spams random hex/base58 strings where both market APIs and security APIs return empty, skip the LLM completely (&lt;code&gt;0&lt;/code&gt; tokens spent) + use Singleflight &lt;code&gt;(chain, address)&lt;/code&gt; coalescing so 50 concurrent users scanning the same trending memecoin trigger only &lt;strong&gt;1&lt;/strong&gt; upstream check.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-token oversized free file guard (&lt;code&gt;@DocVoiceAIBot&lt;/code&gt;)&lt;/strong&gt;: Reject free uploads exceeding &lt;code&gt;10MB / 15 pages / 5 min&lt;/code&gt; immediately with an honest upgrade prompt before touching Gemini, and force post-trial 20% previews onto &lt;code&gt;flash-lite&lt;/code&gt; capped at &lt;code&gt;1/day&lt;/code&gt; and &lt;code&gt;600&lt;/code&gt; output tokens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Honest upfront quotas&lt;/strong&gt;: Avoid marketing "Unlimited" on AI plans. Showing clear daily fair-use caps (&lt;code&gt;60 tasks/day&lt;/code&gt; for VIPs, &lt;code&gt;3 free scans/day&lt;/code&gt;) and remaining counters directly inside &lt;code&gt;/start&lt;/code&gt; and invoices eliminates chargeback friction and user frustration.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Native Telegram Stars Billing &amp;amp; Unified 4-Bot Read-Only Telemetry
&lt;/h2&gt;

&lt;p&gt;Because Telegram Stars (&lt;code&gt;XTR&lt;/code&gt;) works natively inside mobile/desktop Telegram with &lt;strong&gt;zero credit card forms or web logins&lt;/strong&gt;, monetization friction drops dramatically for global users (especially across CIS, LatAm, and MENA). One subtle safeguard: automatic &lt;code&gt;refundStarPayment&lt;/code&gt; on job failure is strictly locked to &lt;strong&gt;one-off purchases&lt;/strong&gt; (&lt;code&gt;50 Stars&lt;/code&gt;), while monthly VIP failures roll back quota and offer 1-tap retry instead of refunding an entire month.&lt;/p&gt;

&lt;p&gt;To monitor all 4 bots and the shared &lt;code&gt;$100/mo&lt;/code&gt; AI key in one place, I mounted a zero-CDN executive dashboard directly inside the existing gateway (protected by an &lt;code&gt;HttpOnly&lt;/code&gt; HMAC-signed cookie) and bridged &lt;code&gt;@AppASORadarBot&lt;/code&gt;'s separate PostgreSQL instance via a &lt;strong&gt;database-enforced &lt;code&gt;SELECT&lt;/code&gt;-only role&lt;/strong&gt; (&lt;code&gt;default_transaction_read_only = on&lt;/code&gt;) — zero changes or restarts needed on the sibling stack.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try Any of the 4 Live Bots (No Signup Needed)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;100% Free AI &amp;amp; SaaS Deals Feed&lt;/strong&gt; (max 2 curated drops/cycle): &lt;strong&gt;&lt;a href="https://t.me/AISaaSDealsPulse" rel="noopener noreferrer"&gt;@AISaaSDealsPulse&lt;/a&gt;&lt;/strong&gt; · Companion Bot: &lt;strong&gt;&lt;a href="https://t.me/AISaaSDealsRadarBot?start=devto_deals" rel="noopener noreferrer"&gt;@AISaaSDealsRadarBot&lt;/a&gt;&lt;/strong&gt; · Full 20-country AI pricing index: &lt;strong&gt;&lt;a href="https://www.aisubdeal.com/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=tg_engine" rel="noopener noreferrer"&gt;aisubdeal.com&lt;/a&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5-Language PDF &amp;amp; Voice Note AI Assistant&lt;/strong&gt; (2 free full runs): &lt;strong&gt;&lt;a href="https://t.me/DocVoiceAIBot?start=devto_doc" rel="noopener noreferrer"&gt;@DocVoiceAIBot&lt;/a&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3-Second Solana &amp;amp; EVM Contract Risk Scanner&lt;/strong&gt; (3 free scans/day, no wallet connect): &lt;strong&gt;&lt;a href="https://t.me/ChainRiskRadarBot?start=devto_chain" rel="noopener noreferrer"&gt;@ChainRiskRadarBot&lt;/a&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App Store &amp;amp; Google Play Competitor ASO &amp;amp; Review Radar&lt;/strong&gt;: &lt;strong&gt;&lt;a href="https://t.me/AppASORadarBot?start=devto_aso" rel="noopener noreferrer"&gt;@AppASORadarBot&lt;/a&gt;&lt;/strong&gt; · Live Public Feed: &lt;strong&gt;&lt;a href="https://t.me/AppStore_ASO_Pulse" rel="noopener noreferrer"&gt;@AppStore_ASO_Pulse&lt;/a&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How are you capping LLM token spend on your public Telegram/Discord bots without ruining UX for paying users? Happy to share any part of the Redis Lua or ARQ setup in the comments!&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>telegram</category>
      <category>devops</category>
    </item>
    <item>
      <title>Why Generic PDF-to-Excel Converters Silently Drop Transactions — And How Dual-Chain Running Balance Math Catches It</title>
      <dc:creator>Akuma Vencent</dc:creator>
      <pubDate>Wed, 25 Nov 2026 02:03:53 +0000</pubDate>
      <link>https://dev.to/akuma_vencent_d5795f5572f/why-generic-pdf-to-excel-converters-silently-drop-transactions-and-how-dual-chain-running-balance-5746</link>
      <guid>https://dev.to/akuma_vencent_d5795f5572f/why-generic-pdf-to-excel-converters-silently-drop-transactions-and-how-dual-chain-running-balance-5746</guid>
      <description>&lt;p&gt;If you have ever converted a PDF bank statement into Excel using a generic PDF-to-XLSX tool—or Excel's built-in Power Query PDF connector—you have probably seen a spreadsheet that &lt;em&gt;looks&lt;/em&gt; completely fine. The columns line up. The rows look tidy.&lt;/p&gt;

&lt;p&gt;Then, at month-end close, your QuickBooks or Excel reconciliation is off by &lt;code&gt;$490.40&lt;/code&gt;. Twenty-five minutes of line-by-line checking later, you discover that a single Zelle deposit sitting at the bottom of page 1 silently vanished during extraction.&lt;/p&gt;

&lt;p&gt;When we built &lt;strong&gt;DocuBridge&lt;/strong&gt;, we started from one rule: &lt;strong&gt;a bank statement converter that does not prove its own math is worse than manual data entry&lt;/strong&gt;, because manual typos feel uncertain while a neat CSV creates false confidence.&lt;/p&gt;

&lt;p&gt;This post breaks down why generic PDF extractors fail silently on US bank statements, and four concrete architectural patterns we implemented in Python and Next.js to make failures loud, deterministic, and safe:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Coordinate-based layout parsing&lt;/strong&gt; for real bank PDF quirks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dual-chain running balance verification&lt;/strong&gt; in &lt;code&gt;decimal.Decimal&lt;/code&gt; that isolates a single broken row without cascading false alarms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Defense-in-depth spreadsheet formula-injection protection&lt;/strong&gt; across CSV and XLSX exports.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A privacy-first boundary&lt;/strong&gt; using browser pre-checks, zero-disk worker isolation, in-memory local OCR, dual-factor HKDF crypto-shredding, and a strict per-request nonce CSP.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Why Bank Statement PDFs Break Generic Table Extractors
&lt;/h2&gt;

&lt;p&gt;The PDF specification has no native "table" primitive—only positioned glyph runs on a 72-DPI canvas. Generic converters cluster bounding boxes into grids, which routinely breaks on real US checking and savings statements for four reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-line wrapped descriptions:&lt;/strong&gt; ACH entries, wire memos, and card purchases wrap across two or three lines directly beneath the row with nothing in the Date or Amount columns. Generic tools spawn orphan rows or drop continuation text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ambiguous amount columns and sign conventions:&lt;/strong&gt; Some banks print one signed &lt;code&gt;Amount&lt;/code&gt; column (&lt;code&gt;-53.61&lt;/code&gt;, &lt;code&gt;2520.17&lt;/code&gt;). Others print unsigned &lt;code&gt;Withdrawals/Debits&lt;/code&gt; and &lt;code&gt;Deposits/Credits&lt;/code&gt; columns, trailing &lt;code&gt;CR&lt;/code&gt;/&lt;code&gt;DR&lt;/code&gt; suffixes, placeholder dashes (&lt;code&gt;—&lt;/code&gt;), or separate &lt;strong&gt;Deposits&lt;/strong&gt; and &lt;strong&gt;Withdrawals&lt;/strong&gt; sections sharing identical headers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Yearless &lt;code&gt;MM/DD&lt;/code&gt; dates across year boundaries:&lt;/strong&gt; Many US banks print &lt;code&gt;12/29&lt;/code&gt; and &lt;code&gt;01/03&lt;/code&gt; without a year, relying on a statement period like &lt;code&gt;Dec 15 - Jan 14, 2026&lt;/code&gt;. Stamping every row with the end year pushes December transactions a full year into the future. Our parser resolves yearless &lt;code&gt;(month, day)&lt;/code&gt; tuples against &lt;code&gt;[period_start - 10 days, period_end + 10 days]&lt;/code&gt; before falling back to a flagged inference.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Page furniture impersonating rows:&lt;/strong&gt; Repeating headers, &lt;code&gt;"Page 2 of 4"&lt;/code&gt;, &lt;code&gt;"Continued"&lt;/code&gt;, section subtotals, and &lt;code&gt;"Daily Balance Summary"&lt;/code&gt; boxes contain dates and dollar amounts. Mistaking a subtotal for a transaction—or a real row near a page break for a footer—produces a tidy spreadsheet whose totals silently diverge.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Why "Looks Like a Table" Is a Financial Hazard
&lt;/h2&gt;

&lt;p&gt;In document-AI benchmarks, 98% row accuracy sounds great. In bookkeeping, &lt;strong&gt;98% accuracy on a 100-row statement means two corrupted or missing transactions on every single statement&lt;/strong&gt;—with zero warning about which two failed.&lt;/p&gt;

&lt;p&gt;Consider a real case from our end-to-end synthetic test suite (&lt;code&gt;missing-row.pdf&lt;/code&gt;, January 2026):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Printed Opening / Closing Balance:&lt;/strong&gt; &lt;code&gt;$1,115.75&lt;/code&gt; → &lt;code&gt;-$623.33&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extracted Rows:&lt;/strong&gt; 14 transactions (&lt;code&gt;$5,085.79&lt;/code&gt; credits, &lt;code&gt;$7,315.27&lt;/code&gt; debits)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Computed Closing Balance:&lt;/strong&gt; &lt;code&gt;$1,115.75 + $5,085.79 - $7,315.27 = -$1,113.73&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discrepancy:&lt;/strong&gt; &lt;code&gt;-$623.33 - (-$1,113.73) = +$490.40&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One &lt;code&gt;$490.40&lt;/code&gt; Zelle deposit between row 4 (&lt;code&gt;01/06&lt;/code&gt;) and row 5 (&lt;code&gt;01/09&lt;/code&gt;) was missing. Also note that &lt;strong&gt;IEEE 754 &lt;code&gt;float&lt;/code&gt; has no place in accounting math&lt;/strong&gt;: every monetary token must stay in Python's &lt;code&gt;decimal.Decimal&lt;/code&gt; across all sums, running-balance checks, and diffs so exact-cent equality never suffers binary rounding drift.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Dual-Chain Running Balance Verification
&lt;/h2&gt;

&lt;p&gt;Before any statement can earn a &lt;code&gt;VERIFIED&lt;/code&gt; badge, it must pass &lt;strong&gt;two independent accounting proofs&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Statement-level identity:&lt;/strong&gt; &lt;code&gt;opening + total_credits - total_debits == closing&lt;/code&gt; with exact &lt;code&gt;Decimal("0.00")&lt;/code&gt; tolerance. If opening or closing balance is missing, the status is strictly &lt;code&gt;UNVERIFIABLE&lt;/code&gt;—never a green checkmark.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Row-level running balance proof:&lt;/strong&gt; Every printed running balance (or daily ending balance) must agree mathematically with the preceding transactions.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Naive Single-Chain Trap
&lt;/h3&gt;

&lt;p&gt;The obvious implementation tracks one running sum from &lt;code&gt;opening&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Naive single-chain check (DO NOT USE)&lt;/span&gt;
&lt;span class="n"&gt;running&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;opening&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;transactions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;running&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;running&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If row 5 on a 60-row statement is missing a &lt;code&gt;$490.40&lt;/code&gt; deposit—or OCR misreads one digit of row 5's amount—row 5 fails, row 6 fails, and &lt;strong&gt;rows 7 through 60 all fail&lt;/strong&gt;. One localized glitch causes 56 cascading false positives.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Dual-Chain Algorithm
&lt;/h3&gt;

&lt;p&gt;Instead, we maintain &lt;strong&gt;two simultaneous chains&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;anchor&lt;/code&gt; + &lt;code&gt;since_anchor&lt;/code&gt;&lt;/strong&gt;: cumulative sum from the last &lt;em&gt;trustworthy&lt;/em&gt; balance (initially &lt;code&gt;opening&lt;/code&gt;, updated only when a row agrees).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;prev&lt;/code&gt; + &lt;code&gt;since_prev&lt;/code&gt;&lt;/strong&gt;: cumulative sum from the &lt;em&gt;immediately preceding&lt;/em&gt; printed balance (always updated, even after a break).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A row's printed balance passes if it agrees with &lt;strong&gt;either&lt;/strong&gt; chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;decimal&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;

&lt;span class="no"&gt;ZERO&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0.00"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reconcile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;txs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opening&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;closing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;credits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;txs&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;debits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;txs&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="n"&gt;anchor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;opening&lt;/span&gt;
    &lt;span class="n"&gt;since_anchor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;since_prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;txs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;since_anchor&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;
        &lt;span class="n"&gt;since_prev&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;ok_anchor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;anchor&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;anchor&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;since_anchor&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;ok_prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;since_prev&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;anchor&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ok_anchor&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;ok_prev&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;anchor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;since_anchor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;

        &lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;since_prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;txs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"unverifiable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"no_transactions"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;opening&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;closing&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"unverifiable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"missing_opening_or_closing_balance"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;computed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;opening&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;credits&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;debits&lt;/span&gt;
    &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;closing&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;computed&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"mismatch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"totals_do_not_match"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"mismatch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"running_balance_breaks"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"verified"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"balanced"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breaks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why does this isolate both single-row failure modes cleanly?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Case A — Single misread &lt;em&gt;printed balance&lt;/em&gt; on row &lt;em&gt;k&lt;/em&gt;:&lt;/strong&gt; Row &lt;em&gt;k&lt;/em&gt; fails both chains and is flagged; &lt;code&gt;anchor&lt;/code&gt; stays on row &lt;em&gt;k−1&lt;/em&gt;. On row &lt;em&gt;k+1&lt;/em&gt;, &lt;code&gt;prev&lt;/code&gt; disagrees, &lt;strong&gt;but &lt;code&gt;anchor + since_anchor&lt;/code&gt; equals row &lt;em&gt;k+1&lt;/em&gt;'s true balance&lt;/strong&gt;, so row &lt;em&gt;k+1&lt;/em&gt; passes and re-anchors. Only row &lt;em&gt;k&lt;/em&gt; is flagged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Case B — Single misread &lt;em&gt;amount&lt;/em&gt; or &lt;em&gt;dropped row&lt;/em&gt; right before row &lt;em&gt;k&lt;/em&gt;:&lt;/strong&gt; Trace our &lt;code&gt;$490.40&lt;/code&gt; missing Zelle deposit:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Row&lt;/th&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Amount&lt;/th&gt;
&lt;th&gt;Printed Bal.&lt;/th&gt;
&lt;th&gt;&lt;code&gt;anchor + Δ&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;prev + Δ&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Outcome&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;code&gt;01/06&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-986.72&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1,823.52&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;1,823.52&lt;/code&gt; ✓&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;1,823.52&lt;/code&gt; ✓&lt;/td&gt;
&lt;td&gt;Clean (&lt;code&gt;anchor=prev=1823.52&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;&lt;code&gt;01/09&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-89.25&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2,224.67&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;1,734.27&lt;/code&gt; ✗&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;1,734.27&lt;/code&gt; ✗&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Flagged (&lt;code&gt;balance_break&lt;/code&gt;)&lt;/strong&gt;; &lt;code&gt;prev → 2224.67&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;&lt;code&gt;01/09&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-39.97&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2,184.70&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;1,694.30&lt;/code&gt; ✗&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;2,184.70&lt;/code&gt; ✓&lt;/td&gt;
&lt;td&gt;Clean! Matches &lt;code&gt;prev&lt;/code&gt;, re-anchors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;&lt;code&gt;01/10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-81.28&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2,103.42&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;2,103.42&lt;/code&gt; ✓&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;2,103.42&lt;/code&gt; ✓&lt;/td&gt;
&lt;td&gt;Clean!&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Out of an entire multi-page statement, &lt;strong&gt;only row 5&lt;/strong&gt; is tagged &lt;code&gt;needs_review&lt;/code&gt; with its exact &lt;code&gt;source_page&lt;/code&gt;. Rows where &lt;code&gt;t.balance is None&lt;/code&gt; (such as Wells Fargo daily-ending-balance statements) accumulate cleanly into both deltas until the next printed balance.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Defending Against Spreadsheet Formula Injection (OWASP CSV Injection)
&lt;/h2&gt;

&lt;p&gt;Bank descriptions are untrusted third-party strings. Legitimate merchants start with formula characters (&lt;code&gt;@HOME DECOR OUTLET&lt;/code&gt;, &lt;code&gt;+1 MOBILE TOPUP&lt;/code&gt;, &lt;code&gt;=TAX PREP SERVICES LLC&lt;/code&gt;), and malicious P2P memos can smuggle &lt;code&gt;=HYPERLINK(...)&lt;/code&gt; or legacy DDE payloads.&lt;/p&gt;

&lt;p&gt;Our exporter defends both CSV and XLSX outputs identically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;DANGEROUS_PREFIXES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"="&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"@"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"\t"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"\r"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"＝"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"＋"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"－"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"＠"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;safe_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"'"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;DANGEROUS_PREFIXES&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details matter in practice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Block full-width Unicode triggers&lt;/strong&gt; (&lt;code&gt;＝&lt;/code&gt;, &lt;code&gt;＋&lt;/code&gt;, &lt;code&gt;－&lt;/code&gt;, &lt;code&gt;＠&lt;/code&gt;) alongside ASCII &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;@&lt;/code&gt;, &lt;code&gt;\t&lt;/code&gt;, and &lt;code&gt;\r&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Harden XLSX &lt;em&gt;and&lt;/em&gt; CSV together:&lt;/strong&gt; In &lt;code&gt;.xlsx&lt;/code&gt;, we set &lt;code&gt;cell.data_type = "s"&lt;/code&gt; (explicit string) &lt;em&gt;and&lt;/em&gt; keep the leading single quote so the cell remains inert if a user later opens the &lt;code&gt;.xlsx&lt;/code&gt; in Excel and runs &lt;strong&gt;Save As → CSV&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emit boring, import-safe CSVs:&lt;/strong&gt; UTF-8 with BOM (&lt;code&gt;\ufeff&lt;/code&gt;), &lt;code&gt;CRLF&lt;/code&gt; line endings, &lt;code&gt;MM/DD/YYYY&lt;/code&gt; dates, plain decimals without currency symbols or thousands commas (&lt;code&gt;-53.61&lt;/code&gt;), and &lt;strong&gt;both&lt;/strong&gt; separate &lt;code&gt;Debit&lt;/code&gt;/&lt;code&gt;Credit&lt;/code&gt; columns and a signed &lt;code&gt;Amount&lt;/code&gt; column so QuickBooks Online (3- or 4-column) and Xero import without manual reformatting.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  5. Privacy-First Architecture for Sensitive Financial PDFs
&lt;/h2&gt;

&lt;p&gt;Bank statements expose salaries, landlords, medical providers, and counterparties. We built our security boundary around five explicit constraints:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Browser pre-checks &amp;amp; explicit consent:&lt;/strong&gt; Locally in the browser, &lt;code&gt;pdf.js&lt;/code&gt; validates PDF magic bytes, file size (&lt;code&gt;≤ 4 MB&lt;/code&gt;), page count (&lt;code&gt;≤ 15&lt;/code&gt;), and password protection before any upload. Nothing transmits until the user reviews a plain-English disclosure and consents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero raw-PDF disk storage &amp;amp; isolated worker:&lt;/strong&gt; Uploaded bytes never hit disk or object storage (&lt;code&gt;rawFileStored: false&lt;/code&gt;). The API pipes bytes over &lt;code&gt;stdin&lt;/code&gt; into a short-lived Python subprocess inside a read-only container with &lt;code&gt;RLIMIT_FSIZE=0&lt;/code&gt; and strict CPU, memory, and wall-clock limits. A malformed PDF can only kill the disposable worker, and the PDF bytes vanish from RAM as soon as parsing completes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In-memory local OCR boundary:&lt;/strong&gt; Sending financial PDFs to third-party cloud OCR or LLM vision APIs expands the subprocessor blast radius. For clear scanned PDFs up to &lt;strong&gt;5 pages&lt;/strong&gt;, the same worker renders pages in memory via PDFium (&lt;code&gt;pypdfium2&lt;/code&gt;), writes grayscale PNGs to an &lt;code&gt;io.BytesIO&lt;/code&gt; buffer, and pipes them into local &lt;code&gt;tesseract stdin stdout -l eng --psm 6 tsv&lt;/code&gt;. Word coordinates scale back to 72 DPI and enter the exact same layout parser and dual-chain reconciliation—zero disk writes, zero external APIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dual-factor HKDF crypto-shredding at rest:&lt;/strong&gt; Extracted transactions stay available for up to 24 hours (or until the user clicks &lt;strong&gt;Delete&lt;/strong&gt;) so flagged rows can be reviewed and fixed. Each job is sealed with &lt;code&gt;AES-256-GCM&lt;/code&gt; under a key derived from &lt;strong&gt;both&lt;/strong&gt; the server key and a browser-only &lt;code&gt;HttpOnly&lt;/code&gt; cookie secret:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cryptography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hazmat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primitives&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hashes&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cryptography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hazmat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primitives&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hkdf&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="no"&gt;HKDF&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;job_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;server_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;session_secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;hkdf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HKDF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;algorithm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;hashes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SHA256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"docubridge/job-payload/v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hkdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;derive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session_secret&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"|"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;server_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server never stores &lt;code&gt;session_secret&lt;/code&gt; (it stores only a keyed HMAC lookup hash). Compromising the database alone—or even the database &lt;em&gt;plus&lt;/em&gt; the server key—yields unreadable ciphertext without the user's cookie. Clicking &lt;strong&gt;Delete&lt;/strong&gt; or letting the 24-hour TTL expire crypto-shreds any residual copies.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Strict per-request nonce CSP &amp;amp; zero statement-page trackers:&lt;/strong&gt; Middleware mints a per-request cryptographic nonce (&lt;code&gt;script-src 'self' 'nonce-&amp;lt;random&amp;gt;' 'strict-dynamic'&lt;/code&gt;, &lt;code&gt;connect-src 'self'&lt;/code&gt;, &lt;code&gt;object-src 'none'&lt;/code&gt;, &lt;code&gt;frame-ancestors 'none'&lt;/code&gt;). Zero third-party analytics SDKs, session replay scripts, or ad tags execute on upload or review pages; product telemetry goes through a first-party relay (&lt;code&gt;/api/t&lt;/code&gt;) enforcing allow-listed enum schemas and stripping client IPs.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Closing &amp;amp; Transparent Disclosure
&lt;/h2&gt;

&lt;p&gt;In financial document processing, deterministic accounting invariants (&lt;code&gt;Decimal&lt;/code&gt; math + dual-chain running balance checks) paired with a narrow, auditable security boundary beat "98% accurate" heuristics every time.&lt;/p&gt;

&lt;p&gt;Full disclosure: I built &lt;strong&gt;&lt;a href="https://docubridge.cc/reconcile-bank-statement-in-excel" rel="noopener noreferrer"&gt;DocuBridge&lt;/a&gt;&lt;/strong&gt; (an independent web tool at &lt;code&gt;docubridge.cc&lt;/code&gt;, distinct from unrelated enterprise software sharing that name) using this exact stack. You can inspect the workflow on a built-in synthetic statement or review our plain-English security model here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Balance-checked PDF-to-Excel workflow: &lt;a href="https://docubridge.cc/reconcile-bank-statement-in-excel" rel="noopener noreferrer"&gt;https://docubridge.cc/reconcile-bank-statement-in-excel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Privacy, retention, and security architecture: &lt;a href="https://docubridge.cc/security" rel="noopener noreferrer"&gt;https://docubridge.cc/security&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Current boundaries (stated plainly):&lt;/strong&gt; DocuBridge currently supports single-account &lt;strong&gt;US checking and savings statements in USD only&lt;/strong&gt; (no credit cards or non-US currencies), digital PDFs up to 15 pages (4 MB), and clear scanned PDFs up to 5 pages via in-memory local OCR. Functional access is enabled in the US and South Korea with processing in the United States, and an independent third-party security assessment has not yet been completed (disclosed directly on &lt;code&gt;/security&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;If you have wrestled with messy bank PDFs—or spotted an edge case in dual-chain balance tracking—let's compare notes in the comments.&lt;/p&gt;

</description>
      <category>pythonfintecsecuritywebdevh</category>
    </item>
    <item>
      <title>Stop Overpaying for AI: The 2026 Global Price Index for Claude, ChatGPT &amp; Grok</title>
      <dc:creator>Akuma Vencent</dc:creator>
      <pubDate>Tue, 25 Aug 2026 09:39:33 +0000</pubDate>
      <link>https://dev.to/akuma_vencent_d5795f5572f/stop-overpaying-for-ai-the-2026-global-price-index-for-claude-chatgpt-grok-5dkd</link>
      <guid>https://dev.to/akuma_vencent_d5795f5572f/stop-overpaying-for-ai-the-2026-global-price-index-for-claude-chatgpt-grok-5dkd</guid>
      <description></description>
    </item>
  </channel>
</rss>
