How giyomdabin/moyak-server works
• Application Entry Point: Highlight "MoyakApplication.java" as the central starting point.
• Controllers:
• AuthController (handles user authentication endpoints)
• ChatController (manages chat-related endpoints)
• Services:
• AuthService (business logic for authentication, interacting with OAuth tokens and profiles)
• ChatService (core logic related to chat operations)
• ChatGptService (integration with ChatGPT API, handling AI-specific requests/responses)
• S3Service (file management, suggesting integration with AWS S3)
• Data Models and DTOs:
• DTOs for Chat, ChatGPT (request and response), Auth (KakaoProfile, OAuthToken), and User objects, as these structure the data flowing in the application.
• Repositories:
• ChatRepository, ChatMessageRepository, EachPillRepository, UserRepository (for persistence with the database)
• External Integrations:
• OAuth (Kakao) for authentication
• ChatGPT API for AI chat responses
• Amazon S3 for storage
• Configurations & Exception Handling:
• Config packages (WebConfig, S3Config) to show configuration of web settings and S3 connections.
• Exception packages (CustomException, CustomExceptionHandler, ErrorResponse) representing centralized error handling.
Relationships and Data Flow
• The Controller interacts with a Service layer that implements the core business logic.
• The Services then interact with Repositories to perform CRUD operations on the database.
• For functionalities like AI chat response or file uploads, Services interface with external APIs (ChatGPT and AWS S3).
• Flows for authentication where the AuthController communicates with an external OAuth provider (for example, Kakao) via models like KakaoProfile and OAuthToken.
• Exception handling as a cross-cutting concern that intercepts errors from any of these interactions.
Architectural Patterns and Design Principles
• Layered (MVC-like) Architecture: Clearly separate controllers, services, and repository layers.
• External API Integration: Treat services like ChatGptService and S3Service as integration adapters, encapsulating communication logic with third-party services.
• Dependency Injection: Implicit in the design (likely through Spring’s DI container) that connects controllers with their respective services.
• Exception Management: Centralized exception handling for better manageability and maintainability.
Additional Advice
• Data flow: It is crucial to represent how data moves from a request to processing and then storage or external API calls.