How milasantacruz/salesmate works
Project Type and Purpose
• This is a cross-platform mobile application built with Flutter (Dart) for order management, integrating bidirectionally with an Odoo ERP back-end and a small WebAdmin API. It supports offline mode (Hive) and real-time sync (JSON-RPC).
High-Level Architecture from File Structure
• Top-level “android/”, “ios/”, “linux/”, “macos/”, “windows/”, “web/” folders: platform runners generated by Flutter.
• “lib/” holds the core of the app, divided into three layers:
• core/ – low-level services (network, cache, DI, HTTP clients, constants, error handling)
• data/ – models (Odoo entities) and repositories (data access, offline/remote)
• presentation/ – UI layer (pages, widgets) and state management (BLoC)
• Root files: proxy_server.js (Node proxy), package.json (Node), flutter entry point main.dart.
Key Insights from README
• State Management: BLoC pattern
• Dependency Injection: GetIt
• Local Cache: Hive
• HTTP Layer: Odoo JSON-RPC (sale.order, res.partner, etc.) and WebAdmin REST endpoints
• Offline-First with bidirectional sync
Main Components
a. Presentation Layer
• Flutter UI (Pages & Widgets)
• BLoC Controllers (AuthBloc, ProductBloc, SaleOrderBloc, etc.)
b. Domain/Data Layer
• Repositories (PartnerRepository, SaleOrderRepository, OfflineOdooRepository)
• Data Models (PartnerModel, SaleOrderModel…)
c. Core Services
• Dependency Injection Container (injection_container.dart)
• Network Connectivity Monitor (network_connectivity.dart)
• HTTP Clients (OdooClientMobile/Web/Stub, SessionInterceptor)
• Cache Service (Hive wrappers)
d. External Services
• Odoo ERP JSON-RPC API
• WebAdmin REST API
• Optional: Local Node.js proxy (proxy_server.js)
e. Platform Runners (Android, iOS, etc.) – bootstrap the Flutter engine
Interactions and Data Flow
• UI widgets dispatch Events → BLoCs
• BLoCs resolve Dependencies via GetIt → invoke Repository methods
• Repositories consult:
• Cache layer (Hive)
• HTTP layer (Odoo JSON-RPC or WebAdmin)
• Offline repository for queued operations
• SessionInterceptor attaches session tokens to HTTP calls
• Network monitor toggles offline/online strategies
• Responses flow back up: Repository → BLoC → UI
Architectural Patterns & Design Principles
• Layered Architecture (Presentation → Domain/Data → Core → External)
• BLoC for unidirectional data flow
• Repository pattern for data access abstraction
• Dependency Injection for decoupling and testability
• Offline-First caching strategy with synchronization logic