Posts app architecture design help

108 views
Skip to first unread message

Joel W

unread,
Jun 4, 2014, 1:09:23 PM6/4/14
to mobile-c...@googlegroups.com
Hi

I need some help with the high level architecture design of an app I am looking to build using CBLite, Sync Gateway and Couchbase server . The app will allow users to make a post, users will be able to subscribe to other users and users will be able to see a feed of comments from the users they are subscribe to. Think twitter/facebook etc.

I get posts will be stored in documents.

Where should I store what user has subscribed to what users? In the user document?

How should I only sync back to the device the posts from the users that user has subscribed to?

How should I then find/display a feed of the recent post?

Thanks
Joel

Todd Freese

unread,
Jun 4, 2014, 9:48:01 PM6/4/14
to mobile-c...@googlegroups.com
Check out the CouchChat example app. 


Todd

J. Chris Anderson

unread,
Jun 6, 2014, 6:17:02 PM6/6/14
to mobile-c...@googlegroups.com

Joel W

unread,
Apr 11, 2016, 10:39:46 AM4/11/16
to Couchbase Mobile
I know this has been a long time, but I am picking this back up :) Great to see all the hard work you guys have been doing.

So would you create a channel per user? and followers of this user are added to that users channel so the followers get post syncing to their device?

Would you also create a channel per post or is this over kill?

Jens Alfke

unread,
Apr 11, 2016, 11:51:00 AM4/11/16
to mobile-c...@googlegroups.com

On Apr 11, 2016, at 6:44 AM, Joel W <joeljam...@gmail.com> wrote:

So would you create a channel per user? and followers of this user are added to that users channel so the followers get post syncing to their device?

Yup. And the way to add a followers to the user’s channel is to add the user ID to a document property, and use the `access` function in the sync function to give them access. The simplest way would be to have a document owned by a user, that lists whom they want to follow; then the app just edits this document to add or remove subscriptions.

—Jens

Joel W

unread,
Apr 11, 2016, 9:23:49 PM4/11/16
to Couchbase Mobile
Thanks Jens, this make sense for user A follows B and C. How would handle so you could see User A is followed by C and D? Would you need to have a relationship doc type, that defines the relationship between each user and this gets added to the channel of each user in the relationship?

Cheers
Joel

Jens Alfke

unread,
Apr 12, 2016, 10:46:11 AM4/12/16
to mobile-c...@googlegroups.com

On Apr 11, 2016, at 6:23 PM, Joel W <joeljam...@gmail.com> wrote:

Thanks Jens, this make sense for user A follows B and C. How would handle so you could see User A is followed by C and D? Would you need to have a relationship doc type, that defines the relationship between each user and this gets added to the channel of each user in the relationship?

That would work.  Something like {“user”: “A”, follows: “B”}. The sync function would add this to both A and B’s ‘relationships’ channels, and grant B access to A’s ‘messages’ channel. (I’m separating the two kinds of channels so that following someone doesn’t automatically show you who they’re following or being followed by.)

—Jens

Joel W

unread,
Apr 13, 2016, 4:25:33 AM4/13/16
to Couchbase Mobile
Cool, so what you are saying is that each user would have 2 channels a 'Messages' channel and a 'Relationship' channel? In terms of scale there wouldn't be an issue if say you had 100k users which would mean 200k channels?

I am a little confused about this sentence you wrote.

(I’m separating the two kinds of channels so that following someone doesn’t automatically show you who they’re following or being followed by.)

Did you mean to say that by following someone they don't automatically see your messages? If as you said the sync function is adding {“user”: “A”, follows: “B”} to both A and B's 'relationship' channel. Wouldn't they be able to see who followers them etc but if you only grant B access to A's 'message' channel, B would only see A's messages and A wouldn't see B's messages?

Thanks
Joel

Joel W

unread,
Apr 20, 2016, 7:37:49 AM4/20/16
to Couchbase Mobile
Hi Jens

Just wounding if you can provide any comments?

Thanks
Joel

Jens Alfke

unread,
Apr 20, 2016, 12:04:36 PM4/20/16
to mobile-c...@googlegroups.com
On Apr 13, 2016, at 1:25 AM, Joel W <joeljam...@gmail.com> wrote:

Cool, so what you are saying is that each user would have 2 channels a 'Messages' channel and a 'Relationship' channel? In terms of scale there wouldn't be an issue if say you had 100k users which would mean 200k channels?

Channels are pretty lightweight; they’re more like tags on messages.

(I’m separating the two kinds of channels so that following someone doesn’t automatically show you who they’re following or being followed by.)

Did you mean to say that by following someone they don't automatically see your messages? If as you said the sync function is adding {“user”: “A”, follows: “B”} to both A and B's 'relationship' channel. Wouldn't they be able to see who followers them etc but if you only grant B access to A's 'message' channel, B would only see A's messages and A wouldn't see B's messages?

What I meant is that following someone should give you access to their messages, but not to the documents that show who they’re following. Which means that those two types of documents should be in different channels, i.e. a posts and a relationships channel.

—Jens

Joel W

unread,
Apr 21, 2016, 7:45:09 AM4/21/16
to Couchbase Mobile
Thanks Jens I will do some testing using these concepts

Cheers
Joel

Reply all
Reply to author
Forward
0 new messages