$ show codebutler/farebot
FareBot is a Kotlin Multiplatform (KMP) application designed to read, parse, and analyze contactless transit smart cards (NFC/RFID). It targets Android, iOS, Desktop (JVM), and Web (Wasm), utilizing Jetpack Compose Multiplatform for the UI layer. The core functionality involves interacting with NFC hardware (Android NFC, PC/SC, CoreNFC) or external devices (Flipper Zero, PN533 USB readers) to extract raw card data. This data is then processed through a layered architecture of protocol readers (MIFARE Classic, DESFire, FeliCa, ISO7816) and transit-specific factories (EN1545, Calypso, proprietary formats) to display balances, trip history, and card identity. The architecture relies heavily on the Factory pattern to support hundreds of global transit systems without modifying core logic. It uses SQLDelight for local persistence of card dumps and keys, and Metro for dependency injection. The codebase demonstrates significant craftsmanship in reverse-engineering proprietary transit protocols, handling complex binary formats, bit-level parsing, and currency normalization across different regions. Hardware abstraction layers (`CardTransceiver`, `FlipperTransport`) allow the same core logic to run across diverse platforms and devices. While the application is actively maintained (last commit 2026-03-22), it faces technical drift risks due to its reliance on experimental Web APIs (WebUSB/WebBluetooth), cutting-edge Gradle versions (9.3.1), and the inherent fragility of reverse-engineered transit protocols. The project is a robust example of cross-platform hardware interaction and data parsing, suitable for engineers interested in NFC protocols, KMP architecture, and hardware abstraction.
The LLM identified 4 files worth highlighting for reuse:
Defines the `TransitFactory` interface which standardizes card detection (`check`) and parsing (`parseInfo`, `parseIdentity`) across hundreds of transit systems. This component is highly reusable as it allows new transit systems to be added as independent modules without touching the core application logic. It demonstrates non-obvious skill in handling diverse data structures (balances, trips, subscriptions) through a unified interface.
Implements the MIFARE Classic protocol, handling sector authentication, block reading, and key management. This component encapsulates complex NFC communication logic and is safely reusable for any MIFARE Classic interaction. It demonstrates skill in low-level binary manipulation and security key handling (static keys, unauthorized sectors).
Provides a communication layer for the Flipper Zero hardware device via USB Serial and BLE. It abstracts the RPC protocol details, allowing the application to offload card reading tasks to the Flipper. This component is reusable for any hardware device requiring serial communication and demonstrates robust error handling and transport abstraction.
Manages the Metrodroid Station Table (MDST) data for resolving station IDs to names and locations. It abstracts the binary file format and provides a clean API for station lookups across different transit systems. This component solves a recurring data problem (station mapping) and is easily adaptable to different station database formats.