Skip to main content

Overview

MotorDesk is built with offline-first architecture, meaning you can continue working even without internet connectivity. All critical operations are saved locally and automatically sync when your connection is restored.
MotorDesk is described in its configuration as an “offline-first” fleet management and electronic billing system, ensuring uninterrupted operations in the field.

How Offline Mode Works

Automatic Detection

The system automatically detects your connectivity status:
  • Online: All operations sync immediately to the server
  • Offline: Operations are saved locally with PENDING sync status
  • Reconnected: Pending items automatically sync in the background

Sync Architecture

MotorDesk uses Redux state management with sagas for sync operations:
// Sales are tagged with sync status
interface Sale {
    id: string;
    clienteId: string;
    montoTotal: number;
    sync_status: 'PENDING' | 'SYNCED';
}
When you create an invoice offline:
  1. Invoice is saved locally with sync_status: 'PENDING'
  2. You can continue working immediately
  3. System monitors for reconnection
  4. When online, syncPendingSales() function triggers
  5. Pending items sync to server
  6. Status updates to SYNCED

What Works Offline

1

Invoice Creation

Fully Functional:
  • Create new invoices and sales receipts
  • Add products from cached inventory
  • Select customers from local database
  • Calculate totals and taxes
  • Save documents with PENDING status
Use frequent products feature for faster offline invoicing - no search required.
2

Customer Management

Available:
  • View existing customer directory
  • Edit customer information
  • Search through customer records
  • Create invoices for existing customers
Limited:
  • ❌ API validation (RUC/DNI lookup) requires internet
  • ✅ Manual customer registration still works
3

Fleet Management

Fully Functional:
  • View vehicle fleet
  • Add new vehicles
  • Edit vehicle information
  • Update odometer readings
  • View maintenance alerts
  • Search and filter vehicles
4

Product Catalog

Available:
  • Browse products
  • Search by name or barcode
  • View prices and descriptions
  • Add products to invoices
The product catalog is cached locally, so you have access to your full inventory offline.

What Requires Internet

The following features require an active internet connection:
  • API Document Validation: RUC/DNI lookup from SUNAT/RENIEC
  • SUNAT Submission: Electronic invoice submission to tax authority
  • Real-time Sync: Immediate server synchronization
  • Cloud Backups: Automatic backup to cloud storage
  • Multi-device Sync: Syncing data across multiple devices/locations

Offline Sync Process

1

Work Offline

Continue your normal operations:
  • Create invoices
  • Register vehicles
  • Update customer information
  • Process sales
Each operation is saved locally with appropriate sync markers.
2

Monitor Sync Status

The system shows pending sync items:
  • Look for sync status indicators in the UI
  • Pending items are marked clearly
  • You can see what’s waiting to sync
Check the sync indicator regularly to know when you have pending operations.
3

Reconnect to Internet

When your connection is restored:
  • System detects the RECONNECTED event
  • syncPendingSales() saga triggers automatically
  • All PENDING items queue for sync
  • Progress indicators show sync status
4

Automatic Sync

The system processes pending items:
  • Sends data to server in order
  • Updates sync_status from PENDING → SYNCED
  • Confirms successful sync
  • Resolves any conflicts automatically
You don’t need to do anything - sync happens automatically in the background.

Before Going Offline

Pre-Offline Checklist

1

Sync Recent Changes

Ensure all recent work is synced:
  • Check sync status indicator shows no pending items
  • Wait for any in-progress syncs to complete
  • Verify recent invoices show SYNCED status
2

Verify Local Data

Confirm you have the data you need:
  • Customer directory is current
  • Product catalog is up to date
  • Vehicle information is recent
  • Pricing is correct
3

Check Device Storage

Ensure adequate space:
  • Local database has room to grow
  • Enough space for new invoices
  • Room for cached data

Logging Out Offline

When you log out with pending sync items:
A special modal appears:¿Cerrar Sesión?“Estás a punto de salir del sistema. Si tienes transacciones offline pendientes de sincronizar, se guardarán de forma segura en este dispositivo.”
Your pending transactions:
  • ✅ Are saved securely on the device
  • ✅ Will sync next time you log in (when online)
  • ✅ Won’t be lost during logout
  • ✅ Remain associated with your account

Best Practices for Offline Work

Data Management

  1. Keep Local Cache Fresh
    • Sync regularly when online
    • Update product catalog before going offline
    • Refresh customer data periodically
  2. Monitor Storage
    • Check device storage regularly
    • Clear old cached data if needed
    • Ensure adequate space for operations
  3. Sync Frequently
    • Don’t accumulate too many pending items
    • Sync daily if possible
    • Process pending queue regularly

Workflow Tips

  1. Use Frequent Products
    • Pre-configure common service items
    • Speeds up offline invoice creation
    • Reduces search requirements
  2. Register Customers in Advance
    • Add customers when online (for API validation)
    • Build customer directory before field work
    • Verify all information is complete
  3. Update Vehicle Data Online
    • Complete vehicle registrations when connected
    • Ensures all data is properly synced
    • Reduces offline data entry
  4. Preview Before Processing
    • Use VISTA PREVIA for complex invoices
    • Verify all information is correct
    • Catch errors before creating PENDING items

Field Service Scenarios

Mobile Service Technician:
1. Sync data at start of day (at office with WiFi)
2. Drive to customer locations (offline)
3. Create invoices on-site (saved as PENDING)
4. Continue to next customer
5. Return to office, auto-sync all invoices
Remote Branch Office:
1. Work normally despite intermittent connectivity
2. System handles connection drops gracefully
3. Operations never interrupted
4. Automatic sync when connection available
5. Central office receives all data

Troubleshooting Offline Mode

Pending Items Not Syncing

1

Check Connection

Verify internet connectivity:
  • Test other websites/apps
  • Check WiFi or mobile data
  • Confirm no firewall blocking
2

Review Sync Status

Look for error indicators:
  • Failed sync messages
  • Connection timeout warnings
  • Server unavailable notices
3

Manual Retry

If auto-sync fails:
  • Look for manual sync button
  • Trigger sync from settings
  • Check sync queue status

Data Conflicts

If the same record is edited offline and online:
  • System uses timestamp-based conflict resolution
  • More recent changes typically win
  • Critical data may require manual review
  • Conflict notifications appear in UI
Avoid editing the same invoices on multiple devices simultaneously to prevent conflicts.

Storage Issues

If device storage is full:
  • Pending syncs may fail to save
  • New invoices can’t be created
  • Error message indicates storage problem
Solution:
  • Free up device storage
  • Sync and clear old cached data
  • Consider archiving old records

Understanding Sync Status

Status Indicators

StatusMeaningAction Required
SYNCEDData is on serverNone
PENDINGWaiting to syncConnect to internet
SYNCINGCurrently uploadingWait for completion
FAILEDSync error occurredReview and retry

Timestamping

The system tracks:
  • syncedAt: When item last synced to server
  • Created timestamp: Original creation time
  • Modified timestamp: Last edit time
{
    id: "V-001",
    placa: "ABC-123",
    kmActual: 45000,
    syncedAt: "2023-10-25T10:01:00Z"  // Last sync time
}

Security in Offline Mode

Your data remains secure offline:
  • ✅ Local database is encrypted
  • ✅ Authentication tokens cached securely
  • ✅ No data accessible without login
  • ✅ Device-level security applies
  • ✅ Data syncs over encrypted connection
Always log out on shared devices, even with pending syncs. The data remains secure and will sync when the authorized user logs back in.

Next Steps

Build docs developers (and LLMs) love