I'm developing a NodeJS API that will be consumed, for now, by an Android app.
I need 2 important things here: a News Feed and a Notification system. And I need it to be scalable.
I'm using MongoDB with Express for this project.
Notification System
About the notification system I'm thinking about a document that would hold:
- actor: id refering to an User object
- verb: a String defining the type of action: add friend, comment, etc.
- object: an id refering to: User, Activity, whatever, depending on the type of verb. I would get the correct object depending on the value of the verb.
My biggest doubt about this structure is: How would I return all this data to my Android app. Is it correct to return a JSON with the notification unpopulated (only ID's), and the Android app would use the ID's and query the API to build the notification. I mean, the client would make a call to: /getUser/:id to get the username, then /getActivity/:id to get the activity details, you get the point... Wouldn't that be to much calls just for a notification?
Because, imagine a user getting 50 notifications, that would be ~100 requests only to get the notification details. If that happens to 1K users, it would be 10K requests to get notification details.
News Feed
What's the best way to my client to get the latest activity? Just query the database for the latest inserted data that matches the criteria?
I shouldn't be dwelling too much on that because the application will start small, but I would like to start with a not so bad design. That's my first application of this type so I don't know what to expect.
Thanks!