/social-network-Apis

API for imaginary social network

Primary LanguageTypeScript

social-network-Apis

API for imaginary social network

npm version npm version License: MIT

Table of Contents

Introduction

This is a RESTful API for an imaginary social network.

Project Structure

├── src
├── .env.sample
├── .eslintrc
├── .gitignore
├── .prettierrc
├── docker-compose.yml
├── Makefile
├── nest-cli.json
├── package.json
├── README.md
└── tsconfig.build.json
└── tsconfig.json

Project Database Architecture

User Model

  • id
  • userName
  • fullName
  • email
  • password
  • refreshToken
  • dateOfBirth
  • profilePictureUrl
  • createdAt
  • updatedAt
  • posts (Post model)

Post Model

  • id
  • title
  • content
  • picture
  • author (User model)
  • authorId (Foreign key from User model)
  • createdAt
  • updatedAt
  • deletedAt

The diagrammatic representation of the models can be found here

ER-Diagram

Features Implemented

  • Sign up
  • Sign in
  • Create tokens ( A refresh token when access token get expired)
  • Logout
  • Get a single user (userMe)
  • Fetch users with pagination
  • Change of password
  • Update user information
  • Upload user profile picture
  • Create post with either with picture upload or not
  • Fetch posts with pagination
  • Fetch single post
  • Fetch posts by author
  • Soft delete post bt author
  • Update post by author with either with picture upload or not
  • Search functionality for post and user

Getting Started

Dependencies

This project uses Nest.js It has the following dependencies:

Prerequisites

  • Ensure you have NodeJS installed by entering node -v on your terminal If you don't have NodeJS installed, go to the NodeJS Website, and follow the download instructions

Getting the Source

You can clone this project directly using this command:

git clone https://github.com/AbonyiXavier/social-network-Apis

Installation & Usage

  • After cloning the repository, create a .env file from .env.sample and set your local .env. variable(s).
cp .env.sample .env
  • Install the dependencies
yarn install
  • You can run the server using
yarn run start:dev

Using the Makefile to Testing

How to run all tests locally

  1. make install - Installs dependencies.
  2. make dev - Run the server
  3. make build
  4. make gen-migrate - Generate migration.
  5. make lint - Lint code.
  6. make studio - Opens up a prisma virtual interface for your database
  7. make up - Start up your app from docker-compose.yml file

Working Routes

API Endpoints

  • Public API documentation of this project is available on postman docs

  • To test create post with picture or update post with picture or upload single profilePictureUrl for user, kindly download Altair GraphQL Client.

    Test for updatePost with picture on Altair GraphQl Client altair client

Improvements

  • The authentication flow could have email notification sent to users upon signing up for verification to avoid bot users registering to our system.

  • Forget and reset password should be considered as part of the authentication flow.

  • The cloudStorageService such as (e.g., AWS S3, Google Cloud Storage, cloudinary) should be responsible for handling the file upload (The post picture or user profilePictureUrl) to a cloud storage system instead of saving them into a local directory (./src/upload).

  • Implement Role and Permission privileges.

  • We could have more models such Comment, Like, Follower or Friendship with extended feature of implementing mentions, hashTags, liking a post and comments and been able to follow a user.

License 💥

This project is under the MIT LICENSE