Skip to content

mohameddaoudmo/SwiftPOS

Repository files navigation

SwiftPOS 🏪

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.

CI API Kotlin Architecture


✨ Features

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)

💳 FinTech & EMV Payment Core

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.

🏗️ Architecture

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"

Frameworks Used

  • 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.

Coverage

  • 14 Behavior Tests: Under :payment verifying checkout state transitions, timeouts, PIN rules, and refund bounds.
  • Architectural Safety Tests: Under :app checking that ViewModels reside in UI feature modules and core-domain layer remains pure Kotlin.

🚀 Getting Started

git clone https://github.com/mohameddaoudmo/SwiftPOS.git
cd SwiftPOS
./gradlew assembleDebug

Requirements:

  • Android Studio Narwhal or later
  • JDK 17
  • Android device or emulator with API 30+

📄 License

MIT License — free to use for portfolio and learning purposes.

About

A production-grade Android POS system showcasing Multi-Module Clean Architecture, NFC tap-to-pay (HCE), EMV state lifecycles, idempotency guards, and offline settlement.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages