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)
This project requires that you have the following installed on your personal computer
- Docker and Docker compose
- npm or yarn
Clone the repository
git clone https://github.com/sauce-kode/sm-api.git
cd sm-apiInstall dependencies
Depending on your package manager, run yarn or npm installGenerate 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.keyGenerate .env files
cp .env.example .env
cp .env.docker.example .env.dockerStart Docker containers
Start your docker application and run docker-compose up -dStart the application server
yarn start or npm run startSocial Media API Documentation
The data model used for this project is shown below
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.
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.
