Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
path: "/learn/couchbase-lite-offline-first-retail"
title: Couchbase Lite and Offline First Retail Applications
short_title: Offline First with Couchbase Lite
description:
- Learn how to build an offline-first retail inventory management application with Couchbase Lite
- Set up a cloud backend with Couchbase Capella and configure App Services for real-time sync
- Enable peer-to-peer sync between mobile devices without requiring cloud connectivity
content_type: learn
filter: mobile
technology:
- mobile
- capella
- app-services
tags:
- Android
- iOS
- App Services
- P2P
tutorials:
- offline-first-app-getting-started
- retail-demo-capella-setup
- retail-demo-app-services-sync
- retail-demo-peer-to-peer-sync
related_paths:
- /learn/android-kotlin-app-services
- /learn/swift
sdk_language:
- kotlin
- swift
download_file: null
length: 1 Hour 45 Mins
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add some overview of this learning path here. This is the landing page for the learning path guiding users on what this learning path is about & the prerequisites & outcomes.
Example of how it looks: https://developer.couchbase.com/learn/flutter-dart-sdk-app-services/


Couchbase Mobile brings the power of NoSQL to the edge, combining Couchbase Lite (an embedded, offline-capable database), Capella App Services (a synchronization layer), and Couchbase Capella (a fully managed cloud database). Together they enable applications that work seamlessly with or without internet connectivity — a pattern known as offline-first.

This learning path walks through a multi-platform retail inventory management application built for iOS (Swift/SwiftUI) and Android (Kotlin/Jetpack Compose). The app demonstrates how a real-world retail solution can store data locally on-device, sync it to the cloud, and even sync directly between nearby devices — all powered by Couchbase Lite.

## Prerequisites

Before starting this learning path, you should have:

* A [Couchbase Capella account](https://cloud.couchbase.com/) (free trial available)
* Familiarity with iOS (Swift) or Android (Kotlin) development
* For iOS: Xcode 16.4+, macOS Sonoma or later
* For Android: Android Studio Ladybug (2024.2.1)+, JDK 17+
* Basic understanding of NoSQL and mobile application architecture

## Retail Demo Application

The sample application is a retail inventory management system for a fictitious supermarket chain with multiple store locations. It demonstrates how Couchbase Lite fits into a production-grade mobile architecture, covering offline data access, cloud synchronization, and direct peer-to-peer sync between devices.

The app uses scopes and collections to isolate data per store location, with three core collections — `inventory`, `orders`, and `profile` — synchronized via Capella App Services.

## Learning Agenda

This learning path covers four modules:

1. **Getting Started** — Understand the application architecture, the offline-first approach, and how to set up your development environment
2. **Capella Setup** — Create a Couchbase Capella cluster, configure buckets, scopes, and collections, set up App Services, and import sample data
3. **App Services Sync** — Learn how Couchbase Lite replicates data bidirectionally with Capella App Services, and test real-time sync across devices
4. **Peer-to-Peer Sync** — Enable direct device-to-device synchronization over a local network without requiring cloud connectivity, using Couchbase Lite's URL Endpoint Listener
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
path: "/offline-first-app-getting-started"
title: Getting Started with Offline First Mobile Apps using Couchbase Lite
short_title: Getting Started
description:
- Learn about the Couchbase Lite Retail Demo application architecture
- Understand the offline-first approach with Couchbase Lite
- Set up your development environment for iOS, Android, or Web
content_type: tutorial
filter: mobile
technology:
- mobile
- capella
- app-services
tags:
- Android
- iOS
- App Services
sdk_language:
- kotlin
- swift
length: 15 Mins
exclude_tutorials: true
---

## Introduction

Welcome to the Couchbase Lite Retail Demo! This tutorial series will guide you through building and understanding a retail inventory management application that demonstrates Couchbase Lite's powerful features.

In this first tutorial, you will learn:

* The architecture of the retail demo application
* Key features including offline-first data storage, real-time sync, and peer-to-peer sync
* How to set up your development environment

## Application Overview

The Couchbase Lite Retail Demo is a multi-platform retail inventory management application built for:

* **iOS** (Swift/SwiftUI)
* **Android** (Kotlin/Jetpack Compose)
* **Web** (React/TypeScript)

### Key Features

| Feature | Description |
|---------|-------------|
| **Offline-First** | Full functionality without internet using Couchbase Lite as a local database |
| **Real-Time Sync** | Bidirectional sync with Couchbase Capella via App Services |
| **Peer-to-Peer Sync** | Direct device-to-device sync over local network (iOS & Android) |
| **Multi-Store Support** | Manage inventory across multiple retail locations |

Comment on lines +26 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could consider moving some of this into the Learning Path landing page (learn/markdown/)

### Architecture Diagram

The complete setup looks like this:

![App Setup Diagram](app-setup.png)

The architecture consists of:

1. **Couchbase Capella** - Cloud database backend
2. **Capella App Services** - Synchronization layer that connects mobile/web clients to Capella
3. **Mobile/Web Clients** - iOS, Android, and Web applications with embedded Couchbase Lite

## Data Model

The application manages three main types of data:

### Collections

Each store scope contains three collections:

| Collection | Purpose | Example Document Count |
|------------|---------|----------------------|
| `inventory` | Product inventory items | ~80 per store |
| `orders` | Customer orders | ~150 per store |
| `profile` | Store profile information | 1 per store |

### Scopes

Data is organized by store using scopes:

* `AA-Store` - AA Supermarket location
* `NYC-Store` - NYC Supermarket location

### Sample Documents

**Inventory Document:**
```json
{
"_id": "Inventory_NYCStore_10000",
"docType": "Inventory",
"productId": 10000,
"sku": "NYC-10000",
"name": "Organic Milk",
"brand": "BudgetBest",
"category": "Dairy",
"price": 29.86,
"unit": "gallon",
"stockQty": 71,
"location": {"aisle": 24, "bin": 7},
"storeId": "nyc-store-01"
}
```

**Order Document:**
```json
{
"_id": "order-nyc-store-01-V1StGXR8_Z5jdHi6B-myT",
"docType": "Order",
"storeId": "nyc-store-01",
"orderDate": 1755257767451,
"orderStatus": "Submitted",
"productId": 10000,
"sku": "NYC-10000",
"unit": "gallon",
"orderQty": 30
}
```

## Prerequisites

Before you begin, ensure you have the following:

### For All Platforms

* **Couchbase Capella Account** - Sign up for a [free trial](https://cloud.couchbase.com/)
* **curl** or similar HTTP client for testing

### For iOS Development

* **Xcode**: 16.4 or later
* **iOS SDK**: 18.5 or later
* **macOS**: Sonoma or later

### For Android Development

* **Android Studio**: Ladybug (2024.2.1) or later
* **JDK**: 17 or later
* **Android SDK**: Minimum 24, Target 35

### For Web Development

* **Node.js**: Version 18 or higher
* **npm**: Comes with Node.js

## Repository Structure

Clone the repository to get started:

```bash
git clone https://github.com/couchbase-examples/couchbase-lite-retail-demo.git
cd couchbase-lite-retail-demo
```

The repository is organized as follows:

```
couchbase-lite-retail-demo/
├── Android/ # Android app (Kotlin/Jetpack Compose)
├── iOS/ # iOS app (Swift/SwiftUI)
├── web/ # Web app (React/TypeScript)
├── common/ # Shared assets
│ └── assets/ # Images and diagrams
├── tutorials/ # Step-by-step tutorials
├── README.md # Main project documentation
└── CONTRIBUTING.md # Development guidelines
```

## Platform-Specific Setup

For detailed setup instructions specific to each platform, see the platform-specific READMEs in the [couchbase-lite-retail-demo repository](https://github.com/couchbase-examples/couchbase-lite-retail-demo):

* [Android README](https://github.com/couchbase-examples/couchbase-lite-retail-demo/blob/main/Android/README.md)
* [iOS README](https://github.com/couchbase-examples/couchbase-lite-retail-demo/blob/main/iOS/README.md)
* [Web README](https://github.com/couchbase-examples/couchbase-lite-retail-demo/blob/main/web/README.md)

## Learn More
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a line here guiding them onto the next step of the learning path.
An example from one of the existing tutorials

Congratulations on completing this step of our learning path!

This step of the learning path walked you through an example of how to use a pre-built Couchbase Lite database. Check out the following links for further documenation and continue on to the next step that covers how to insert documents into the database using Batch operations.


### References

* [Couchbase Lite Documentation](https://docs.couchbase.com/couchbase-lite/current/index.html)
* [Couchbase Capella App Services](https://docs.couchbase.com/cloud/app-services/index.html)
* [Couchbase Capella Free Trial](https://cloud.couchbase.com/)

## What's Next?

You now have a solid understanding of the Couchbase Lite Retail Demo architecture and your development environment is ready. In the next tutorial, you will set up the cloud backend by creating a Couchbase Capella cluster, configuring scopes and collections, and enabling App Services for synchronization.
Loading