<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohamed Hamed</title>
    <description>The latest articles on DEV Community by Mohamed Hamed (@m7amedenho).</description>
    <link>https://dev.to/m7amedenho</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4111341%2F5408637b-27da-4830-ae33-f3cdade465a4.jpg</url>
      <title>DEV Community: Mohamed Hamed</title>
      <link>https://dev.to/m7amedenho</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/m7amedenho"/>
    <language>en</language>
    <item>
      <title>Building a Fully Offline-First Flutter App for ERPNext: The RedLine Architecture and Sync Engine</title>
      <dc:creator>Mohamed Hamed</dc:creator>
      <pubDate>Sat, 05 Sep 2026 15:56:04 +0000</pubDate>
      <link>https://dev.to/m7amedenho/building-a-fully-offline-first-flutter-app-for-erpnext-the-redline-architecture-and-sync-engine-23a6</link>
      <guid>https://dev.to/m7amedenho/building-a-fully-offline-first-flutter-app-for-erpnext-the-redline-architecture-and-sync-engine-23a6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction: The Field Sales Connectivity Problem
&lt;/h2&gt;

&lt;p&gt;One of the most persistent challenges in enterprise software development is bridging the gap between a centralized backend system and field employees operating in areas with poor or zero internet connectivity. &lt;/p&gt;

&lt;p&gt;For field sales representatives, an inability to connect to the company's ERP means lost sales, delayed data entry, and frustrated customers. To solve this, &lt;strong&gt;Red Tech For Technology&lt;/strong&gt; developed &lt;strong&gt;RedLine&lt;/strong&gt;—an open-source, fully offline-first mobile application built with &lt;strong&gt;Flutter&lt;/strong&gt;, deeply integrated with the &lt;strong&gt;ERPNext / Frappe&lt;/strong&gt; ecosystem.&lt;/p&gt;

&lt;p&gt;This article breaks down the architecture, technical stack, and core features of RedLine, serving as a comprehensive guide on how to build robust offline-capable apps for ERPNext.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is RedLine?
&lt;/h2&gt;

&lt;p&gt;RedLine is a mobile extension of an ERPNext deployment tailored specifically for field sales teams in the MENA region. Featuring a native Arabic (RTL) interface, it empowers sales representatives to create documents, collect payments, log GPS-tagged visits, and track approvals directly from their smartphones, without needing a continuous server round-trip.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgkquwv8t0dinpn9hru4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgkquwv8t0dinpn9hru4g.png" alt=" " width="428" height="962"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6tflic5h8x3w9hf7yfmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6tflic5h8x3w9hf7yfmh.png" alt=" " width="429" height="960"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi0zl3wyo44chvsjg0dm3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi0zl3wyo44chvsjg0dm3.png" alt=" " width="434" height="965"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2dpmn0zi82stcisyxhyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2dpmn0zi82stcisyxhyc.png" alt=" " width="434" height="971"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fquij671ir8h1kqfnb8n5.png" alt=" " width="433" height="976"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Technical Stack &amp;amp; Architecture
&lt;/h2&gt;

&lt;p&gt;Building a true offline-first application requires a solid foundation for local storage and intelligent network handling.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Framework:&lt;/strong&gt; Flutter (stable channel, Dart SDK ^3.12.2)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Backend:&lt;/strong&gt; ERPNext / Frappe (REST and RPC APIs)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Local Storage (Database):&lt;/strong&gt; Drift (SQLite) for managing the offline queue and reference-data caching.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Networking:&lt;/strong&gt; Dio (with automatic session-refresh handling).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Connectivity:&lt;/strong&gt; &lt;code&gt;connectivity_plus&lt;/code&gt; backed by a custom &lt;strong&gt;real server reachability check&lt;/strong&gt;, preventing false-positive network signals.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Core Libraries:&lt;/strong&gt; &lt;code&gt;flutter_secure_storage&lt;/code&gt;, &lt;code&gt;geolocator&lt;/code&gt;, &lt;code&gt;printing/pdf&lt;/code&gt;, &lt;code&gt;local_auth&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Offline-First Sync Engine: How It Works
&lt;/h2&gt;

&lt;p&gt;The crown jewel of RedLine is its offline synchronization engine. Unlike basic caching, RedLine implements a &lt;strong&gt;Full Offline Queueing System&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Action Queueing:&lt;/strong&gt; When a user creates a Sales Order, Customer Visit, Material Request, Customer Registration, or Expense Claim without an internet connection, the action is serialized and stored in the local Drift SQLite database.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Reachability Verification:&lt;/strong&gt; The app does not blindly trust the device's network interface. It actively pings the server to ensure a live, stable connection before attempting synchronization.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Sequential Auto-Retries:&lt;/strong&gt; Once connectivity is confirmed, queued actions are automatically retried in chronological order. &lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Sync Queue UI:&lt;/strong&gt; A dedicated screen allows users to view pending, failed, or completed actions, complete with manual retry and discard controls.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Offline Media:&lt;/strong&gt; Photos taken offline (e.g., visit proofs) are stored locally, uploaded upon reconnection, and automatically flushed from device storage to save space.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Read-Through Caching:&lt;/strong&gt; Reference data like Customer Statements and Due Invoices are cached locally with a clear "last updated" timestamp.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Note on Financial Integrity:&lt;/em&gt; Operations requiring absolute concurrent accuracy—like invoice creation, payment collection, and immediate stock transfers—are intentionally locked as online-only to prevent conflicting updates (e.g., bypassing a shared credit limit).&lt;/p&gt;




&lt;h2&gt;
  
  
  Comprehensive Feature Breakdown
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Sales and Order Management
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Sales Orders:&lt;/strong&gt; Create, edit, and track orders with automatic, strict credit-limit validation against the customer's outstanding balance.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Sales Invoices:&lt;/strong&gt; Supports immediate stock deduction, return processing, and payment-schedule management.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;On-Device PDF Generation:&lt;/strong&gt; Instantly generate and share PDFs for orders and invoices locally, requiring zero server processing.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;GPS Validation:&lt;/strong&gt; Geographic coordinates are captured and attached to transactions as verifiable proof of origin.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Payments &amp;amp; Treasury
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Payment Entries:&lt;/strong&gt; Collect payments against outstanding invoices while properly managing payment-term due dates and treasury allocations (cash/bank/mode of payment).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Role-Based Discounting:&lt;/strong&gt; Document-level and per-item discounts are gated; only region managers can edit them based on configurable limits, keeping them hidden from standard reps.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Treasury Views:&lt;/strong&gt; Detailed treasury statements track cash and bank movements seamlessly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Customer CRM &amp;amp; Field Operations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Customer Management:&lt;/strong&gt; GPS-tagged registration, credit limit display, price lists, and payment term configurations. Filtered heavily by territory mapping.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Account Statements:&lt;/strong&gt; Full GL-based customer statements with expandable transaction details and PDF exports.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Visit Logging:&lt;/strong&gt; Log visits, collections, or reactivations with GPS enforcement and an interactive calendar view. Tracks overdue customers based on configurable territory rules.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Two-Leg Warehouse Transfers:&lt;/strong&gt; Reps can initiate Material Requests, warehouse keepers prepare shipments, and reps confirm receipt directly from the app.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Expense Claims:&lt;/strong&gt; Integrated vehicle logging (fuel/maintenance) and personal expenses with auto-resolution of approvers and payable accounts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Workflows &amp;amp; Approvals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;ERPNext Workflow Support:&lt;/strong&gt; Full compatibility with Frappe's native multi-level approval chains (Region Manager ➔ Accounts ➔ General Manager) utilizing role-based transitions.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Notification Center:&lt;/strong&gt; A unified, generic pending-approvals screen for bulk actions, paired with an in-app notification center (backed by Frappe’s Notification Log).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Advanced Dashboards
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Rep Dashboard:&lt;/strong&gt; Quick actions and recent-activity feeds.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Team Dashboard (Managers):&lt;/strong&gt; Region managers access independently sortable metrics per rep (sales, collections, outstanding debt, visit counts) ensuring a granular view of team performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Enterprise-Grade Security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Domain-based login against ERPNext instances.&lt;/li&gt;
&lt;li&gt;  Secure token management via &lt;code&gt;flutter_secure_storage&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Biometric unlock (fingerprint/FaceID) integration for rapid, secure field access.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Open Source &amp;amp; Contribution
&lt;/h2&gt;

&lt;p&gt;We strongly believe in contributing back to the ERPNext and Flutter communities. RedLine is open-source and released under the &lt;strong&gt;GPL-3.0 License&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Currently, the UI is Arabic (RTL) focused. We invite the community to explore the architecture, test the offline engine, and help us implement English (LTR) localization (i18n).&lt;/p&gt;

&lt;p&gt;🔗 **Check out the repository on GitHub: &lt;a href="https://github.com/m7amedenho/Redline-Representative-App-ERPNEXT" rel="noopener noreferrer"&gt;https://github.com/m7amedenho/Redline-Representative-App-ERPNEXT&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are an ERPNext implementer or a Flutter developer, we would love your feedback, bug reports, and pull requests!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Let’s build the ultimate offline mobile tool for the Frappe ecosystem, together.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>erpnext</category>
      <category>flutter</category>
      <category>offlinefirst</category>
      <category>dart</category>
    </item>
  </channel>
</rss>
