Appearance
Architecture Overview: Microtec POS โ
This document provides a technical deep-dive into the architecture of Microtec POS, an offline-first POS application built with Flutter. It explains the layers, state management, and specialized multi-window logic used to support Customer Display Systems (CDS).
๐๏ธ 1. Clean Architecture Layers โ
The project follows a standard Clean Architecture approach, ensuring separation of concerns and testability.
๐ข Presentation Layer (lib/presentation/) โ
- UI: Flutter Widgets, pages, and components.
- State Management: BLOC (via
flutter_bloc). BLOCs interact with Domain layer use-cases and emit states for the UI to consume. - Views: Includes specialized views for CDS (Customer Display Systems) on both Windows and Tablet platforms.
๐ง Domain Layer (lib/domain/) โ
- Entities: Pure business logic objects.
- Use Cases: Application-specific business rules.
- Repository Interfaces: Abstract definitions of data operations, to be implemented in the Infra layer.
๐พ Infrastructure Layer (lib/infra/) โ
- Repositories: Concrete implementations of Domain repositories.
- Data Sources:
- Local: ObjectBox (NoSQL) for high-performance offline storage.
- Remote: REST API (via
Dio) for cloud sync. - Real-time: gRPC/Protobuf for KDS/CDS communication.
๐งช 2. State Management & DI โ
BLOC Pattern โ
We use BLOC for all state-heavy features. Each business module (Auth, Sales, Tables, Sync) has its own BLOC.
- Events: Represent user actions or system triggers.
- States: Immutable representations of the UI at a specific point in time.
Dependency Injection โ
- GetIt & Injectable: Used for automatic dependency injection.
- Service Locator: Initialized in
lib/di/service_locator.dart. configureDependencies(): Asynchronous setup called at app startup to register all services and repositories.
๐ฅ๏ธ 3. Multi-Display & CDS Logic โ
The application supports dual-screen setups (Windows Desktop) and secondary tablets for Customer Display Systems (CDS).
Windows Multi-Window โ
- Managed via the
desktop_multi_windowpackage. - The entry point (
lib/main.dart) detects themulti_windowargument and launches a separateWindowsCdsViewinstance. - Communication: Local JSON-based messages are used to sync the main sale window with the customer display.
Tablet CDS โ
- A dedicated
TabletCdsViewis provided for cases where the customer display is a separate Android tablet. - Sync: Real-time communication is handled via gRPC to ensure the customer sees item updates instantly.
๐ก 4. Data Synchronization โ
The app uses an offline-first strategy:
- Local Writes: All transactions are first written to the ObjectBox store.
- Background Sync: Dedicated sync managers (
lib/application/web_sync/) monitor local changes and push them to the cloud via REST APIs. - Conflict Resolution: Business-date-based logic ensures that shifts spanning across midnight are synchronized accurately without data loss.
โ๏ธ 5. Monitoring & Error Handling โ
- Sentry: integrated into
lib/main.dartviarunZonedGuarded. It captures all unhandled exceptions and performance traces. - Custom Logging: A
LogManagertracks application events locally for diagnostic purposes.
For business-level feature descriptions, see APP_SPECIFICATIONS.md.