/Chatbase

A simple (mobile) chat app using Couchbase Lite, Sync Gateway, and Couchbase Server.

Primary LanguageC#Apache License 2.0Apache-2.0

Chatbase

Chatbase is a simple (mobile) chat app powered by an embedded Couchbase Lite database, the synchronization enginee of Sync Gateway, and a distributed Couchbase Server database.

Table of Contents

  1. Couchbase Mobile Overview
  2. Setting up server-side components
    1. Sync Gateway
    2. Couchbase Server
  3. Running the solutions
  4. Support

Couchbase Mobile Overview

Couchbase Mobile brings the power of NoSQL to the edge and is comprised of three components:

Couchbase Lite, an embedded, NoSQL JSON Document Style database for your mobile apps

Sync Gateway, an internet-facing synchronization mechanism that securely syncs data between mobile clients and server, and

Couchbase Server, a highly scalable, distributed NoSQL database platform

Setting up server-side components

Chatbase uses Couchbase's Sync Gateway and Server solutions. Both components can be installed locally, on on-premisis servers, and/or within the cloud. For this demo we'll be installing everything locally for testing.

Sync Gateway

Sync Gateway is the synchronization server in a Couchbase Mobile deployment.

Sync Gateway is designed to provide data synchronization for large-scale interactive web, mobile, and IoT applications. Commonly used features include:

  • User authentication, ensuring that only authorized users can connect to Sync Gateway (see user authentication guide).

  • Access Control, guaranteeing that only relevant documents are synced. Sync Gateway accomplishes this by examining document and applying business logic to decide whether to assign the documents to channels. Access control and ensuring that only relevant documents are synced are achieved through the use of channels and the Sync Function.

Installation

To install Sync Gateway please follow the instructions here.

Running

To start using Sync Gateway execute the following command.

~/Downloads/couchbase-sync-gateway/bin/sync_gateway ~/path/to/basic-sync-function.json

Note: "basic-sync-function.json" is included within the repo here.

Settings

To learn more about how to modify the Sync Gateway configuration file please see the documentation here.

Couchbase Server

Couchbase Server is an open source, distributed, NoSQL document-oriented engagement database. It exposes a fast key-value store with managed cache for sub-millisecond data operations, purpose-built indexers for fast queries and a powerful query engine for executing SQL-like queries. For mobile and Internet of Things environments Couchbase also runs natively on-device and manages synchronization to the server.

Couchbase Server is specialized to provide low-latency data management for large-scale interactive web, mobile, and IoT applications. Common requirements that Couchbase Server was designed to satisfy include:

Unified Programming Interface

  • Query
  • Search
  • Mobile and IoT
  • Analytics
  • Core database engine
  • Scale-out architecture
  • Memory-first architecture
  • Big data and SQL integrations
  • Full-stack security
  • Container and Cloud deployments
  • High Availability

Installation

To install Couchbase Server please follow the instructions here.

Note: I advise installing Couchbase Server manually to start. If you install using Docker you will need to ensure that both Sync Gateway and Couchbase Server are running on the same Docker Host, and then you'll need to configure accordingly. You can find more instructions using Docker here.

Running

Once Couchbase Server has been installed simply navigate to where it has been installed and start "Couchbase Server".

To start Couchbase Server using Docker please see the documentation here.

Admin Portal

Couchbase Server can be accessed using

When Couchbase Server has been started you'll be able to navigate directly to the admin portal at http://localhost:8091.

Running the solutions

Chatbase has two .NET solutions:

  • Chatbase.API: A .NET Core Web API solution used for communicating with Sync Gateway via the Admin API.

  • Chatbase: A Xamarin(.Forms) based solution containing several porjects

You will need to build and run the Chatbase.API solution before attempting to use the Chatbase mobile solution. You will also need to keep the Chatbase.API solution running.

Users are able to log into the app simply by entering a name and a Sync Gateway channel.

After you've logged in you'll be taken to the channel's chat screen, and will be able to send messages.

You'll also be able to switch channels by tapping the navigation bar title, and entering in a new channel name.

Support

If you have any questions, comments, or would like to contribute to this projects please reach out to me directly at robert.hedgpeth@couchbase.com or on Twitter.