Beyond Offline Mode: Engineering a Field Sales Mobile App for ERPNext with Flutter
Building RedLine: An Offline-First Mobile Experience for ERPNext Sales Representatives
Field sales teams rarely work in ideal network conditions.
Sales representatives visit customers, create orders, collect payments, check outstanding balances, and move between warehouses. They often work in areas where internet connectivity is unreliable or completely unavailable.
For an ERP system like ERPNext, this creates a practical challenge: how can field employees continue working without constantly depending on a live connection to the central server?
This was the problem we wanted to solve when building RedLine, an open-source Flutter mobile application designed specifically for ERPNext field sales operations.
In this article, I'll explain the architecture behind RedLine, the technology choices, the offline synchronization engine, and some of the engineering decisions we made to handle real-world business operations.
1. The Problem: ERPNext in the Field
ERPNext provides a powerful business management platform, but field sales operations introduce requirements that are different from traditional desktop workflows.
Consider a typical sales representative's day:
- Visiting customers across different locations.
- Checking customer balances and outstanding invoices.
- Creating sales orders.
- Registering new customers.
- Recording customer visits.
- Submitting expense claims.
- Requesting stock transfers.
- Collecting payments.
Now imagine the representative loses internet connectivity halfway through the day.
A conventional mobile application that depends on API requests for every action becomes almost useless.
We wanted RedLine to provide a different experience.
The application should remain useful even when the server is unavailable.
This led us to adopt an offline-first architecture rather than simply adding caching to a traditional online application.
2. What Is RedLine?
RedLine is an open-source mobile extension for ERPNext, developed by Red Tech For Technology.
It is built with Flutter and designed for field sales representatives and their managers.
The application integrates directly with ERPNext and provides a mobile interface for daily sales and field operations.
Its main capabilities include:
- Sales order management.
- Sales invoice management.
- Customer registration and management.
- Customer account statements.
- Payment collection.
- GPS-tagged customer visits.
- Warehouse transfer requests.
- Expense claims.
- Approval workflows.
- Notifications.
- Representative and manager dashboards.
The interface currently supports Arabic (RTL) only. English (LTR) localization is not available yet.
3. Technology Stack
We selected technologies that provide a balance between performance, reliability, and maintainability.
| Component | Technology | Purpose |
|---|---|---|
| Mobile Framework | Flutter | Cross-platform mobile application |
| Language | Dart | Application development |
| Backend | ERPNext / Frappe | Business logic and data |
| Local Database | Drift / SQLite | Offline storage and action queue |
| HTTP Client | Dio | API communication |
| Connectivity | connectivity_plus | Network state monitoring |
| Secure Storage | flutter_secure_storage | Secure credential storage |
| Location | geolocator | GPS functionality |
| PDF Generation | Flutter PDF libraries | On-device document generation |
| Authentication | ERPNext authentication | User authentication and sessions |
One important decision was to use Drift instead of relying entirely on in-memory state or temporary local storage.
Drift provides a structured SQLite-based persistence layer, which is essential when queued operations must survive application restarts.
4. The Offline-First Architecture
This is probably the most important part of RedLine.
A common approach to offline support is to cache API responses and display them when the device loses connectivity.
However, this does not solve the problem of creating new transactions offline.
We needed a system capable of storing user actions locally and synchronizing them with ERPNext when connectivity returned.
Our architecture separates local operations from remote synchronization.
Local Database
RedLine uses Drift (SQLite) to store:
- Cached reference data.
- Pending operations.
- Synchronization status.
- Local media references.
- Operation metadata.
When a supported action is performed offline, the application stores the operation locally instead of immediately sending an HTTP request.
Action Queue
For example, when a representative creates a Sales Order without an internet connection:
- The representative completes the order form.
- The application validates the available local information.
- The operation is serialized.
- The operation is saved in the local SQLite database.
- The interface displays its synchronization status.
- The synchronization engine processes it when the server becomes reachable.
This approach allows the user to continue working without waiting for a server response.
Server Reachability
One lesson we learned is that detecting an active network connection is not the same as confirming that the ERPNext server is reachable.
A device might be connected to Wi-Fi while the server is down.
For this reason, RedLine combines connectivity monitoring with an actual server reachability check.
The synchronization engine does not start simply because the operating system reports an active network connection.
Sequential Synchronization
Queued operations are processed sequentially in chronological order.
This helps preserve the intended order of operations and makes synchronization behavior easier to track and debug.
The application also provides a dedicated synchronization screen where users can:
- View pending operations.
- Identify failed operations.
- Check completed synchronization.
- Retry failed operations manually.
- Discard operations when appropriate.
5. Handling Financial Integrity
Offline-first applications introduce an important challenge: not every business operation is safe to execute offline.
For example, consider two representatives attempting to sell the same inventory or a representative trying to collect a payment against an invoice whose balance has already changed.
Local data may be outdated.
If the application blindly accepts every financial transaction offline, it can create inconsistencies between the mobile application and ERPNext.
We therefore distinguish between operations that can safely be queued and operations that require immediate server validation.
Supported offline operations include:
- Sales order creation.
- Customer registration.
- Material requests.
- Customer visit logging.
- Expense claim submission.
Operations requiring an online connection include:
- Financial transactions requiring current server validation.
- Payment collection.
- Operations involving immediate stock updates or transfers.
The exact availability of each operation depends on the business rules and validation requirements.
Our goal is not to make every operation available offline at any cost. It is to provide offline functionality without compromising financial integrity.
6. Sales and Customer Management
RedLine provides a mobile workflow for representatives to manage their customers and sales activities.
Sales Orders
Representatives can create and manage sales orders with:
- Customer selection.
- Item selection.
- Quantity and pricing.
- Warehouse information.
- Credit-limit validation.
- Order tracking.
The application also supports generating PDF documents directly on the device.
Customer Management
Customer management includes:
- Customer registration.
- GPS-tagged registration.
- Customer credit limits.
- Price lists.
- Payment terms.
- Territory-based filtering.
This makes it easier for representatives to manage their assigned customer base.
Customer Account Statements
Representatives can review customer financial activity through account statements.
The application provides expandable transaction details and PDF export capabilities.
Where appropriate, cached information is displayed with its last synchronization timestamp to help users understand how current the data is.
7. Payments and Treasury
Managing collections is an important part of field sales.
RedLine integrates payment workflows with ERPNext Payment Entries.
The application supports payment-related information such as:
- Outstanding invoices.
- Payment terms.
- Due dates.
- Cash and bank accounts.
- Modes of payment.
- Treasury statements.
We also implemented role-based discount controls.
For example, document-level and item-level discounts can be restricted to authorized regional managers rather than being available to every sales representative.
This helps maintain better control over pricing policies.
8. GPS-Based Field Operations
For organizations that depend on field sales teams, knowing where and when customer interactions happen can be valuable.
RedLine integrates GPS functionality into field operations.
Representatives can:
- Register customer visits.
- Record collection visits.
- Log customer reactivation.
- Attach geographic coordinates to supported activities.
- Review visits through an interactive calendar.
GPS information can also be used as part of customer registration and transaction validation.
Location permissions are handled through the mobile application rather than treating GPS as an unrestricted background capability.
9. Warehouse Transfers
Another important workflow is transferring inventory between warehouses and sales representatives.
RedLine supports a two-stage transfer workflow:
- The sales representative initiates a Material Request.
- The warehouse keeper prepares the shipment.
- The representative confirms receipt through the application.
This provides a clearer workflow between warehouse operations and field sales teams.
10. Workflows and Approvals
ERPNext provides a native workflow engine, and we wanted RedLine to work with that existing functionality instead of introducing a separate approval system.
The application supports multi-level approval chains.
A typical example might look like:
Sales Representative → Regional Manager → Accounts → General Manager
Authorized users can review pending requests and perform available workflow transitions.
We also implemented a unified pending-approvals screen and an in-app notification center backed by Frappe's Notification Log.
This allows employees to follow their assigned approval tasks without constantly switching to the ERPNext Desk interface.
11. Manager Dashboards
RedLine is not limited to individual sales representatives.
Regional managers can access team-level information and monitor the performance of their representatives.
The dashboard includes metrics such as:
- Sales performance.
- Collections.
- Outstanding customer debt.
- Customer visit counts.
- Individual representative activity.
Managers can independently sort and review representative metrics.
This provides a more practical overview of field operations from a mobile device.
12. Security Considerations
A mobile application connected to an accounting and ERP system must treat security as a core requirement.
RedLine includes several security-related features:
- Domain-based login against ERPNext instances.
- Secure session and token storage.
- Role-based access to application functionality.
- ERPNext permission and workflow integration.
- Biometric authentication for local application unlocking.
We also designed financial and administrative operations around the permissions available to the authenticated ERPNext user.
Biometric authentication is intended to protect access to the application on the device; it does not replace server-side authorization.
The ERPNext server remains responsible for validating access to business data and operations.
13. Lessons Learned
Building RedLine taught us several important lessons about offline-first enterprise applications.
1. Network connectivity is not server availability.
A device can have internet access while the ERPNext server is unreachable. A real reachability check is necessary.
2. Offline support is more than caching.
A reliable offline application needs persistent local data, an action queue, synchronization policies, and clear failure handling.
3. Not every operation should be available offline.
Financial integrity is more important than allowing every transaction to be created without connectivity.
4. Synchronization needs visibility.
Users should understand what is pending, what failed, and what has been synchronized.
5. Mobile workflows should be designed around actual users.
Field representatives need fast, simple interfaces. They should not have to navigate a full desktop ERP experience on a small screen.
14. Open Source and Community
RedLine is released under the GPL-3.0 license.
We believe the Frappe ecosystem can benefit from more specialized mobile applications, especially for businesses operating in environments with unreliable connectivity.
We are opening the project to the community and welcome:
- Bug reports.
- Architecture reviews.
- Feature suggestions.
- Flutter and Dart contributions.
- ERPNext integration feedback.
- Contributions toward English (LTR) localization.
The application currently provides an Arabic (RTL) interface only. English localization is one of the areas we would like to expand in future development.
Try RedLine
Google Play:
https://play.google.com/store/apps/details?id=com.redtech.redline
We would especially appreciate feedback from ERPNext implementers, developers, and organizations managing field sales teams.
What do you think is the biggest challenge when building offline-first applications for ERPNext: synchronization conflicts, financial consistency, local data management, or something else?
I'd love to hear your thoughts and experiences.