/twico_engine

Designed a twitter like engine and web user interface

Primary LanguageErlangMIT LicenseMIT

Twi-co App

Implementation of WebSocket Interface for a Twitter-like engine

Problem Statment

Implementation of WebSocket interface for Twitter API implemented using actor model in Erlang. The main functionalities of this engine will be

  • To provide an interactive client interface
  • Updating feed without client intervention.
  • Client should be able to
    • Register
    • Send tweets
    • View Feed and Retweet
    • Subscribed
    • Query using hashtags, mentions & subscribed users.

Implementation

HTTP vs WebSockets

In HTTP long polling, the client has to continuously pull the updates from the server and update accordingly. If there’s a continuous stream of data, the client will have to request more pull requests and wait till the server is free. It is ineffective. In Web Sockets, a channel is created which enables the server to send a stream of data without client asking server.

Cowboy

Cowboy is a small, fast, HTTP server for Erlang/OTP. Cowboy provides a complete web stack which is supported by HTTP/1.1, HTTP/2, Websocket, REST

Let us discuss on how to create and run a cowboy application in a linux/Mac device.

  • Create a directory with all lower cases
  • Install erlang.mk: wget https://erlang.mk/erlang.mk
  • Bootstrap the application : make -f erlang.mk bootstrap bootstrap-rel
  • Run the application : make run
  • Now, add cowboy to the existing dependencies(in Makefile)
  • Add Routing and listening in the <app name>_app.erl
  • Run the application : make run For more references, check out the documentation

Architecture

Register

image

Twitter Functionality

image

Feed Update with WebSocket

image

Routing & Connections**

Routes

image

Connections

image

Run Instructions

  • Run the following in terminal
cd twitterws
make run

Conclusions

A websocket interface for a twitter like engine is successfully implemented with an interactive user interface through which users can perform functionalities like

  • Tweet
  • Register
  • Subscribe
  • Retweet
  • Query tweets by mention, hashtag & by subscribed users A websocket connection is established after registering and redirected to /name/main. Once a user tweeted, all the subscribed users will instantly get in the feed through websockets without any user interaction.

Author

  • Vatsal Verma
  • Joowsook Lee
  • Rebecca Kane