A scalable social media backend built using a microservices architecture with Node.js. The system separates authentication, post management, media handling, and search into independent services communicating through REST APIs and asynchronous events.
Client
|
v
API Gateway
|
+----------------+----------------+
| | |
v v v
Identity Service Post Service Media Service
|
v
RabbitMQ Events
|
v
Search Service
Redis / MongoDB
The API Gateway acts as the main entry point for clients and routes requests to the appropriate microservice.
Responsibilities:
- Request routing
- Authentication middleware
- Rate limiting
- Service communication
Handles user authentication and identity management.
Responsibilities:
- User registration
- User login
- JWT authentication
- User validation
Manages social media posts.
Responsibilities:
- Create posts
- Retrieve posts
- Delete posts
- Publish post events
- Communicate with Media Service
Handles media associated with posts.
Responsibilities:
- Media upload
- Media storage management
- Media deletion
- Media metadata management
Provides post search functionality.
Responsibilities:
- Index post data
- Search posts
- Consume RabbitMQ events
- Maintain searchable post information
The application uses RabbitMQ for asynchronous communication between services.
Example event flow:
User creates a post
|
v
Post Service
|
v
Post Created Event
|
v
RabbitMQ
|
v
Search Service
|
v
Post indexed for search
This architecture reduces tight coupling between services and allows services to process events independently.
- Node.js
- Express.js
- MongoDB
- Redis
- RabbitMQ
- Docker
- Docker Compose
- JWT Authentication
- REST APIs
Social-media-Microservices/
│
├── api-gateway/
├── Identity-service/
├── Post-service/
├── media-service/
├── search-service/
│
├── docker-compose.yaml
└── .gitignore
Make sure the following tools are installed:
- Docker
- Docker Compose
- Git
git clone https://github.com/ayushman1210/Social-media-Microservices.git
cd Social-media-MicroservicesBuild and start all microservices:
docker compose up --buildRun the services in the background:
docker compose up --build -ddocker compose downDocker Compose manages the application services and supporting infrastructure.
api-gateway
identity-service
post-service
media-service
search-service
redis
rabbitmq
Each microservice runs independently inside its own Docker container.
- Microservices-based backend architecture
- API Gateway pattern
- JWT-based authentication
- Event-driven communication
- Asynchronous message processing using RabbitMQ
- Redis integration
- Independent service containers
- Docker Compose orchestration
- Post and media management
- Event-driven search indexing
This project demonstrates several backend and distributed system concepts:
- Microservices Architecture
- API Gateway Pattern
- Event-Driven Architecture
- Message Queues
- Service Isolation
- Asynchronous Communication
- Distributed System Design
- Containerization
- Kubernetes deployment
- Distributed tracing
- Centralized logging
- Prometheus and Grafana monitoring
- Automated CI/CD pipeline
- API documentation using Swagger/OpenAPI
- Integration and unit testing
- Service health checks
- Circuit breaker pattern
Ayushman Gupta
GitHub: ayushman1210