How tonyoliver0208/social-network-microservices works
Project type and purpose
• This is a cloud-native, microservices-based social network backend. It uses an API Gateway to route and secure traffic, and four domain services (Identity, Media, Post, Search). Each service is containerized and communicates via REST and asynchronous messaging.
Top-level architecture and main components
a. API Gateway
• Exposes a unified HTTP interface
• Contains middleware for authentication, rate limiting, error handling
• Forwards requests to the appropriate service proxy (Identity, Media, Post, Search)
b. Identity Service
• Manages user accounts, tokens, refresh flows
• Exposes REST endpoints for login, signup, token refresh
• Stores users and refresh tokens in a database
c. Media Service
• Handles file uploads, transforms, storage via Cloudinary
• Emits and consumes events (e.g., media‐uploaded) via RabbitMQ
• Caches metadata in Redis
d. Post Service
• Manages user posts (CRUD)
• Emits change events (post-created, post-deleted) on RabbitMQ
• Uses Redis for caching hot data
e. Search Service
• Indexes posts and media to support search queries
• Subscribes to post/media events from RabbitMQ to update its index
• Persists search indices in a database
f. Shared infrastructure
• Databases (one per service)
• Redis instances (for rate-limiting, caching, sessions)
• RabbitMQ (event bus)
• External cloud service: Cloudinary
Relationships and data flows
• Client → API Gateway → appropriate service (REST)
• Identity Service ↔ Redis (session caching)
• Media/Post → RabbitMQ → Search Service (asynchronous event flow)
• Media Service → Cloudinary (external API)
• All services may log to a central logger or service (utility in each service)
Architectural patterns and principles
• Microservices: each domain is an autonomous service with its own data store
• API Gateway pattern for cross-cutting concerns (auth, rate limit, logging)
• Event-driven architecture using RabbitMQ for eventual consistency and decoupling
• Polyglot persistence: each service picks its optimal database + caching layer
• Twelve-factor app: containerized, environment-driven config, separate build and run, logs as streams
How to reflect this
• Edge Layer: Client / Mobile / Web
• API Layer: API Gateway
• Microservices Layer: Identity, Media, Post, Search
• Messaging Layer: RabbitMQ broker
• External Services: Cloudinary
• From client to API Gateway (HTTP)
• From API Gateway to each microservice (HTTP, label REST)
• From services to Redis/DB/Cloudinary
• Blue rectangles for services
d. Labels:
• Clearly name each component (e.g., “Identity Service”, “Post Service”)
• Protocols (HTTP, AMQP) and middleware responsibilities