A modern retail inventory management application built with Couchbase Lite for web, featuring real-time sync capabilities with Couchbase Capella App Services.
- 📱 Offline-First: Full functionality without internet connection using Couchbase Lite
- 🔄 Real-Time Sync: Automatic bidirectional sync with Couchbase Capella App Services
- 🏪 Multi-Store Support: Manage inventory across multiple retail locations
- 📦 Inventory Management: Track products, stock levels, and orders
- 🎨 Modern UI: Built with React, TypeScript, and shadcn/ui components
- 🔐 Secure: Store-based authentication and data isolation
- Frontend: React 18 + TypeScript + Vite
- UI Framework: shadcn/ui + Tailwind CSS
- Database: Couchbase Lite for JavaScript
- Sync: Couchbase Capella App Services
- Icons: Lucide React
- State Management: TanStack Query
- Node.js: Version 18 or higher (install with nvm)
- npm: Comes with Node.js
- Couchbase Capella Account: For App Services sync functionality
git clone https://github.com/couchbase-examples/couchbase-lite-retail-demo.git
cd couchbase-lite-retail-demo/webnpm installCopy the example environment file and configure it with your Couchbase Capella settings:
cp .env.example .envEdit .env and set your Couchbase App Services WebSocket URL:
# Get this from your Capella App Services dashboard
# Format: wss://your-endpoint.apps.cloud.couchbase.com:4984/database-name
VITE_APP_SERVICES_URL=wss://your-endpoint.apps.cloud.couchbase.com:4984/your-database-nameWhere to find your WebSocket URL:
- Log into Couchbase Capella
- Navigate to App Services
- Select your App Services endpoint
- Copy the complete WebSocket URL including the database path
- Example:
wss://xxxxx.apps.cloud.couchbase.com:4984/retail-sync
- Example:
npm run devThe application will be available at http://localhost:5173 (or another port if 5173 is in use).
Build the optimized production bundle:
npm run buildThe built files will be in the dist/ directory.
Preview the production build locally:
npm run previewweb/
├── src/
│ ├── components/ # React components
│ ├── lib/
│ │ ├── database/ # Couchbase Lite database setup and types
│ │ └── auth.ts # Authentication helpers
│ ├── pages/ # Page components
│ └── App.tsx # Main app component
├── public/ # Static assets
├── .env.example # Environment variables template
└── package.json # Dependencies and scripts
The app uses email-based authentication with the following format:
- Email:
{store-id}@supermarket.com(e.g.,nyc-store-01@supermarket.com) - Password: As configured in your Capella App Services
The store ID is extracted from the email and determines:
- Which data scope the user has access to
- Store-specific inventory and orders
Note: The App Services URL configured in .env is used as-is without any modifications based on the store ID.
VITE_APP_SERVICES_URL: Complete WebSocket URL for your Capella App Services endpoint (including database path)
The following are defined in the application code and don't need to be configured:
- Database Name:
retail-inventory(defined insrc/lib/database/types.ts) - Database Version:
4(defined insrc/lib/database/types.ts) - Collections:
inventory,orders,profile - Scopes:
AA-Store,NYC-Store(automatically selected based on login)
npm run dev: Start development server with hot reloadnpm run build: Build for productionnpm run preview: Preview production build locallynpm run lint: Run ESLint to check code quality
- Verify your
VITE_APP_SERVICES_URLis correct - Check that your App Services endpoint is running
- Ensure your credentials are valid in Capella
- Check browser console for error messages
- Clear node_modules:
rm -rf node_modules && npm install - Clear cache:
rm -rf dist .vite - Ensure Node.js version is 18 or higher:
node --version
- Run:
npm run buildto see all type errors - Ensure all dependencies are installed:
npm install