Reddit Backend Project Using Microservice Architecture

Search for a command to run...

No comments yet. Be the first to comment.
When a simple payment API becomes a distributed systems problem

A Deep Dive into Large Language Models and Their Building Blocks

In the past three years, I’ve mostly worked with startups, and the common approach was always “build fast, optimize later.” It definitely helped us move quickly, but when the user base started growing, we ran into scaling issues that were tough to ha...

Recently, while working on my Spring Boot backend, I stumbled on one of those optimizations that gives huge results for minimal effort: GZIP compression. No complex setups. No code changes. Just a few config tweaks and boom—API payloads dropped by 80...

Microservices represent a software architecture approach where a complex application is built as a collection of small, independent services, each running in its process and communicating with others through well-defined APIs. The key principle is to decouple various functionalities into modular services, promoting flexibility, scalability, and ease of maintenance. Each microservice is responsible for a specific business capability and can be developed, deployed, and scaled independently.
Enhanced modularity: Microservices break down applications into smaller, independent services.
Scalability: Each microservice can be scaled independently to meet specific demands.
Parallel development: Developers can work on individual components without affecting the entire system.
Flexibility: Easy integration of new features and updates without disrupting the entire application.
Resource optimization: Efficient utilization of resources by scaling specific microservices as needed.
The project consists of 6 microservices. Each service is independent and loosely coupled so it doesn't affect other services.
Java version: 17, Dependency Management: Maven, Springboot Version: 3.2+

Spring Cloud Config is a tool in the Spring Cloud ecosystem that centralizes and manages application configuration settings. Instead of hardcoding configurations in every service we can fetch all the configurations from a central repository which eases the management and updating of config.
It also helps in having different configurations for different environments by creating multiple YML files for each environment. It also facilitates dynamic updates without the need for service redeployment.
I have used the following dependency to utilize the Spring Cloud config
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
</dependency>

Using Eureka Discovery service here. helps microservices find and communicate with each other in a distributed system.each service registers itself with Eureka, and other services can look up its location when they need to interact with it.
Automatically locate and connect to services without hardcoding their locations, making the system more flexible and scalable.
LB:Distribute incoming requests among multiple instances of a service to improve performance and reliability.

An API gateway acts as a central hub for managing and securing interactions between clients and backend services. It streamlines tasks like authentication, authorization, and routing, enhancing security, performance, and scalability. By providing a unified entry point, it simplifies client access and enables monitoring and analytics for better insights and decision-making. In summary, API gateways play a vital role in modern architecture by optimizing communication and abstracting complexities.

Manages user-related operations such as user creation, retrieval, update, deletion, status change, searching, filtering, and association with subreddits, posts, and comments.

Manages subreddits, offering functionalities for creating, retrieving, updating, and deleting subreddits. Additionally, it handles user membership management within subreddits, association of posts, and interaction with comments.

Comprising controllers for comments, posts, and votes, this service manages the core functionalities of the Reddit clone project. It facilitates the creation, retrieval, updating, and deletion of comments and posts, as well as the handling of voting interactions, ensuring a robust and engaging user experience.

Check out my project on GitHub