The JSON Placeholder Service is a group of Spring Boot applications designed to mimic the functionalities of the JSONPlaceholder service. This service provides RESTful APIs for handling users, posts, comments, and albums, demonstrating a microservices architecture using Spring Cloud.
This project follows a microservices architecture, where each functionality is separated into individual services. The project leverages Spring Cloud for API gateway, service discovery, and configuration management.
- Spring Boot
- Spring Data JPA
- H2 Database
- Spring Cloud
- Docker
- Docker Compose
- Grafana
- Loki
- Prometheus
- Tempo
The JSON Placeholder Service is composed of the following microservices:
-
Post Service
- Folder: Post Service
- Manages posts.
-
Comment Service
- Folder: Comment Service
- Manages comments.
-
Album Service
- Folder: Album Service
- Manages albums.
-
Photo Service
- Folder: Photo Service
- Manages photos.
-
Todo Service
- Folder: Todo Service
- Manages todos.
-
User Service
- Folder: User Service
- Manages users.
- JDK 21
- Maven
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/nathsagar96/json-placeholder-service.git cd json-placeholder-service
-
Build and start the application using Docker Compose:
In the root directory (where
docker-compose.yml
is located), run:docker-compose up --build
This command builds the Docker images and starts the containers for all microservices.
-
Access the application at
http://localhost:{port}
, where{port}
is the port exposed by your API Gateway or individual services.
GET /posts
: Retrieve all postsGET /posts/{id}
: Retrieve a post by IDPOST /posts
: Create a new postPUT /posts/{id}
: Update a post by IDDELETE /posts/{id}
: Delete a post by IDGET /posts/user/{userId}
: Retrieve all posts by a specific user
GET /comments
: Retrieve all commentsGET /comments/{id}
: Retrieve a comment by IDPOST /comments
: Create a new commentPUT /comments/{id}
: Update a comment by IDDELETE /comments/{id}
: Delete a comment by IDGET /comments/post/{postId}
: Retrieve all comments by a specific post
GET /albums
: Retrieve all albumsGET /albums/{id}
: Retrieve an album by IDPOST /albums
: Create a new albumPUT /albums/{id}
: Update an album by IDDELETE /albums/{id}
: Delete an album by IDGET /albums/user/{userId}
: Retrieve all albums by a specific user
GET /photos
: Retrieve all photosGET /photos/{id}
: Retrieve a photo by IDPOST /photos
: Create a new photoPUT /photos/{id}
: Update a photo by IDDELETE /photos/{id}
: Delete a photo by IDGET /photos/album/{albumId}
: Retrieve all photos by a specific album
GET /todos
: Retrieve all todosGET /todos/{id}
: Retrieve a todo by IDPOST /todos
: Create a new todoPUT /todos/{id}
: Update a todo by IDDELETE /todos/{id}
: Delete a todo by IDGET /todos/user/{userId}
: Retrieve all todos by a specific user
GET /users
: Retrieve all usersGET /users/{id}
: Retrieve a user by IDPOST /users
: Create a new userPUT /users/{id}
: Update a user by IDDELETE /users/{id}
: Delete a user by ID
This project integrates with several tools for monitoring and logging:
Grafana provides a powerful and flexible interface for visualizing metrics. To access Grafana, navigate to
http://localhost:3000
.
Grafana is configured to connect with Prometheus to fetch metrics data and visualize it.
Prometheus is used for collecting and querying metrics. It scrapes metrics from your microservices and stores them for querying.
Loki is used for log aggregation. Loki integrates with Grafana, allowing you to correlate logs and metrics.
Tempo is used for distributed tracing. Tempo helps in tracing the flow of requests through your microservices.
Contributions are welcome! Please fork the repository and submit a pull request.
- Fork the repository
- Create a new branch (
git checkout -b feature-branch
) - Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature-branch
) - Create a new Pull Request