Skip to content

Projeto para estudar e praticar, focado na integração entre Spring Boot e MongoDB

Notifications You must be signed in to change notification settings

jose-meurer/Social-Media-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API for a Social Media Application

This is a REST API designed for a social media application. It provides endpoints for managing users, posts, and comments. Built with the latest technologies, it leverages the power of Spring Boot and MongoDB to deliver a robust and scalable solution for social media features.

Tech Stack

  • Java 21
  • Spring Framework
  • Spring Boot 3.4.1
  • Spring Data MongoDB
  • MongoDB 8.0.4
  • Maven

Modules

  • User Module: Handles user management.
  • Post Module: Manages posts created by users.
  • Comment Module: Manages comments on posts.

Installation & Run

  • To run the API, follow the steps below:
  • Update the database configuration inside the application.yaml file.
  • Set your local database URI and port number.
server:
  port: 8081

spring:
  data:
    mongodb:
      uri: mongodb://localhost:27017/app_db

API Root Endpoint

https://localhost:8081/api

User Module

  • GET /users: Returns a list of users.
  • GET /users/{id}: Returns a user by ID.
  • GET /users/{id}/posts: Returns the posts of a user by their ID.
  • POST /users: Creates a new user.
  • DELETE /users/{id}: Deletes a user by ID.
  • PUT /users/{id}: Updates a user by ID.

Post Module

  • GET /posts: Returns a list of posts.
  • GET /posts/{id}: Returns a post by ID.
  • GET /posts/searchtext?text: Returns posts that contain the searched text in their title, body, or comments.
  • GET /posts/{id}/comments: Returns comments for a post by its ID.
  • POST /posts: Creates a new post.
  • DELETE /posts/{id}: Deletes a post by ID.
  • PUT /posts/{id}: Updates a post by ID.

Comment Module

  • GET /comments: Returns a list of comments.
  • GET /comments/{id}: Returns a comment by ID.
  • POST /comments/{id}: Creates a comment for a post by its ID.
  • DELETE /comments/{id}: Deletes a comment by ID.
  • PUT /comments/{id}: Updates a comment by ID.

Sample API Response for Posts

GET localhost:8081/api/posts/678e921efae5ff2f043f0b88

  • Response
{
  "id": "678e921efae5ff2f043f0b88",
  "date": "2024-01-15T08:30:00Z",
  "title": "Exploring the Future of Technology",
  "body": "Technology is evolving rapidly, with innovations that promise to transform our lives. In this post, we will explore some of these technologies and their impact.",
  "author": {
    "id": "678e921efae5ff2f043f0b85",
    "name": "Maria Brown"
  }
}

About

Projeto para estudar e praticar, focado na integração entre Spring Boot e MongoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages