Skip to content

sauce-kode/sm-api

Repository files navigation

Social Media API

A REST API service for a social media platform

Features implemented:

  • User signup
  • User Login (using JWT)
  • Create posts
  • Fetch posts
  • Like or unlike posts
  • Comment or uncomment on a post
  • Follow or unfollow other users
  • Search (Posts)

Installation

This project requires that you have the following installed on your personal computer

Clone the repository

git clone https://github.com/sauce-kode/sm-api.git
cd sm-api

Install dependencies

Depending on your package manager, run yarn or npm install

Generate JWT keys

You can skip this step as the public and private keys have been attached, which would not be done in a production environment. However, to generate new ones:

ssh keygen -t rsa -b 2048 -m PEM -f private.key
openssl rsa -in private.key -pubout -outform PEM -out public.key

Generate .env files

cp .env.example .env
cp .env.docker.example .env.docker

Start Docker containers

Start your docker application and run docker-compose up -d

Start the application server

yarn start or npm run start

API Documentation

Social Media API Documentation

Data Model

The data model used for this project is shown below

Social Media Data Model

Notes

- Security

RS256 signing algorithm is used to sign JWT tokens when generating them. This is to ensure a high level of security through the private/public key pair used in generating and verifying tokens as opposed to the same single secret key of the HS256 signing algorithm.

- Search

The two columns (title and content) in the posts table are indexed with Generalized Inverted Indexes (GIN) and a full text search is done on the posts table. GIN was chosen because it is particularly suitable for full text searches and also because of of its efficient indexing, fast search performance and concurrent updates support which would be an important feature for an application like this.

About

A simple REST API for a social media application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors