How shantanu200/ds_social-app works
Project Type and Purpose
• The project is a distributed microservices social media application, similar to Twitter.
• The README emphasizes a multi-service architecture where each service (User, Tweet, Timeline, Notification, and User Relation) is an independent Golang microservice.
• The tech stack spans a modern client (React, NodeJs, Tailwind CSS) to Golang services leveraging Postgres, Redis, RabbitMQ, and WebSocket, with orchestration via Docker Compose and Kubernetes.
File Structure
• The file tree reveals separate directories for each microservice (e.g., user-service, tweet-service, timeline-service, notification-service, user-relation-service). Each service is organized with its own API entrypoints, controllers, handlers, models, and support modules (database connections, caches, RabbitMQ interactions, and even socket handling in the Notification service).
• Every service contains its Dockerfile, indicating containerization and independent deployment.
• There are shared patterns across services such as the “cmd/api” structure following standard MVC-like organization where controllers handle the API logic, and auxiliary layers are dedicated to caching, database connectivity, or messaging.
README for Additional Insights
• The README outlines the different API endpoints and operations for each service, providing clarity on service responsibilities:
• User Service: registration, login, and user detail management.
• Tweet Service: handling tweets, replies, likes/favorites, and media storage through S3.
• Timeline Service: generating user timelines including home feed, following feeds, and timeline management.
• User Relation Service: managing follow and unfollow operations, plus recommendations.
• Notification Service: using WebSocket to trigger real-time notifications upon events like posting a tweet, liking a tweet, or following users.
a. Main Components:
• Client Application: React-driven interface that interacts via HTTP/WebSocket with the backend.
• API Microservices:
• User Service: handles authentication, user CRUD, and JWT token management.
• Tweet Service: manages tweet posting, reply threads, like/dislike actions, and S3 integrations.
• Timeline Service: aggregates and serves timeline data using database queries, cache, and RabbitMQ.
• User Relation Service: controls follow/unfollow mechanics and user recommendations.
• Notification Service: implements real-time communication via WebSocket to deliver notifications.
• Infrastructure Components:
• Database: Postgres (for persisting relational data across services).
• Cache: Redis (for caching and fast data access).
• Message Broker: RabbitMQ (for inter-service communication and event handling).
• Containerization and orchestration (Docker Compose and Kubernetes).
b. Relationships and Interactions:
• The Client initiates REST/API calls to the individual microservices (or through an optional API Gateway if available).
• Each service communicates with its own database instance in Postgres.
• Redis is used in multiple services to cache frequently accessed data (e.g., in the tweet and timeline services).
• RabbitMQ acts as the central messaging backbone, facilitating event-driven communication between services (e.g., notifying the timeline service on new tweets, updating caches, or triggering WebSocket notifications).
• The Notification Service listens for specific events (tweet posted, like, follow) and then pushes updates via WebSocket to active clients.
c. Architectural Patterns and Design Principles:
• Microservices Architecture: Independent services with dedicated responsibilities.
• Event-Driven Communication: Usage of RabbitMQ to decouple services.
• API Layer: Each microservice exposes REST endpoints to serve client requests.
• Caching Strategy: Redis is incorporated to improve response times.
• Containerization: Dockerfiles for each service indicate isolated, containerized deployments.
• Real-Time Data Flow: Notification service via WebSocket ensures immediate client updates.
d. Technologies and Libraries:
• Server-side: Golang, RabbitMQ (messaging), Redis (caching), Postgres (database).
• Client-side: React, Axios, and modern React libraries (React Query, React Hook Form).
• Deployment: Docker Compose (locally), Kubernetes (production).
• S3 Storage: Used by the Tweet Service for handling media.
Final Touch
• The goal is to capture every crucial architectural element – every service, its internal modules, and its interactions – to give a comprehensive view of the overall architecture.