Skip to content

Backend API for a social media app using MERN stack (Mongo , Express, Node and React soon)

Notifications You must be signed in to change notification settings

yoanastamenova/Social_media--back

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Media API Project ❤️

Welcome to my social media REST API, a Twitter-inspired backend project, designed and developed with versatility and robust functionality in mind.


Table of contents 📝
  1. About the project
  2. Deploy
  3. Stack
  4. Database Diagram
  5. Clone
  6. Endpoints
  7. Future functionalities
  8. Contributions
  9. Development
  10. Appreciations
  11. Contact

About the project

The main idea for the project was recreating a social media and to be exact I had Twitter (now X) in mind. Constructed with the use of non-relational database technology (MongoDB in conjunction with the Mongoose library), this API gives birth to a social media application where users can engage, share, and interact through texts posts.

Core Features

Our API boasts an array of features focused on delivering an engaging and seamless user experience. The core functionalities include:

  • User Management: Enabling users to register, log in, update their profile, and check out their personal details on their profile.

  • Post Management: Users can create, update, and delete their posts. They can also view their own posts as well as posts created by other users. The option to find a specific post adds an additional layer of navigation.

  • Interaction: Users can like or dislike posts to express their sentiments. A follow/unfollow feature is also available, allowing users to curate the posts they see based on their preferences.

  • Admin Control: Special functionalities are available exclusively for administrators and super administrators, ensuring streamlined content and community management.

  • In addition, the use of seeders offers a quick and efficient method for data insertion during a database refresh. Middleware support exists for implementing authentication processes such as tokenization.

With successfully achieving the development milestone and deploying the project to production, the next exciting step is creating a dynamic front-end view using React. This will not only enhance the user interface but also ensure a cohesive, interactive, and intuitive user experience!

Stay tuned for this exciting update! :)

Deploy 🚀

Click here! 🚀🚀🚀

Stack

Used technologies for the project:

Schema from Mongo

  • 1 Strong entitiy - Users (can exist by itself without depending on another entitiy).
  • 1 Weak entitiy - Posts (depends on users, it must be written/posted by a user).

Even that we have a non relational database project, there is a relation between the posts and users as a post cannot exist by itself. A post can have likes such as user can have users that he/she follows and on the contrary users that are following.

Local installation guide

  1. Clone the repository from the url: git clone https://github.com/yoanastamenova/Social_media.git
  2. Connect the cloned repo with MongoDB
  • If you dont have Mongo we can use already existing Mongo container from Docker with the following command: docker run -d -p 27017:27017 --name mongo -v mongo_data:/data/db -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=root mongo:latest
  1. npm install (to get all the npm needed packages)
  2. npm run dev to run our server
  3. npm run seed to fill our documents

Endpoints

Authentication 👓

Method URI Action Auth Body
POST /api/auth/register Register user N/A (public) { "email": "[email protected]", "password": "yourPassword" }
POST /api/auth/login Login user N/A (public) { "email": "[email protected]", "password": "yourPassword" }

Users 👦🏻 👩🏻

Method URI Action Auth Body
GET /api/users/all View all users Token (admin)
GET /api/users/profile View user profile Token (user)
PUT /api/users/profile/update Update user profile Token (user) info to update
GET /api/users/email Get user by email Token (user) "email": "[email protected]"
DELETE /api/users/:id Delete user by id Token (user)
PUT /api/users/role Update user role Token (user) "role": "admin"

Posts ✍🏻

Method URI Action Auth Body
POST /api/posts/create Create post Token (user)
DELETE /api/posts/delete/:id Delete post Token (user)
PUT /api/posts/update/:id Update post Token (user) info to change
GET /api/posts/own Get own posts Token (user)
GET /api/posts/all Get all posts Admin
GET /api/posts/:id Get post by id Admin
GET /api/users/posts/user/:id Get posts by a user id Admin

Like 🫶🏻

Method URI Action Auth Body
POST /api/posts/likePost/:id Like/Dislike post by id Token (user)

Follow 👋🏻

Method URI Action Auth Body
POST /api/users/followUnf/:id Follow/Unfollow user from id Token (user)

Timeline 🏄🏻‍♂️

Method URI Action Auth Body
GET /api/users/timeline Shows user timeline Token (user)

Future functionalities

✅ Add timeline option

⬜ Add user biometrics

⬜ Include profile privacy options

Contribute to the project

Feel free to suggest an improvment or functionality to my project.

There are two ways of doing this:

  1. Opening an issue
  2. Creating a fork of the repository
    • Creating a new branch
      $ git checkout -b feature/yourUsername -feat
      
    • Make a commit with your changes
      $ git commit -m 'feat: this X thing'
      
    • Make a push to the branch
      $ git push origin feature/yourUsername -feat
      
    • Opening a Pull Request

Development:

const developer = "yoanastamenova";

console.log("Developed by: " + developer);

Appreciations:

Forever gratefull to GeeksHubs Academy for the oportunety to learn and grow on my career path. <3

Contact

About

Backend API for a social media app using MERN stack (Mongo , Express, Node and React soon)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published