INDIA +91 964 309 2571 | USA +1 650 405 4891 info@navyuginfo.com

Activity feed on any socializing platform shows the updates/news and as it says, activities of your friends and people whose activities you are authorized to view. Anything – a news feed, chat message, a connection request or a notification is an activity feed.

Let’s take a brief overview how can we implement activity feeds in our socializing mobile/web applications taking an example of how we achieved the same in a recent project.

Every activity feed has following properties:

  • Creator – user who initiates/creates the activity.
  • Info – content of that activity.
  • Audience – set of people who are going to see that feed in real time.
  • TrackableType – tells the type of activity (in particular model of the activity).
    • News Feed
    • Friend Requests
    • Chat Messages
    • Notifications

Whenever a user creates an activity, a process attached to it is queued in Sidekiq. Sidekiq is a full-featured background processing framework for Ruby. For more info on sidekiq –https://github.com/mperham/sidekiq/wiki.

Before creating/updating any activity its audience is saved/updated first. So that we will:

  • add a feed to a new audience,
  • update feed to the old audience (if the feed is being updated),
  • delete the feed from the removed audience

To store user data in user’s bin redis caching is utilized. Sidekiq uses Redis to store all of its job and operational data. For more info on using redis – https://github.com/mperham/sidekiq/wiki/Using-Redis.

After the activity has been published/unpublished to/from user bins at the backend, it also needs to be updated on the user side in real time. To achieve real-time updates on user side faye server is being used. Faye is a publish-subscribe messaging system. It provides message servers for Node.js and Ruby, and clients for use on the server and in all major web browsers. For more info on faye – https://faye.jcoglan.com/.

Hope the article was helpful in managing activity feeds of your application!!

[avatar user=”Aqbal Ahmad” size=”thumbnail” align=”left” /]