$ show capcom6/android-sms-gateway
This is an Android application that turns a smartphone into an SMS/MMS gateway. It exposes a local REST API (Ktor-based HTTP server) for sending and receiving messages, supports cloud server integration via Firebase and Server-Sent Events, and provides webhook delivery, end-to-end encryption (RSA-OAEP + AES-GCM), and device key rotation. The architecture is modular: foreground services (SSE, ping, local server), WorkManager workers for background tasks (message sending, webhook queue processing, inbox upload, settings sync), a Room database for persistence, and Koin for dependency injection. The codebase is well-structured with event-driven communication via a custom EventBus, a validated state machine for message lifecycle, encrypted storage, and rich UI fragments. It supports SMS, MMS, and data SMS, with inbound message capture via broadcast receivers and content observers.
The LLM identified 3 files worth highlighting for reuse:
Implements a per-key mutex using coroutines, ensuring that operations on the same key (e.g., message ID) are serialized without blocking other keys. The pattern is isolated and can be extracted into any project that requires concurrent, key-scoped locking without shared global state.
Defines a table-driven state machine for message and recipient lifecycle transitions (e.g., Pending -> Sent -> Delivered -> Failed). It validates each transition against a pre-defined map, making it easy to extend and reuse in any system requiring guarded state changes.
A clean interface for encryption/decryption operations with multiple implementations (RSA, passphrase-based). It abstracts cryptographic details behind a simple contract, enabling easy swapping of algorithms and reuse in other applications needing pluggable encryption.