codewithkarani
All topics

Category

Engineering Craft

Every guide on Engineering Craft from Code With Karani - 38 field-tested articles on Engineering Craft for developers and teams.

39 articles

August 2026

  1. One tap at the till, five documents: the submit chain behind ERPNext retail

    I recorded an hour and twenty minutes of UpeoRetail and refused to cut the boring parts, because the eight seconds at the counter is the easy bit. What one submit really writes: stock ledger, GL, a serial and batch bundle, a payment, and two integrations that live outside the transaction.

    15 min read

July 2026

  1. Your spare Android phone is a payment gateway: an offline-first SMS relay for M-Pesa

    M-Pesa till confirmations arrive as an SMS, and Daraja is not open to every merchant. So we turned a spare Android phone into a self-hosted SMS-to-HTTP gateway: encrypted on-device, HMAC-signed on the wire, and built so that it never loses a message.

    14 min read

  2. Six ways Android will eat your background service, and what actually worked

    A broadcast receiver is a lie, WAL journalling wedged openDatabase on OxygenOS, and one polite database close in a WorkManager teardown silently stopped the whole gateway. Six real failure modes from a production Android SMS gateway, and the fix for each.

    16 min read

  3. Exactly-once over an unreliable pipe: HMAC, nonces, and a byte-exact contract

    A per-request nonce and a per-content hash look like the same idea and are not. One says this request arrived twice, the other says this message arrived twice, and a payment pipeline needs both. The signing design behind a production SMS gateway.

    12 min read

  4. Shipping an Android app that can never be on the Play Store

    Play forbids READ_SMS for anything that is not the default SMS handler, so this app was never going to be listed. Then a silent fallback to the debug keystore and a versionCode stuck at 1 turned every update into an uninstall. Two traps, one incident.

    9 min read

  5. The OEM autostart rabbit hole: deep-linking into a dozen undocumented settings screens

    Android has no API for the autostart allowlist your phone's manufacturer invented. So you keep a list of undocumented component names, try them in order, and design the failure case properly, because Transsion, which is enormous in Africa, exposes nothing at all.

    9 min read

  6. A payment source, not a payment parser: what keeping the pipe dumb actually buys

    The SMS gateway could have extracted the M-Pesa transaction code on the phone. It deliberately does not. Here is what that bought, what it cost, and the boundary question every integration eventually has to answer: where does meaning belong?

    11 min read

  7. GitHub Actions from scratch: workflows, jobs, steps and triggers

    A workflow file is four ideas stacked on each other. Learn them in the right order, understand why push to main is the wrong deployment trigger, and you can write your first deploy pipeline today.

    8 min read

  8. Access is a liability, not a convenience

    Every SSH key you hold on a client's server is a credential you now have to defend, insure and explain. The strongest position in an enterprise procurement conversation is not having it at all.

    8 min read

  9. Error 1055: MySQL 5.7 Rejected the GROUP BY Query That Worked for Years

    ONLY_FULL_GROUP_BY is on by default in MySQL 5.7 and it broke half the reports in a legacy app. Why the old query was always wrong, and the four ways to fix it ranked by regret.

    7 min read

  10. Python 2 Dies in January: The Migration Plan I Wish I Had Started Sooner

    Python 2 reaches end of life on 1 January 2020. Here is the order I move a real codebase in, the bugs that only appear in production, and what to do if you truly cannot finish.

    6 min read

  11. Git for Two: The Branching Model a Small Team Actually Needs

    Git Flow is costume jewellery for a two-person team. Here is the smallest workflow that stops you clobbering each other: short-lived branches, protected main, rerere, squash merges, and revert-forward.

    8 min read

  12. Docker, Finally: A Practical On-Ramp for Developers Who Kept Putting It Off

    You are not scared of containers, you are tired of the vocabulary. The mental model in four sentences, four commands, a real multi-stage Dockerfile, a Compose v2 file, and the five things that will confuse you.

    7 min read

  13. Ship to Your Own VPS: GitHub Actions CI/CD Without the Cloud Bill

    A complete pipeline for a 10-dollar server: test, build to GHCR, deploy over SSH, health check, roll back. Real workflow YAML with current action versions, plus the details that quietly break deploys.

    7 min read

June 2026

  1. Six API Design Mistakes That Will Cost You Six Months

    API mistakes are expensive because they are public. Status codes in the body, offset pagination, contradictory booleans, leaked schemas, no versioning plan, and float money - with the fixes that are free today.

    8 min read

  2. Your Migration Will Run Twice: Write It That Way

    Retried deploys, scaled replicas and tired humans all re-run migrations. Advisory locks, idempotent DDL, resumable batched backfills, the CREATE INDEX CONCURRENTLY trap, and a CI check that runs it three times.

    7 min read

  3. How to Read a Codebase You Did Not Write, Without Panicking

    Never try to understand a codebase. Answer one question about it and let understanding be a side effect. Run it first, find the edges, trace one request, read the schema, and mine Git history for the answers.

    8 min read

  4. React Native Version Mismatch: Rebuilding Is Only Half the Fix

    The redbox compares two build artefacts, not two package.json entries, and only major.minor. How to find which side is stale, pin react correctly, and stop it recurring.

    9 min read

May 2026

  1. Daraja Error 1032 'Request Cancelled by User' Is Not a Bug in Your M-Pesa Integration

    M-Pesa STK Push ResultCode 1032 means the customer pressed Cancel, not that anything broke. Stop paging on it and handle it as the user action it is.

    6 min read

  2. CI Auto-Retry Is Hiding Your Flaky Tests, Not Fixing Them

    Retry-on-failure keeps CI green by throwing away the one thing you need to diagnose flakiness. Here is how to make flakes visible, quarantine them, and root-cause the real nondeterminism.

    9 min read

  3. pytest-asyncio 'event loop is already running': there is no patch coming

    request.getfixturevalue() on an async fixture crashes pytest-asyncio, nest_asyncio no longer saves you, and upstream has no fix. Here is the test architecture that works instead.

    9 min read

  4. Testing Payment Integrations When the Sandbox Itself Is Flaky

    M-Pesa, Stripe and Paystack callbacks are where payments break, and the sandbox that fires them is unreliable. Stop chasing it: record the payloads once and test your handler against fixtures.

    7 min read

April 2026

  1. How to Actually Read a Stack Trace: Finding Your Code in the Noise

    Stop reading stack traces top to bottom. Find the deepest frame in your own code, read direction by language, and turn a wall of red text into a two-minute fix.

    7 min read

  2. Laravel 419 Page Expired in Production: A Diagnostic Order, Not a Fix List

    The intermittent Laravel 419 TokenMismatchException has five common causes that look identical. Here is the order to diagnose them so you fix it once.

    9 min read