How instagram-clone-coding/spring_instagram-clone works
Main Components
• Controllers per Domain: Each module has its own REST controller layer (e.g., MemberAuthController, PostController, ChatController, etc.)
• Services: Business logic is encapsulated in service classes (e.g., MemberService, PostService, ChatService, etc.).
• Data Access Layer (Repositories): Using Spring Data JPA, JDBC, and Querydsl repositories.
• Global Configuration & Cross-cutting Concerns:
– Security & Authentication (Spring Security filters, JWT authentication providers, security handlers, etc.)
– Exception Handling (Centralized using @RestControllerAdvice)
– Global Configurations (SwaggerConfig, AsyncConfig, QuerydslConfig, RedisConfig, etc.)
• Infrastructure Integration:
– AWS S3 integration for image uploads and storage (S3Uploader)
– Email service for confirmations and resets
– Kakao API for map/location support
– Redis for caching, refresh tokens, and temporary codes (like RegisterCode, ResetPasswordCode)
• External Systems:
– MySQL for persistent relational data storage
– Redis as an in-memory datastore for caching and session/token management
Layered Architecture and Relationships
• Client Layer: External requests from the frontend (or any client) arrive via HTTP.
• Presentation Layer: Controllers which expose REST endpoints.
• Service (Business Logic) Layer: Connect controllers to service classes that process requests.
• Data Access Layer: Services call Repository components using JPA/Querydsl.
• Infrastructure Layer:
– Security Components: Show integration with filters (JwtAuthenticationFilter, Custom Exception Filters), security providers for authentication.
– External Integrations: AWS S3, Email, Kakao, and Redis are used by various service modules.
– Database: Connect the Repository layer to MySQL.
– Caching/Session Management: Connect services or security layer to Redis.
Architectural Patterns/Principles
• Layered architecture / Clean separation between Controller, Service, and Repository.
• Use of Domain-Driven Design: Multiple domain modules (member, feed, dm, follow, hashtag, story, alarm, search, etc.) are self-contained, following similar folder structures (controller, service, dto, entity, repository, exception).
• Security and Error-Handling are implemented in a cross-cutting manner using AOP and global exception handling (with a unified ErrorResponse and ResultResponse design).
• Use of Dependency Injection and Inversion of Control via Spring Boot.
– A “Presentation” tier (Controllers), “Business Logic” (Services), “Persistence” (Repositories).
c. A “Security” block where filters (JwtAuthenticationFilter, ReissueAuthenticationFilter, etc.) and provider components reside.
f. Configuration components (e.g., SwaggerConfig, GlobalExceptionHandler, AsyncConfig) that affect multiple domains.