Skip to content

chiragbaid7/PiperSocial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 

Repository files navigation

Hosted Here

https://pipersocial.netlify.app/

Walk through

Piper.Social.mp4

Tech Stack

ExpressJS NodeJS SQL React AWS Netlify image

Project Directory Structure

│
├── src
|   ├── API
|   |   ├── routes
│   │   │   └── v1
|   |   |      ├── user 
|   |   |      |   ├── userRoutes.js
|   |   |      |   └── schema.js
|   |   |      ├── posts
|   |   |      |   ├── postsRoute.js
│   │   |      |   └── schema.js  
│   │   │      ├── index.js
│   │   │      └── followRoute.js
|   |   └── controller
│   │       └── v1
|   |          ├── postsHandler.js
|   |          ├── userHandler.js
|   |          └── followHandler.js         
|   ├── domain
│   │   ├── models
|   |   |   ├── sequilze
|   |   |   │   ├── index.js
|   |   |   │   ├── followModel.js
│   │   |   │   ├── postsModel.js
|   |   |   │   └── userModel.js
|   |   |   └── database.js
│   │   └── data-access / repository
|   |       ├── userData.js
|   |       ├── followData.js
|   |       └── postsData.js
│   ├── storage
│   │   └── AWS_S3.js
│   ├── service
|   |   ├── postsService.js
|   |   ├── FollowSerivice.js
│   │   └── UserService.js
|   |   
│   ├── middleware / helpers
|   |   ├── validation.js
│   │   ├── auth.js
│   │   └── ErrorHandler.js 
|   ├── utils
|   |   ├── Error
|   |   │   ├── ApplicationError.js
|   |   │   ├── errorFactory.js
|   |   │   ├── customError.js
|   |   │   └── commonError.js
|   |   └── Response 
|   |       └── response.js
│   ├── config
│   │   └── index.js
│   │  
├── app.js
├── package.json
├── Readme.md
├── package-lock.json

System Design

Backend Architecture

anatomy

Diagram Code
Title: Backend Architecture
participant client
participant web server as webserver
participant controller
participant service
participant domain
participant storage

client -> webserver:  POST /api/v1/Posts
webserver -> controller: post_handler()
controller -> service: post_service()
service -> storage: upload_AWS(image)
service -> domain: post_domain(id)
domain -> service: domain_model
service -> controller: domain_model
controller -> webserver: JSON or HTML Response
webserver -> client: HTTP Response

Database Schema

REST API

POSTS API

 get a list of current user's posts             GET      http:://api/v1/users/posts

 get a particular post                          GET      http:://api/v1/users/posts/{post_id}

 get current user's friends posts               GET      http:://api/v1/users/posts/following

 create a post                                  POST     http:://api/v1/users/posts

 delete a post                                  DELETE   http:://api/v1/users/posts/{post_id}

 get a list of user's posts                     GET      http:://api/v1/users/{user_id}/posts


COMMENT API

 get all comments on a post                     GET      http:://api/v1/users/posts/{post_id}/comments

 create a comment on a post                     POST     http:://api/v1/users/posts/{post_id}/comments

 delete a comment of a post                     DELETE   http:://api/v1/users/comments/{comment_id}

LIKES API

 like  a post                                   PUT      http:://api/v1/users/posts/{post_id}/likes

 unlike a post                                  DELETE   http:://api/v1/users/posts/{posts_id}/likes

 List of users who have liked the post          GET      http:://api/v1/users/posts/{post_id}/likes

FOLLOW API

  follow a user                                  PUT      http:://api/v1/users/following/{friend_id}

  unfollow a user                                DELETE   http:://api/v1/users/following/{friend_id}

  get all users I follow                         GET      http:://api/v2/users/following

System APIs Examples

  • createUser(name,email,password)

    • Response Body: 200
      {
          "result": {
              "user_id": 5
          },
          "success": true,
          "Token": "jwtToken"
      }
  • createUser(email,password)

    • Response Body: 400
      {
      "error": {
          "name": "AppError",
          "type": "APP_NAME",
          "code": "VALIDATION_ERROR",
          "message": "\"name\" is required",
          "statusCode": 400,
      },
      "success": false
      }

Features

  • Users can submit text or images as posts.
  • Users feed are populated of people they are following sorted by latest posts on top.
  • Users can follow each other.
  • Users can likes posts.
  • JWT Tokens, make requests with a token after login with Authorization header with value Bearer yourToken where yourToken is the signed and encrypted token given in the response from the login process.

Future enhancements.

  • Users should be able to submit both texts and images together as multi-form data.
  • Users should be able to see the preview of the image after uploading in the frontend (Image can be stored as blob).
  • Users should be able to submit video contents as well.
  • Improve UI and add more features.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published