Skip to content

VatsalBhuva11/social-media-backend

Repository files navigation

Name: Vatsal Bhuva
Enrollment Number: IIT2022004
Bucket: Backend


The Social Media Mastery

A fully functioning social media website's backend, crafted together using Express, Node.js, Multer, bcrypt, and more!


Libraries used

  1. express

    To handle the different HTTP requests.

  2. mongoDB

    Backbone of it all. Stores all the information, using which the HTTP requests access/store information

  3. node.js

    To install the different npm packages.

  4. multer

    To upload and store files as posts/pictures/videos.

  5. bcrypt

    Security is key. This enables hashing and salting passwords to secure the user's information. So, in the event of a data leak, only the hashed password is available which is very hard to crack.

  6. jwt

    Enables you to "stay logged in" across the different routes. JWT handles the authentication part so you don't have to login again and again.

  7. cookieParser

    Storing the JWT key in a cookie allows the JWT to be verified, ensuring that only a logged in user can perform most of the activities.

Installation

As this application is composed entirely of the backend part of a social media website, we require Postman to make HTTP requests to the various routes.

Paste the following link to open postman in your browser to directly simulate the requests.

https://www.postman.com/universal-comet-532028/workspace/webd-task2-iit2022004/collection/29122774-5240a42b-9036-4b8e-912c-5082ffd517c5?action=share&creator=29122774

Usage

  • Expand the 'Requests' tab to view the titles of the different requests that you make

  • screenshot

  • The userRequests tab enlists all the user-related options that are available for this social media website. Likewise, the postRequests tab enlists all the post-related options that a user can make.

  • image

  • To get started, click on the "Register" option under the userRequests tab. Under the "Body" section on the right, and under the "x-www-form-urlencoded" tab, enter the details of the user that you want to register as (remember your username and password!)

  • image

  • Once registered, head over to the "Login" section, and login with the correct credentials. Without logging in, you will not be able to access the various different functionalities, other than being able to view the profile of users (just like instagram allows you to view the profile of another user without logging in.)

  • image

  • Upon successfully logging in, you should receive a "token" in the response section at the bottom. This is your JWT token, which is used to authenticate you as a logged in user across the different routes. You don't need to store the token anywhere, it's taken care of by 🍪 ;)

  • image


    Let's have a look at the different functionalities of the website, and how to use them.

    User Requests

  • Logout: Nothing to do; click on the send option to log out from the currently logged in user.
  • View profile: This lets you view the profile information of any user. It does not require for you to be logged in. Type in the username of the user who's profile you want to view under the "Params" tab, not the "Body" tab like we've been doing so far.

  • image

  • Follow request: Want to make friends? Follow them up! Following a user lets you see their posts in your feed. Enter their username in the "Params" tab to follow them.

  • Unfollow request: Same functionality as the Follow feature.

  • Update user password: Didn't I tell you to remember your password? No worries, got your back. Head over to this request to change your password. The new password should be entered as the value to the password attribute under the "Body -> x-www-urlencoded" tab.

  • image

  • Update user bio: Let others get to know more about you through your bio! Update your bio using this request, and showcase your specs!

  • Update profile pic: Haven't seen me yet? View my profile pic! Under the "Body -> form-data" section, select the profile pic that you want to upload!

  • image

    Note: the profile won't be visible as this is just the backend part. The image can, however, be rendered using frontend as the image's relative path is stored in the database. The same applies to viewing a user's posts as well.


    Post Requests

  • Create post: Share where you've been this summer or your outing with your friends and much more! Head over to the "Body -> form-data" section, and select the image/video that you want to post! Don't forget to add a suitable magical caption to captivate your followers!

  • image

  • Like a post: Show your support to your close ones by liking their posts! Under the "Params" section, enter the username to whom the post belongs, and the ID of the post that you want to like. NOTE: the postID can be obtained by viewing the posts/profile of that user, and in the posts array will be listed all the posts with each post having a unique "_id" attribute. Copy the inner text (don't copy the ObjectID part) and paste it in the postID attribute. (don't be cheeky to like your own post or like the same post twice :) i've got that covered :))

  • image image

  • Dislike a post: Same usage as liking a post.

  • Comment on a post: Express (no pun intended) your thoughts on your friend's posts to flatter them :) Enter the username and the postID (the same way as in liking a post), and enter your comment in the "Body -> x-www-form-urlencoded" section, under the "comment" attribute.

  • image

  • View feed: Following your friends? View what they're upto in your feed! Your feed shows your your following's posts in a randomized order to make it more natural! Just click the send button to view your feed!

  • View posts of a user: View the posts of a specific user by heading over to this section, and entering the username of that user under the "username" attribute, in the "Params" section.

  • image

  • Delete a post: Uploaded the wrong post? Or did you have a "felt cute might delete later" moment? Delete your post right away by mentioning the ID of your post!

  • Delete a comment: Didn't like what someone commented on your post? Mention the postID, and the commentID of the comment to delete the comment right away! The postID and the commentID can be obtained by viewing the profile or the posts of a user. The commentID will be the value of the "commIndex" attribute of the specific comment.

  • image


    Contacts

    Mail me at: vatsalbhuva11@gmail.com

    LinkedIn: https://www.linkedin.com/in/vatsal-bhuva-673587233/ Instagram: https://www.instagram.com/_.vb11/

    About

    No description, website, or topics provided.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published