Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

8 Commits

Folders and files

Repository files navigation

LinkedInn - LinkedIn Inspired Social Media Platform

A production-style, event-driven microservices application built with Spring Boot, Spring Cloud, Kafka, Neo4j, PostgreSQL, and Kubernetes.


Overview

LinkedInn is a LinkedIn-inspired social networking platform built using a microservices architecture to demonstrate the design of scalable and resilient distributed systems.

  • Microservices Architecture
  • Service Discovery
  • API Gateway Pattern
  • Event-Driven Communication
  • Graph Databases
  • Asynchronous Messaging
  • Cloud Native Deployment using Kubernetes

The platform allows users to:

  1. Register and manage profiles

  2. Create posts (with image uploads)

  3. Build professional connections

  4. Discover 1st, 2nd, and 3rd degree connections

  5. Receive notifications

  6. Handle communication between services efficiently


πŸ— Architecture Overview

High-Level Architecture

Client requests never directly communicate with individual services.

Instead, requests flow through the API Gateway, which routes traffic to the appropriate microservice.

Client
   ↓
API Gateway
   ↓
Service Discovery (Eureka)
   ↓
Microservices

Architecture Diagram

Local Development Architecture

Screenshot 2026-06-22 at 11 55 30β€―PM

Kubernetes Deployment Architecture

Screenshot 2026-06-22 at 11 55 58β€―PM

βš™οΈ Tech Stack

Category Technologies
Backend Spring Boot
Microservices Spring Cloud
Service Discovery Netflix Eureka
API Gateway Spring Cloud Gateway
Inter-Service Communication OpenFeign
Authentication Spring Security + JWT
Relational Database PostgreSQL
Graph Database Neo4j
Messaging Apache Kafka
File Storage AWS S3
Containerization Docker
Orchestration Kubernetes
Ingress Controller NGINX Ingress
Persistent Storage PVC (Persistent Volume Claims)

Microservices

1. User Service πŸ‘€

Responsible for user-related operations.

Features

  • User Registration
  • User Authentication
  • Profile Management
  • Profile Information Retrieval

Database

PostgreSQL


2. Post Service πŸ“

Handles everything related to posts.

Features

  • Create Posts
  • Fetch User Posts
  • Feed Retrieval
  • Support Image Posts

Database

PostgreSQL


3. Connection Service 🀝

This service models the professional network.

Instead of using relational joins, connections are stored in a graph database.

Why Neo4j?

LinkedIn-like applications require traversal queries such as:

  • Who are my direct connections?
  • Who are my second-degree connections?
  • Who can I reach through my network?

These queries become extremely efficient using graph databases.


Connection Model

When User A sends a request to User B:

(User A)
    |
REQUESTED
    |
(User B)

A directed edge is created.


When User B accepts:

(User A) ---- CONNECTED_TO ---- (User B)

A bidirectional relationship is established.


Supported Queries

  • First Degree Connections
  • Second Degree Connections
  • Third Degree Connections
  • Connection Search
  • Pending Requests
  • Accept Requests

4. Notification Service πŸ””

Responsible for generating notifications.

Features

  • Post Notifications
  • Connection Notifications
  • Future extensibility for:
    • Email Notifications
    • Push Notifications
    • Real-Time Alerts

Database

PostgreSQL


5. Upload Service πŸ“Έ

Handles media uploads independently.

Why Separate Upload Service?

Uploading files can involve:

  • Validation
  • Compression
  • Storage
  • CDN Integration

Keeping it isolated prevents bloating the Post Service.


Features

  • Upload Post Images
  • AWS S3 Integration

πŸ” Service Discovery using Eureka

In local development, all services register themselves with Eureka.

Each service contains Eureka Client configuration.

Example:

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka

Registration Flow

Service Starts
      ↓
Registers with Eureka
      ↓
Eureka stores:
    Service Name
    IP Address
    Port

Request Flow

API Gateway
     ↓
Ask Eureka:
"Where is Post Service?"
     ↓
Eureka returns address
     ↓
Gateway forwards request

This eliminates hardcoded service URLs.


🌐 API Gateway

The API Gateway acts as the single entry point to the system.

Responsibilities include:

  • Request Routing
  • Authentication Filters
  • Rate Limiting (future enhancement)
  • Logging
  • Cross-Cutting Concerns
  • Load Distribution

Example routing:

routes:
  - id: post-service
    uri: lb://POST-SERVICE
    predicates:
      - Path=/posts/**

πŸ”„ Inter-Service Communication

Microservices communicate using OpenFeign.

Feign acts as a declarative HTTP client.

Instead of manually writing REST calls:

RestTemplate.exchange(...);

We simply define:

@FeignClient(name = "connection-service")
public interface ConnectionClient {

    @GetMapping("/connections/{userId}")
    List<Long> getConnections(@PathVariable Long userId);

}
Screenshot 2026-06-22 at 11 44 04β€―PM

Feign internally:

  • Discovers services through Eureka
  • Performs HTTP calls
  • Waits for responses
  • Converts responses into Java objects

⚑ Event-Driven Architecture with Kafka

One of the key highlights of this project.


The Problem

Suppose User A creates a post.

We need to notify hundreds or thousands of connections.

If the Post Service waits until every notification is generated:

  • Post creation becomes slow.
  • User experience degrades.
  • Notification failures impact posting.

The Solution: Kafka

Post creation and notification generation are decoupled.


Workflow

User Creates Post
       ↓
Post Service
       ↓
Connection Service
(Get Connections)
       ↓
Kafka Producer
Publishes Event
       ↓
Kafka Topic
       ↓
Notification Service
(Kafka Consumer)
       ↓
Notifications Created

Why Kafka?

Faster User Experience

The user immediately receives:

"Post Created Successfully"

without waiting for notifications.


Fault Tolerance

Even if Notification Service is temporarily down:

  • Events remain in Kafka.
  • Notifications are processed once the service recovers.

Scalability

Consumers can scale independently.


Reliability

Events are persisted until consumed.


☁️ AWS S3 Image Upload Flow

User Uploads Image
        ↓
Post Service
        ↓
Upload Service
        ↓
AWS S3 Bucket
        ↓
Image URL Returned
        ↓
Post Saved

Benefits:

  • Efficient storage
  • Highly durable
  • Scalable
  • CDN-friendly

☸️ Kubernetes Deployment

The entire application can be deployed on Kubernetes.


Why Kubernetes?

Kubernetes provides:

  • Self-Healing
  • Scaling
  • Service Discovery(k8s own DNS service)
  • Networking
  • Load Balancing
  • Rolling Updates

Deploying Stateless Services

Microservices are deployed using:

Deployments

Used for:

  • API Gateway
  • User Service
  • Post Service
  • Connection Service
  • Notification Service
  • Upload Service

Why Deployments?

These services are stateless.

If a pod crashes:

Old Pod Dies
      ↓
New Pod Starts
      ↓
Application Continues

No identity or persistent storage is required.


Deploying Stateful Components

Databases and Kafka use:

StatefulSets

Used for:

  • PostgreSQL Databases
  • Neo4j
  • Kafka

Why StatefulSets?

State matters.

They require:

  • Stable Network Identity
  • Predictable Naming
  • Persistent Storage

Example:

postgres-0
postgres-1
postgres-2

Pods retain their identity.


Persistent Volume Claims (PVC)

Each StatefulSet is attached to PVCs.

Benefits:

  • Data survives pod restarts.
  • Volumes automatically reattach.
  • Prevents data loss.

Example:

Postgres Pod Crashes
       ↓
New Pod Starts
       ↓
Existing PVC Reattached
       ↓
Database Restored

Kubernetes Networking

Inside Kubernetes:

  • Every Pod gets an IP.
  • Services expose Pods internally.
  • Kubernetes DNS resolves service names.

Example:

http://user-service
http://post-service
http://connection-service

Services communicate using names instead of IP addresses.


Goodbye Eureka

(Inside Kubernetes)

Kubernetes already provides:

  • Internal DNS
  • Service Discovery
  • Load Balancing

Therefore:

Local Development

Gateway
   ↓
Eureka
   ↓
Services

Kubernetes

Gateway
   ↓
Kubernetes Services
   ↓
Pods

Eureka is no longer required inside the cluster.


🌍 External Access using Ingress

Users outside the cluster cannot access internal services directly.

Ingress exposes the application.


Request Flow

Internet User
      ↓
NGINX Ingress Controller
      ↓
Ingress Rules
      ↓
API Gateway
      ↓
Microservices

Responsibilities

Ingress provides:

  • Public IP Address
  • Host-Based Routing
  • Path-Based Routing
  • External Load Balancing
  • SSL/TLS Support

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages