How studyfi/studyfi-backend works
Project Type and Purpose
• This is a microservices‐based backend for a social media platform (“StudyFi”). It consists of multiple Spring Boot services, an API Gateway (Spring Cloud Gateway), a Eureka Discovery Server, and several domain microservices (User & Group, Content & News, Notification).
Main Components
a. API Gateway
• Spring Cloud Gateway service listening on port 8080.
• Routes external API calls to downstream services via Eureka.
• Handles cross‐cutting concerns (auth, rate‐limiting, logging).
b. Discovery Server
• Eureka Server on port 8761.
• Central registry for all microservices.
c. User & Group Service
• Manages user accounts, groups, image uploads (Cloudinary), email workflows (SMTP).
• Exposes REST endpoints for user registration, authentication, profile & group management.
• Persists to MySQL.
• Outbound: WebClient → Notification service.
• Inbound: other services may query user/group info.
d. Content & News Service
• Manages news articles, posts, likes, comments.
• File uploads via Cloudinary.
• Persists to MySQL.
• Outbound: WebClient → User & Group service (for author info), Notification service (for events).
e. Notification Service
• Receives notification requests (email) from other services.
• Sends via JavaMailSender/SMTP.
• Persists notifications to MySQL.
External Dependencies
• MySQL database (possibly one schema per service or shared).
• Cloudinary (file hosting).
• SMTP server (Google SMTP).
Interactions & Dataflows
1. Client → API Gateway → routed to appropriate microservice (User, Content, Notification).
2. Gateway & services register with Eureka → on startup.
3. Service discovery: Gateway and services call Eureka to resolve service instances (via lb://SERVICE-NAME).
4. User & Group Service → Notification Service (via WebClient) to send verification / reset emails.
5. Content & News Service →
• User & Group Service (via WebClient) to fetch author metadata.
• Notification Service to send “new comment” or “like” notifications.
Architectural Patterns & Principles
• Microservices with single responsibility.
• Service discovery (Eureka) + client‐side load balancing.
• API Gateway pattern for a unified entry point.
• Asynchronous HTTP communication (WebClient).
• Externalized configuration (application.properties).
• Cloud‐based file storage (Cloudinary).