# naughtycomputer/naughty-be-spring architecture

> Architecture diagram of the GitHub repository naughtycomputer/naughty-be-spring, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/naughtycomputer/naughty-be-spring
- Repository: https://github.com/naughtycomputer/naughty-be-spring

## Overview

##### Project type and purpose
- This is a Spring Boot–based monolithic backend service for a “2025 졸업 프로젝트” (graduation project) named “Naughty-BE-Spring.”
- It exposes RESTful endpoints for user, post, comment, profile, like/scrap functionality and handles authentication (including OAuth2 via Kakao) and JWT-based security.

##### File structure
- Top level: standard Gradle/Spring Boot layout.
- build.gradle, gradlew scripts, settings.gradle, gradle wrapper -> build and dependency management
- src/main/java/naughty/tuzamate -> application code
- src/test -> unit/integration tests
- Packages under src/main/java:
- auth – controllers, services, JWT filters/providers, OAuth2 integration (Kakao)
- domain – modular subpackages for comment, post, postLike, postScrap, profile, user; each with controller, dto, entity, repository, converter, service/command, service/query
- global – cross-cutting concerns: BaseTimeEntity, API payload wrappers, config (SecurityConfig, SwaggerConfig, WebConfig), global errors and exception handlers, success codes
- No separate “frontend” or microservices—this is a single monolith with layered architecture (Controller → Service → Repository → Database).

##### README for additional insights
- Only confirms backend Spring part of graduation project.

##### Elements
– Green for external systems (Kakao, DB)
– Orange for cross-cutting components (SecurityConfig, GlobalExceptionHandler)
- Annotations for major classes/interfaces (e.g., JwtFilter, SecurityConfig, CustomResponse)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Client["Client (Web/Mobile)"]:::external
    LB["Load Balancer / API Gateway"]:::external
    SwaggerUI["Swagger UI"]:::external
    Kakao["Kakao OAuth2 Server"]:::external
    DB["Relational Database"]:::external

    Client -->|HTTP Request| LB
    LB -->|Forwards Request| JwtFilter
    SwaggerUI -->|API Docs| LB

    subgraph "Spring Boot Monolith"
        %% Security Layer
        subgraph "Security Layer"
            JwtFilter["JwtFilter"]:::cross
            JwtProvider["JwtProvider"]:::cross
            SecurityConfig["SecurityConfig"]:::cross
        end

        JwtFilter -->|validates JWT| JwtProvider
        JwtFilter -->|routes to| Controllers

        %% Presentation Layer
        subgraph "Presentation Layer"
            Controllers[/"Controllers"/]:::module
            subgraph "Auth Module"
                KakaoController["KakaoController"]:::module
            end
            subgraph "Comment Module"
                CommentController["CommentController"]:::module
            end
            subgraph "Post Module"
                PostController["PostController"]:::module
            end
            subgraph "Profile Module"
                ProfileController["ProfileController"]:::module
            end
            subgraph "User Module"
                UserController["UserController"]:::module
            end
        end

        Controllers -->|calls| AuthServices
        Controllers -->|calls| CommentServices
        Controllers -->|calls| PostServices
        Controllers -->|calls| ProfileServices
        Controllers -->|calls| UserServices

        %% Service Layer
        subgraph "Service Layer"
            subgraph "Auth Services"
                OAuth2Service["OAuth2Service"]:::module
                OAuth2ServiceImpl["OAuth2ServiceImpl"]:::module
                KakaoService["KakaoService"]:::module
            end
            subgraph "Comment Services"
                CommentCommandSvc["CommentCommandService"]:::module
                CommentQuerySvc["CommentQueryService"]:::module
            end
            subgraph "Post Services"
                PostCommandSvc["PostCommandService"]:::module
                PostQuerySvc["PostQueryService"]:::module
            end
            subgraph "Profile Services"
                ProfileCommandSvc["ProfileCommandService"]:::module
                ProfileQuerySvc["ProfileQueryService"]:::module
            end
            subgraph "User Services"
                UserServiceImpl["UserService"]:::module
            end
        end

        AuthServices -->|use JPA| Repositories
        CommentServices -->|use JPA| Repositories
        PostServices -->|use JPA| Repositories
        ProfileServices -->|use JPA| Repositories
        UserServices -->|use JPA| Repositories

        %% Data Access Layer
        subgraph "Data Access Layer"
            Repositories[(Repositories)]:::module
            subgraph "Comment Repo"
                CommentRepo["CommentRepository"]:::module
            end
            subgraph "Post Repo"
                PostRepo["PostRepository"]:::module
                PostLikeRepo["PostLikeRepository"]:::module
                PostScrapRepo["PostScrapRepository"]:::module
            end
            subgraph "Profile Repo"
                ProfileRepo["ProfileRepository"]:::module
            end
            subgraph "User Repo"
                UserRepo["UserRepository"]:::module
            end
        end

        Repositories --> DB

        %% Global Config & Cross-Cutting
        subgraph "Global Config & Concerns"
            BaseTimeEntity["BaseTimeEntity"]:::cross
            CustomResponse["CustomResponse"]:::cross
            WebConfig["WebConfig"]:::cross
            SwaggerConfig["SwaggerConfig"]:::cross
            GlobalExceptionHandler["GlobalExceptionHandler"]:::cross
        end

        Controllers --> GlobalExceptionHandler
        Controllers --> CustomResponse
        JwtFilter --> GlobalExceptionHandler
    end

    %% External Calls
    KakaoController -->|OAuth Flow| Kakao

    %% Click Events
    click TuzamateApplication "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/TuzamateApplication.java"
    click KakaoController "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/controller/KakaoController.java"
    click OAuth2Service "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/service/OAuth2Service.java"
    click OAuth2ServiceImpl "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/service/OAuth2ServiceImpl.java"
    click KakaoService "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/service/KakaoService.java"
    click JwtFilter "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/jwt/JwtFilter.java"
    click JwtProvider "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/jwt/JwtProvider.java"
    click PrincipalDetails "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/principal/PrincipalDetails.java"
    click PrincipalDetailsService "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/auth/principal/PrincipalDetailsService.java"
    click CommentController "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/comment/controller/CommentController.java"
    click PostController "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java"
    click ProfileController "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/profile/controller/ProfileController.java"
    click UserController "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/user/controller/UserController.java"
    click CommentRepo "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/comment/repository/CommentRepository.java"
    click PostRepo "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/post/repository/PostRepository.java"
    click PostLikeRepo "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/postLike/repository/PostLikeRepository.java"
    click PostScrapRepo "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/postScrap/repository/PostScrapRepository.java"
    click ProfileRepo "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/profile/repository/ProfileRepository.java"
    click UserRepo "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/domain/user/repository/UserRepository.java"
    click BaseTimeEntity "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/global/BaseTimeEntity.java"
    click CustomResponse "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/global/CustomResponse.java"
    click SecurityConfig "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/global/config/SecurityConfig.java"
    click SwaggerConfig "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/global/config/SwaggerConfig.java"
    click WebConfig "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/global/config/WebConfig.java"
    click GlobalExceptionHandler "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/main/java/naughty/tuzamate/global/GlobalExceptionHandler.java"
    click TuzamateApplicationTests "https://github.com/naughtycomputer/naughty-be-spring/blob/dev/src/test/java/naughty/tuzamate/TuzamateApplicationTests.java"

    %% Styles
    classDef module fill:#BBDEFB,stroke:#42A5F5,color:#000
    classDef external fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef cross fill:#FFE0B2,stroke:#FB8C00,color:#000
```
