Skip to content

A cli-interactive application build on the top of Network layer, with custom protocols, client-server finite-state-machines and TCP socket. This has been tested with mininet using network typologies.

Notifications You must be signed in to change notification settings

antimattercorrade/Mini_LinkedIn

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mini-LinkedIn ⭐

Mini-LinkedIn is a program using networking paradigms that supports important LinkedIn features like feed, job posting and searching, connecting and networking, creating companies, and building profiles. Mini-LinkedIn consists of several different features, taking inspiration from the popular social networking platform LinkedIn. The server and client model for Mini-LinkedIn work on TCP protocol, where the server serves the requests by the client(s). The server interacts with the database to retrieve, insert, delete and update data of the users/companies.

Refer here for our project proposal for Mini-LinkedIn.

Refer here for our presentation slides for Mini-LinkedIn.

Refer here for detailed document for design, architecture and testing.

Refer here for demonstration video of our project.

Codebase Directory Architecture: πŸ“

Mini_LinkedIn
β”œβ”€ README.md
β”œβ”€ client
β”‚  β”œβ”€ client.js
β”‚  β”œβ”€ commands.js
β”‚  β”œβ”€ package-lock.json
β”‚  └─ package.json
β”œβ”€ mininet
β”‚  β”œβ”€ func_def.py
β”‚  β”œβ”€ gen_data_company.py
β”‚  β”œβ”€ gen_data_user.py
β”‚  β”œβ”€ mini_test_company.py
β”‚  β”œβ”€ mini_test_user.py
β”‚  β”œβ”€ test_company.py
β”‚  β”œβ”€ test_user.py
β”‚  β”œβ”€ workload_company
β”‚  β”‚  β”œβ”€ address.txt
β”‚  β”‚  β”œβ”€ budget.txt
β”‚  β”‚  β”œβ”€ companyName.txt
β”‚  β”‚  β”œβ”€ description.txt
β”‚  β”‚  β”œβ”€ emails.txt
β”‚  β”‚  β”œβ”€ employmentType.txt
β”‚  β”‚  β”œβ”€ experience.txt
β”‚  β”‚  β”œβ”€ index.txt
β”‚  β”‚  β”œβ”€ indexOfApplicant.txt
β”‚  β”‚  β”œβ”€ indexOfJob.txt
β”‚  β”‚  β”œβ”€ industryType.txt
β”‚  β”‚  β”œβ”€ jobLocation.txt
β”‚  β”‚  β”œβ”€ jobTitle.txt
β”‚  β”‚  β”œβ”€ jobType.txt
β”‚  β”‚  β”œβ”€ password.txt
β”‚  β”‚  └─ skills.txt
β”‚  └─ workload_user
β”‚     β”œβ”€ address.txt
β”‚     β”œβ”€ content.txt
β”‚     β”œβ”€ emails.txt
β”‚     β”œβ”€ fnames.txt
β”‚     β”œβ”€ index.txt
β”‚     β”œβ”€ indexOfJobs.txt
β”‚     β”œβ”€ indexOfUser.txt
β”‚     β”œβ”€ lnames.txt
β”‚     β”œβ”€ password.txt
β”‚     β”œβ”€ skills.txt
β”‚     β”œβ”€ status.txt
β”‚     β”œβ”€ title.txt
β”‚     └─ viewUserIndex.txt
└─ server
   β”œβ”€ config.json
   β”œβ”€ db
   β”‚  β”œβ”€ constants.js
   β”‚  └─ db.js
   β”œβ”€ errorHandler.js
   β”œβ”€ feed
   β”‚  β”œβ”€ companyFeed.js
   β”‚  └─ userFeed.js
   β”œβ”€ models
   β”‚  β”œβ”€ company.js
   β”‚  β”œβ”€ jobPosting.js
   β”‚  β”œβ”€ post.js
   β”‚  └─ user.js
   β”œβ”€ modules
   β”‚  β”œβ”€ databaseAPI.js
   β”‚  β”œβ”€ helper.js
   β”‚  β”œβ”€ jobs.js
   β”‚  β”œβ”€ posts.js
   β”‚  β”œβ”€ serverAPI.js
   β”‚  └─ userControl.js
   β”œβ”€ package-lock.json
   β”œβ”€ package.json
   └─ server.js

Overall Structure πŸ”₯

The client-server-database architecture is shown below.

picture alt

Server Architecture πŸ’»

The server broadcasts its available states (routes) to the client and serves the requests by transitioning into appropriate states by receiving and/or sending data to the client. The server maintains session information regarding each client. The server acts as a finite state machine(FSM) as shown below.

picture alt

Client Architecture πŸ“²

Privileged features like updating profile, getting feed etc. are not accessible by the client without login. After logging in, the session is available for a limited duration and the client is logged out if the session expires or if the client chooses to logout. The client architecture is shown below.

picture alt

Features and Use Cases βœ…

βœ… The client is able to register and set up an account either as a company or normal user. 
βœ… The client is able to login and logout with Mini-LinkedIn. 
βœ… Users are able to set up a custom profile with fields like skills, about, experience etc. in case of 
   a user profile and set fields like company name, about etc. in case of a company profile.
βœ… Users are able to send and accept connection requests from other users.
βœ… Users are able to create LinkedIn posts, like posts and view posts of their connections.
βœ… Display the number of users who viewed a person’s profile.
βœ… Display the information of users who endorse specific skills.
βœ… Only companies are able to post job updates. All the registered users can search for job postings 
   with skill filters.
βœ… Companies are able to see the users who have applied for the job they posted.
βœ… The server is a concurrent program that can handle several client requests. 
βœ… Users are authenticated with the server before trying to access any of the features. 
βœ… When a user is prompted for a Login password, the user input for the password is obscured/masked.
βœ… A user can only see the posts of users who are in their connection. 
βœ… Job recommendations based on the skills provided by the user are provided.
βœ… Connection recommendations are provided.
βœ… Comments on post and multiple reactions (such as like, clap and support) on a connection’s post 
   are provided.

Instructions to Install Database ⬇️

  • Install MongoDB database for Ubuntu using instructions provided here

  • Make sure that a local instance of mongodb is running by running sudo systemctl status mongo

  • Fire up the terminal and type mongo. Then type use linkedin. Then type exit.

Configure the IP of your system in the /server/db/constants.js file for MONGOURI variable. You can get the IP of your host using ifconfig command on Ubuntu.

Instructions to Run πŸƒ

To run Mini-LinkedIn on host,

  • In the server and client folders, run npm install
  • In the mininet folder run pip3 install pickle and pip3 install faker
  • Use the command node server.js localhost to start the server from the directory /server/
  • Use the command node client.js localhost to start the server from the directory /client/

Now follow the instructions on the terminal window of client.

Available Commands (APIs) for Client πŸ“ƒ

{
    '0':'exitProgram',
    '1':'login',       
    '2':'signUpUser',
    '3':'signUpCompany',
    '4':'logout', 
    '5':'getMyProfile',
    '6':'updateProfileUser', 
    '7':'deleteAccount',
    '8':'getMyFeed',    
    '9':'like',    
    '10':'clap',           
    '11':'support',
    '12':'acceptConnection',   
    '13':'sendConnection',   
    '14':'postJob', 
    '15':'createPost',
    '16':'searchJob',
    '17':'feedCompany',        
    '18':'endorseSkill',
    '19':'applyToJob', 
    '20':'viewProfileUser',
    '21':'viewProfileCompany',     
    '22':'connectionRecommendation',
    '23':'jobRecommendation', 
    '24':'commentOnPost'
}

Instructions to Test on Mininet πŸ“ƒ

  • Install Mininet on VM by following the instructions provided here
  • Configure VM to setup "NAT Network" and "Host Only Network"

For Ubuntu 16.04 and less, there will be an interfaces file in \etc\network\ directory. For more recent releases copy the interfaces file from older versions and paste it in the directory.

  • Run python3 gen_data_user.py or python3 gen_data_company.py to generate workload for user and company respectively.
  • In the mininet folder, run sudo python3 mini_test_user.py to run tests for user or run sudo python3 mini_test_company.py to run tests for company.

Note: We have used a fat tree topology for testing, with depth 2 and fanout 4. Here is the structure of the Fat tree topology: picture alt

Networking Paradigm πŸ’»

Client and Server Interaction -

  • Since, TCP is a reliable data transfer protocol, all the transactions between client and server happens on TCP. The server opens up a socket and listens, as soon as a client sends a connection request, a TCP connection is set up between the client and the server and is persistent for the entire communication between them until any one of them closes the connection.

  • These are the steps in data exchange -

    • Data is encoded in a proper format by the sender which both the entities can understand.
    • It is payloaded directly in a TCP packet and sent to the receiver.
    • The receiver decodes data and takes appropriate actions.
  • Here, sender/receiver can be both client and server.

  • Hence, both the entities exchange data with TCP as the underlying protocol.

Server and Database Interaction-

The server communicates and performs operations on the database directly by using APIs provided by the database (happens over HTTP).

Implementation ▢️

Client-Server - Node.js

Node.js is an open-source, cross platform runtime environment for executing JavaScript code outside of a browser. It works on an event based model requiring callback functions which provides better performance than traditional thread based models.

A TCP connection can be easily set up on Node.js using sockets that allows client-server interaction in Mini-LinkedIn.

Database - MongoDB

MongoDB is a document-based NoSQL database with powerful querying capabilities, flexible schemas which suit the requirements of the Mini-LinkedIn tool. It is nicely compatible with Node.js, offers code-native data access (APIs) for the server to work and has enough documentation.

Protocol over TCP, Encoding and Decoding data in TCP packets

Data between the client and the server are sent by packing data into JSON format. After packing the data is sent via the TCP sockets in the server and the client. Both the client and the server parse the received data to perform the respective actions.

picture alt

For sending one single request or response -

The entire JSON data (be it sending a request from client for some command or sending response from the server for a command from client) is first made into a string by stringifying the JSON. Then this string is converted into a raw string of hex. Depending on the buffer size defined on the client and the server side, we create chunks of the string.

For each such complete raw string (formed from JSON) an end of response is marked using special characters ( EOI (End of Instruction) in our case ). Now, these packets are sent over TCP socket as a stream of bytes and are received by the other side socket. That socket keeps on collecting the received data, and checking at each stage if the EOI is received.

For receiving one single request or response -

The receiver receives raw text in a loop from the other party and tries to concatenate all the raw text received. For each text received, it also checks whether the current text is the end of this whole command’s response/request with the special end marked using special characters. When it detects the end of the message it sends the entire raw text string (that was formed by concatenating many packets) to the application logic where it can be parsed into JSON and processed and break current loop and go on for receiving next packets.

This is how the sender and receiver knows where a particular data ends which makes a transaction between client-server as request-response message.

Note: There is no extra overhead for sending JSON over TCP, as we stringify the JSON before sending it as a payload. Therefore, we are effectively sending a string over TCP and parsing that string at the other end of the connection.

Security aspects πŸ”’

  • As mentioned above, for every coming request from the client, the server verifies the token and command and then takes necessary action. If the authentication via the token fails the commands will not be handled by the server unless the client logins with proper credentials.

  • The client is not permitted to perform any command except login/sign up without logging in.

  • A user cannot access/use APIs for a company and a company cannot access/use the APIs for a user. For instance, only a user will be able to send connection requests to other users and a company cannot send connection requests. Similarly, a user will not be able to post jobs, only a company will be able to post jobs.

  • The passwords entered by the client are obscured using (*) symbol for security.

  • All the data sent over TCP connection is encoded before sending.

  • A user can only see posts of users who are in their connection. Similarly, a user who is already a connection of another user, can’t send another connection request. Similarly, a liked post cannot be liked again by the same user.

About

A cli-interactive application build on the top of Network layer, with custom protocols, client-server finite-state-machines and TCP socket. This has been tested with mininet using network typologies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 74.5%
  • Python 25.5%