Creating the design

As we mentioned before, this project will be like a social media platform; the users can post their statuses and others can see them in the timeline and can like it, add comments, and so on. For this project, there won't be a UI for the server side. We will create a backend server. To create this server, we will have to create a REST API that can be used by the client application. To do this, we need to create a database based on our REST API.

First of all, we split our database table names, the HTTP function requests, and the URL path.

There will be four tables:

Let's have a look at each of them:

  • One is for the users. All their information will be stored in a table named Profile.
  • There will be another table named Post, where all the posted statuses of all the users will be stored.
  • Another table named Comment will store all the comments of all the posted statuses.
  • Another table named LikeObj will store all the likes of all the posted statuses, but we won't provide this feature for the comments.

Now we will create the URL path of the REST API using an HTTP function request, and all the output will be designed for JSON. We are using JSON because it is very easy to handle and understand for all developers. 

Regarding the Profile table, here are the URL paths of the HTTP requests:

  • POST http://localhost:8080/user/new: This request will create a user profile with all the information the user has posted on their profile
  • GET http://localhost:8080/user/{id}: This request will get the details of the given id holder
  • PUT http://localhost:8080/user/{id}: This request will update the user details of the given id holder
  • DELETE http://localhost:8080/user/{id}: This request will delete the user details of the given id holder, including all the posts, comments, and likes from this user

Regarding the Post table, here are the URL paths of the HTTP requests:

  • POST http://localhost:8080/post/{id}/new: This request will create a post from the id holder
  • GET http://localhost:8080/postsThis request will get all the post's details
  • GET http://localhost:8080/post/{id}: This request will get the post details of the given id holder
  • DELETE http://localhost:8080/post/{id}This request will delete the post details of the given id holder, including all the comments

Regarding the Comment table, here are the URL paths of the HTTP requests:

  • POST HTTP://localhost:8080/comment/{post_id}: This request will create a comment on the post_id holder
  • DELETE HTTP://localhost:8080/comment/{post_id}: This request will delete the comment of the given post_id holder

Regarding the LikeObj table, here are the URL paths of the HTTP requests:

  • POST http://localhost:8080/like/new: This request will like a post of the post_id holder
  • DELETE ttp://localhost:8080/like/newThis request will unlike a post of the post_id holder
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.97.170