Microservice based backend for a blogging platform. It has 4 services - authentication, blog, feed, and user. Swagger UI for these services is also available.
MIT License
Microservice based backend and Next.js frontend for a micro-blogging platform.
It offers four distinct API services that collectively enable various functionalities:
login
, logout
, and registration
, ensuring secure access to the platform.create
, update
, and delete
their blog posts. Additionally, they have the ability to like
or dislike
posts, promoting user engagement and feedback.follow
or unfollow
other users, enabling social connections within the platform. Furthermore, users can delete
their account if desired.all posts
, posts from followed
authors, liked
posts, posts by a specific user, or a particular post
.localhost:8084/swagger/index.html
Try this API service in postman.
.env.example
file. Follow the steps below to set up the necessary environment variables:.env.example
file and copy its contents..env
file..env.example
file.docker network create my-network
docker compose up
.Note: The
docker compose up
command will automatically set up the database. However, if it fails, please refer to the "DB-Setup" section for further instructions.
Frontend is a Next.js 13.x application bootsrapped by create-next-app
After cloning the project:
Navigate to http://localhost:3000 to access the frontend of this project.
After running docker compose up
, perform the following steps:
docker exec -it db bash
.psql -U postgres
to access the PostgreSQL command-line interface.CREATE DATABASE blogx_db;
.\c blogx_db
.init.sql
file located in the \db
folder.init.sql
file.By following these steps, you should be able to set up the local environment and initialize the necessary database for the service.
endpoint | method | success statuscode | auth tokenrequirement |
---|---|---|---|
/ | GET | 200 | NO |
/register | POST | 201 | NO |
/login | POST | 200 | NO |
/logout | POST | 202 | YES |
endpoint | endpoint | success statuscode | auth tokenrequirement |
---|---|---|---|
/ | GET | 200 | NO |
/addBlog | POST | 200 | YES |
/updateBlog | PATCH | 200 | YES |
/deleteBlog | DELETE | 204 | YES |
/like?post_id= | GET | 200 | YES |
/dislike?post_id= | GET | 200 | YES |
endpoint | method | success statuscode | auth tokenrequirement |
---|---|---|---|
/ | GET | 200 | NO |
/allPosts | GET | 200 | YES |
/allPostsPageWise?page_no= | GET | 200 | YES |
/postWithId?post_id= | GET | 200 | YES |
/postWithUserId?user_id= | GET | 200 | YES |
/myPosts | GET | 200 | YES |
/followingUsersPosts | GET | 200 | YES |
/myLikedPosts | GET | 200 | YES |
endpoint | method | success statuscode | auth tokenrequirement |
---|---|---|---|
/ | GET | 200 | NO |
/delete | DELETE | 204 | YES |
/follow?toFollowId= | POST | 200 | YES |
/unfollow?toUnfollowId= | POST | 200 | YES |
As this is the first version of this backend, each service endpoint is preceded by
/v1/api
Database used - PostgreSQL
Table name | Description |
---|---|
users | Stores the details of users. The password is not stored directly; it is hashed for security purposes. |
posts | Stores the blog posts created by users. |
user_followers | Represents the relationship between users, where the follower_id follows the following_id . |
user_likes | Records the likes given by users (user_id) to specific posts (post_id). |