Engineering case
Order dispatch with debt accounting
Orders for hired workers: dispatch, statuses, disputes and payout maths. One file, the standard library and a single external dependency.
- external dependency
- 1
Money operations are race-safe: a payout runs under a lock that re-checks the current debt, so a double click cannot pay twice, and reassigning an order marks the original through a compare-and-set. An access request is claimed atomically by exactly one manager.
Undelivered messages are handled by cause rather than as one generic error: when the text is too long there is no «Retry» button, because retrying will not help. When Telegram did not answer at all, the order stays active — the message may well have arrived.
Python · SQLite (WAL) · Telegram Bot API · http.server