A production-grade Android Point-of-Sale system built for Tier 1 FinTech portfolios. Demonstrates multi-module Clean Architecture, NFC payment flows, offline-first sync, and Bluetooth thermal printing.
| Feature | Status |
|---|---|
| NFC tap-to-pay (HCE) | ✅ |
| Card / PIN payment flow | ✅ |
| Cash payment + change calculation | ✅ |
| QR code payment | ✅ |
| Split-bill support | ✅ |
| Bluetooth ESC/POS thermal printing | ✅ |
| Offline-first (Room → WorkManager sync) | ✅ |
| Barcode scanner (CameraX + ML Kit) | ✅ |
| Sales dashboard with charts (Live Room DB + Custom Canvas) | ✅ |
SwiftPOS is designed with enterprise FinTech standards in mind:
- NFC Host Card Emulation (HCE): Simulates payment card communications using Android's HCE APIs for contactless checkout.
- EMV State-Driven Lifecycle: Modeled using a strict, unit-tested MVI state machine supporting card reads, PIN limits, floor-limit contactless bypasses, and refund validations.
- Idempotency Protection: Integrated unique key generation and checking logic at the state-transition level to guarantee zero duplicate payment submissions.
- Peripheral Printing: Built-in ESC/POS formatting layer to encode transaction receipts directly into binary command layouts for Bluetooth thermal printers.
- Offline Settlement: Local-first transaction persistence with WorkManager sync policies to handle transactions in low-connectivity retail environments.
SwiftPOS/
├── app/ # Entry point — Hilt, MainActivity, Navigation
├── core/
│ ├── core-domain/ # Pure Kotlin — models, repository interfaces, use cases
│ ├── core-data/ # Room, Retrofit, repository implementations
│ └── core-ui/ # Shared Compose components & theme
├── payment/ # PaymentStateMachine, NFC HCE, Checkout & Receipt UI
├── catalog/ # Product grid, barcode scanner, inventory
├── dashboard/ # Sales charts, transaction history, end-of-day report
└── peripheral/ # Bluetooth printer, ESC/POS encoder, cash drawer
### Data Flow
UI (Compose Screen) ↓ collects StateFlow ViewModel ↓ delegates to PaymentStateMachine ← State: Idle → AwaitingPayment → WaitingForCard ↓ emits effects → Processing → Approved / Declined Repository (interface) ↓ Room (local) + Retrofit (remote) AppDatabase ←→ WorkManager (background sync when online)
---
## 🧩 Tech Stack
| Layer | Library |
|---|---|
| UI | Jetpack Compose + Material 3 |
| State | StateFlow + MVI pattern |
| DI | Hilt (Dagger) |
| Database | Room 2.6 |
| Networking | Retrofit + OkHttp |
| Background | WorkManager |
| Testing | JUnit4 + MockK + Turbine |
| Build | Gradle KTS + build-logic convention plugins |
---
## 🧪 Tests
```bash
# Run all unit and architectural tests
./gradlew test
# Run payment module tests only (using Kotest Assertions)
./gradlew :payment:test
# Run architectural consistency checks (using Konsist)
./gradlew :app:test --tests "com.example.swiftpos.ArchitectureConsistencyTest"
- Kotest Assertions: High-readability, expressive assertions (
shouldBe,shouldBeTypeOf,shouldThrow) for domain/logic rules. - Konsist: Structural architectural check framework ensuring code formatting, encapsulation rules, and Clean Architecture dependencies hold true.
- Turbine & Coroutines Test: Flow collection and testing of asynchronous reactive states.
- 14 Behavior Tests: Under
:paymentverifying checkout state transitions, timeouts, PIN rules, and refund bounds. - Architectural Safety Tests: Under
:appchecking that ViewModels reside in UI feature modules and core-domain layer remains pure Kotlin.
git clone https://github.com/mohameddaoudmo/SwiftPOS.git
cd SwiftPOS
./gradlew assembleDebugRequirements:
- Android Studio Narwhal or later
- JDK 17
- Android device or emulator with API 30+
MIT License — free to use for portfolio and learning purposes.