Architecture & Design
This page outlines the technical foundation of the POS application. The project is built with a focus on speed, offline-first reliability, and a modern developer experience.
Feature-Based MVVM
We utilize a Feature-based MVVM (Model-View-ViewModel) structure. By grouping code by functionality rather than technical layers, we ensure that the codebase remains scalable and easy to navigate.
Core Pillars
-
The Composable View
- Built entirely with Jetpack Compose.
- Uses
State Hoistingfor modularity. - Observes
StateFlowfrom the ViewModel for real-time UI updates.
-
The Feature ViewModel
- Manages UI state for specific features (e.g., Payments, History).
- Communicates directly with Room DAOs and Ktor to reduce boilerplate.
- Handles asynchronous tasks via Kotlin Coroutines.
-
Data Sources
- Room Database: Local persistence for transactions and settings.
- Ktor: High-performance networking for terminal communication.
Technical Stack
| Layer | Technology |
|---|---|
| UI | Jetpack Compose (Material 3) |
| Logic | Kotlin Coroutines & Flow |
| DI | Dagger 2 (via KSP) |
| Database | Room SQLite |
| Networking | Ktor Client |
| Animations | Lottie Compose |
Project Structure
com.example.pos_app
├── features # Functional modules (UI + Logic)
│ ├── payment # Checkout UI & Transaction ViewModels
│ └── history # Transaction logs & History ViewModels
├── data # Global Data Engine
│ ├── dao # Room Data Access Objects (SQL Queries)
│ ├── entity # Database Tables / Data Models
│ ├── repository # Data coordination (Local vs Remote)
│ └── utils # Data-related helpers & formatters
├── di # Dependency Injection (Dagger/Hilt)
└── ui.theme # Design System (Color, Type, Theme)