A production-style, event-driven microservices application built with Spring Boot, Spring Cloud, Kafka, Neo4j, PostgreSQL, and Kubernetes.
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:
-
Register and manage profiles
-
Create posts (with image uploads)
-
Build professional connections
-
Discover 1st, 2nd, and 3rd degree connections
-
Receive notifications
-
Handle communication between services efficiently
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
| 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) |
Responsible for user-related operations.
- User Registration
- User Authentication
- Profile Management
- Profile Information Retrieval
PostgreSQL
Handles everything related to posts.
- Create Posts
- Fetch User Posts
- Feed Retrieval
- Support Image Posts
PostgreSQL
This service models the professional network.
Instead of using relational joins, connections are stored in a graph database.
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.
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.
- First Degree Connections
- Second Degree Connections
- Third Degree Connections
- Connection Search
- Pending Requests
- Accept Requests
Responsible for generating notifications.
- Post Notifications
- Connection Notifications
- Future extensibility for:
- Email Notifications
- Push Notifications
- Real-Time Alerts
PostgreSQL
Handles media uploads independently.
Uploading files can involve:
- Validation
- Compression
- Storage
- CDN Integration
Keeping it isolated prevents bloating the Post Service.
- Upload Post Images
- AWS S3 Integration
In local development, all services register themselves with Eureka.
Each service contains Eureka Client configuration.
Example:
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eurekaService Starts
β
Registers with Eureka
β
Eureka stores:
Service Name
IP Address
Port
API Gateway
β
Ask Eureka:
"Where is Post Service?"
β
Eureka returns address
β
Gateway forwards request
This eliminates hardcoded service URLs.
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/**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);
}
Feign internally:
- Discovers services through Eureka
- Performs HTTP calls
- Waits for responses
- Converts responses into Java objects
One of the key highlights of this project.
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.
Post creation and notification generation are decoupled.
User Creates Post
β
Post Service
β
Connection Service
(Get Connections)
β
Kafka Producer
Publishes Event
β
Kafka Topic
β
Notification Service
(Kafka Consumer)
β
Notifications Created
The user immediately receives:
"Post Created Successfully"
without waiting for notifications.
Even if Notification Service is temporarily down:
- Events remain in Kafka.
- Notifications are processed once the service recovers.
Consumers can scale independently.
Events are persisted until consumed.
User Uploads Image
β
Post Service
β
Upload Service
β
AWS S3 Bucket
β
Image URL Returned
β
Post Saved
Benefits:
- Efficient storage
- Highly durable
- Scalable
- CDN-friendly
The entire application can be deployed on Kubernetes.
Kubernetes provides:
- Self-Healing
- Scaling
- Service Discovery(k8s own DNS service)
- Networking
- Load Balancing
- Rolling Updates
Microservices are deployed using:
Used for:
- API Gateway
- User Service
- Post Service
- Connection Service
- Notification Service
- Upload Service
These services are stateless.
If a pod crashes:
Old Pod Dies
β
New Pod Starts
β
Application Continues
No identity or persistent storage is required.
Databases and Kafka use:
Used for:
- PostgreSQL Databases
- Neo4j
- Kafka
State matters.
They require:
- Stable Network Identity
- Predictable Naming
- Persistent Storage
Example:
postgres-0
postgres-1
postgres-2
Pods retain their identity.
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
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-serviceServices communicate using names instead of IP addresses.
(Inside Kubernetes)
Kubernetes already provides:
- Internal DNS
- Service Discovery
- Load Balancing
Therefore:
Gateway
β
Eureka
β
Services
Gateway
β
Kubernetes Services
β
Pods
Eureka is no longer required inside the cluster.
Users outside the cluster cannot access internal services directly.
Ingress exposes the application.
Internet User
β
NGINX Ingress Controller
β
Ingress Rules
β
API Gateway
β
Microservices
Ingress provides:
- Public IP Address
- Host-Based Routing
- Path-Based Routing
- External Load Balancing
- SSL/TLS Support