paint-brush
Getting Started with Activity streamby@rohitkhatana
2,872 reads
2,872 reads

Getting Started with Activity stream

by Rohit KhatanaMarch 22nd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Today every application indirectly uses the concept of activity stream but people do not know that there is a protocol defined by the community for this purpose only.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Getting Started with Activity stream
Rohit Khatana HackerNoon profile picture

Today every application indirectly uses the concept of activity stream but people do not know that there is a protocol defined by the community for this purpose only.

So, What is Activity Stream?

Activity Stream is a protocol(specification) for logging the business level events in a proper structured way. For ex: Facebook’s News Feed, Github activity feed etc.

On any standard system, usually there is a lot of activities are going which we want to persist. We can take example of collaborative editor platform , social platform, order management system etc.

And its better you use state machine on top of activity stream to impose rules on your system. Together both these things help you building a robust system.

Let’s first discuss the specifications:

In Activity stream you break the event into a English like sentence which has **Actor Verb Object Target**

For example this event: CustomerA placed an order for hotelA. So we can break it in the format of **Actor** **verb** **object** **target**

Actor: customer_id

verb: placed/state

object: order_id

target: hotel_id

Generally we create collection/table with the name of activity in which we have following fields/columns named: actor, verb, object, target, created_at/published_at.

And then we break our business events/activities into verbs like: placed, delivered, sent, dispatched etc.

and now think about our object as order/friend_request/demo_request etc.

Finally the target group, it can hold a single reference or group reference like: friend_id, hotel_id, document_id, group_id etc.

So in this way we log every business level event in a collection.

First principle of using activity stream you never override any event/activity.

And you avoid taking decision on the basis of activity collection. You just used it as read only. And use this info for latter analysis.

You can bind these events for notifying the target customer or showing them them there activity logs etc.

So using above approach you can easily built a news feed, activity manager etc.

There is a lot of open source packages available which you can easily integrate with you system.

For java and python you can refer these links:

https://github.com/OpenSocial/activitystreams

http://django-activity-stream.readthedocs.io/en/latest/streams.html

Conclusion:

I hope I explained everything clearly enough for you to understand. If you have any questions, feel free to ask. You can find me on twitter.

Make sure you click on green heart below and follow me for more stories about technology :)

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!