cloudant / python-cloudant

A Python library for Cloudant and CouchDB
Apache License 2.0
163 stars 55 forks source link

Need help with couchDb replication to do the below use case in the best possible way #482

Closed vdj69 closed 4 years ago

vdj69 commented 4 years ago

Hi there! I'm new to couchDB and need help to do the below use case in the best possible way:

Use Case: There will be a single database and in that database, there will be multiple multiple documents like:

  1. Company document: Company document will contain the company-related information like companyName, isComanyEnabled, isBlackList, and etc.
  2. User document: User document will contain the user-related information like userName, userContact, isUserEnabled, isBlackList, assignedCompany and etc.
  3. Driver document: User document will contain the driver-related information like driverName, driverContact, isDriverEnabled, isBlackList, and etc.
  4. Vehicle document: Veichal document will contain Vehicle -related information like VehicleMake, VehicleModel, VehicleNumber, isVeichalActive, isBlackList, assignedDriver, assignedCompany and etc.
  5. Vehicle Permission Rule document: This will contain information like which time of which day, which user is allowed to access which Vehicle.

Applications There will be:

  1. server-side application: This will contain all the information,
  2. Mobile app for User: Using this app, the user can sign in using his credential then the user can book a vehicle and see the list of assigned Vehicles and there will be one QR code for each ride.
  3. Driver App: Using this app, the driver can sign in using his credential then the driver can check which Vehicle is going to drive and which day.
  4. Veichal App: Mobile with this app will be installed on every Vehicle. In this app, the user will scan the QR code and if he gets authenticated then only he will be allowed to take the ride.

AIM I want this app to work in continuous replication and offline when there will be no network. As there will 1000's of record so want to do the following thing:

  1. Mobile app for User: This app will only sync the record based on the signed userID
  2. Driver App: This app will only sync the record based on the signed DriverID
  3. Veichal App: Here signed veichalID, and its related users, rules will be synced because the QR validation will happen here both online and offline. One the QR code scanned the record will push to the main server when the network will be available.

How can I replicate/sync? Suggestions and examples are welcome..

ricellis commented 4 years ago

How can I replicate/sync?

Hi @vdj69 - this (python-cloudant) library can control replication documents on the server (i.e. configuring server mediated replications) via the Replicator class, but it does not have a sync capability. Cloudant has libraries for iOS and Android that are able to sync with Cloudant/CouchDB. PouchDB is also a popular option in the CouchDB ecosystem.

I want this app to work in continuous replication

In general mobile applications don't do "continuous replication" in the way a server does because of the drain on the device. You can see some discussion on this here. The usual pattern is to configure replications to be controlled by events (such as network connecting).

need help to do the below use case in the best possible way

Complete app design is outside the scope of an issue here. If you are an IBM Cloudant or Support for CouchDB customer you can email support@cloudant.com to setup an engagement with our Client Architecture team for more help designing your application. If you are not a customer then I'd recommend the CouchDB slack or users mailing list to have discussions with the wider CouchDB community about best-practices for this type of application.

vdj69 commented 4 years ago

@ricellis : Thanks :)