Be kind this is my first question on StackOverflow :p. I am hoping its specific enough.
Here is how the project is structured
- REST API built using NodeJS and MongoDB (mongoose has been used for modelling the database schemas) with a Express server.
- Android app.
- Web app using AngularJS
My question is regarding how I should structure synchronisation of data between the Android app and the REST API. The following points bring clarity to the entire scenario -
- The database model (on the server) is pretty complex with each database model having multiple subdocuments.
- There are about 6 - 7 models which reference each other.
- I am currently using Volley to get the data from the remote server.
- I am also considering adding a SyncAdapter for syncing the data regularly and am not sure as to how to incorporate this with a local database. Should I have a different ContentProvider for every table / model in the database? and how should I handle nested schemas (that are in the remote server) locally?
To summarise my question what I exactly want to know is considering that there will be about 15-20 requests per user per day for about 100,000 users daily, would the best approach be to -
To demonstrate the complexity of the app please have a look at the models below
This is the user model
var AddressSchema = new Schema({
name: String,
address: String,
mobile: String,
pincode: String,
city: String,
state: String
});
var CartSchema = new Schema({
book: { type: Schema.Types.ObjectId, ref: 'Book' },
quantity: {
type: Number,
default: 1
},
dateAdded: Date
});
var WishlistSchema = new Schema({
book: { type: Schema.Types.ObjectId, ref: 'Book' },
dateAdded: Date
});
var OrderSchema = new Schema({
orderNumber: String,
cart: [CartSchema],
totalAmount: Number,
deliveryCharge: Number,
discountAmount: Number,
address: [AddressSchema],
date: Date,
deliveryDate: Date,
deliveryStatus: String
});
var SellOrderSchema = new Schema({
orderNumber: String,
bookDetails: [{
isbn: String,
title: String,
quantity: {
type: Number,
default: 1
}
}],
address: [AddressSchema],
date: {
type: Date,
default: Date.now()
}
});
var ReceivedOrdersSchema = new Schema({
orderNumber: String,
bookDetails: [{
book: { type: Schema.Types.ObjectId, ref: 'Book' },
quantity: Number,
price: Number
}],
dueDate: Date,
status: {
type: String,
default: 'Pending'
}
});
var CouponSchema = new Schema({
coupon: [{ type: Schema.Types.ObjectId, ref: 'Coupon' }],
used: Number,
totalDiscount: Number
});
var UserSchema = new Schema({
name: String,
email: { type: String, lowercase: true },
role: {
type: String,
default: 'user'
},
hashedPassword: String,
provider: String,
salt: String,
facebook: {},
twitter: {},
google: {},
github: {},
usedCoupons: [CouponSchema],
cart: [CartSchema],
wishlist: [WishlistSchema],
orders: [OrderSchema],
sellOrders: [SellOrderSchema],
addresses: [AddressSchema],
booksToSell: [{ type: Schema.Types.ObjectId, ref: 'Book' }],
receivedOrders: [ReceivedOrdersSchema]
});
This is the books model
var BookSchema = new Schema({
_creator : {type: Schema.Types.ObjectId, ref: 'User'},
title: String,
subtitle: String,
author: String,
language: String,
pages: Number,
publisher: String,
publishedDate: String,
isbn10: String,
isbn13: String,
description: String,
dimensions: {
height: String,
width: String,
thickness: String
},
category: String,
rating: String,
bookType: String,
imageLinks: {
extraLarge: String,
large: String,
medium: String,
small: String,
smallThumbnail: String,
thumbnail: String,
uploaded: String
},
uploadedImageLink: String,
supplierData: {
mrp: Number,
supplierPrice: Number,
quantity: Number
},
pricing: {
salesPrice: Number,
deliveryCharge: Number
},
dateAdded: Date,
isFeatured: Boolean,
isBestseller: Boolean
});
There are 5-6 other such models that are dependent on each other