Skip to content

A React Native POS system with offline functionality, LAN data synchronization, and real-time updates between devices.

Notifications You must be signed in to change notification settings

haseeb-usman/offline-sync

Repository files navigation

Restaurant Order App with Offline Capabilities

A robust restaurant ordering system built with Expo React Native that works seamlessly offline and syncs when online.

Features

Core Functionality

  • ✅ Place and manage restaurant orders
  • ✅ Works offline with automatic sync when online
  • ✅ Real-time updates between devices using Socket.IO
  • ✅ Automatic server discovery on local network
  • ✅ Persistent data storage with PouchDB

Technical Features

  • 💾 Custom AsyncStorage adapter for PouchDB
  • 🔄 Bidirectional sync between devices
  • 🌐 Network state management and automatic reconnection
  • 📡 Zero-configuration network service discovery using Zeroconf
  • 💬 Real-time messaging system for device communication

Getting Started

Prerequisites

  • Node.js 14+
  • npm or yarn
  • Expo CLI (npm install -g expo-cli)

Installation

  1. Install dependencies:

    npm install
  2. Start the Expo development server:

    npx expo start
  3. Start the backend server (required for multi-device sync):

    node server/index.js

Development

Running on Multiple Devices

  1. Start the backend server on your computer
  2. Connect multiple devices to the same WiFi network
  3. Run the app on each device
  4. The app will automatically discover the server

Testing Offline Mode

  1. Run the app connected to the server
  2. Turn off WiFi/data on your device
  3. Continue using the app - all changes are stored locally
  4. Reconnect to the network to sync changes

Architecture

Client

  • PouchDBSetup: Custom AsyncStorage adapter for offline data persistence
  • NetworkService: Manages connectivity, server discovery, and real-time communication
  • DatabaseService: Handles data operations and synchronization

Server

  • Express.js backend with PouchDB for data storage
  • Socket.IO for real-time communication
  • RESTful API endpoints
  • Zero-conf network discovery

Technical Notes

Data Synchronization

The app uses a bidirectional sync mechanism:

  • Local changes are pushed to the server when online
  • Server changes are pulled to the device
  • Conflict resolution is handled automatically by PouchDB

Network Discovery

The app uses Zeroconf/Bonjour for automatic server discovery on local networks, making setup easier for restaurants with multiple devices.

Socket.IO Integration

Real-time communication between devices ensures immediate updates for new orders and status changes.

License

MIT

About

A React Native POS system with offline functionality, LAN data synchronization, and real-time updates between devices.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published