# sungwookkk/ftt_backend architecture

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

- Interactive diagram: https://gitdiagram.com/sungwookkk/ftt_backend
- Repository: https://github.com/sungwookkk/ftt_backend

## Overview

##### Project type and purpose
- This is a monolithic, full-stack (serving a SPA frontend from Spring Boot) backend service built with Java Spring Boot.
- It provides REST APIs for user, task, team, chat, community post, badge, statistics, file uploads; real-time presence via WebSocket; batch jobs for SMS reminders; integrations with Kafka, Twilio, OpenAI, and social login (Google, Naver).

##### File structure
- Top-level: Gradle build, Spring Boot entry point (FttBackendApplication.java).
- config: security (JWT filters, WebConfig), batch (schedulers, controllers), kafka, openai, twilio, data loader.
- controller → REST endpoints; model → JPA entities; repository → Spring Data; service → business logic; social → OAuth controllers; socket → WebSocket setup; statistics → analytics endpoints and DTOs.
- resources/static + SpaForwardController serve the frontend.

##### README for additional insights
- Notes on CI/CD, DataLoader, REST API design, batch job setup (Twilio, Kafka).

##### Be detailed but focused
- Break the backend monolith into at least these sub-components: API Layer, Service Layer, Data Layer, Batch Module, WebSocket Module, Security Module, Integration Modules.
- External dependencies and asynchronous flows (Kafka).
- Avoid over-splitting trivial classes; aggregate by module.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "SPA Client" 
        direction TB
        Static["Static Assets"]:::frontend
        SpaController["SpaForwardController"]:::frontend
    end

    %% Backend Monolith
    subgraph "Spring Boot Backend"
        direction TB

        subgraph "API Layer" 
            direction TB
            Controllers["REST Controllers"]:::api
        end

        subgraph "Service Layer"
            direction TB
            Services["Business Services"]:::service
        end

        subgraph "Data Layer"
            direction TB
            Models["JPA Entities"]:::data
            Repos["Spring Data Repositories"]:::data
        end

        subgraph "Security Module"
            direction TB
            JwtFilter["JwtAuthenticationFilter"]:::security
            JwtUtils["JwtUtils"]:::security
            SecConfig["SecurityConfig"]:::security
            JwtEntry["JwtAuthenticationEntryPoint"]:::security
        end

        subgraph "Batch Scheduler Module"
            direction TB
            BatchCfg["BatchConfig"]:::batch
            SmsSched["SmsReminderScheduler"]:::batch
            BatchCtrl["BatchTriggerController"]:::batch
        end

        subgraph "WebSocket Module"
            direction TB
            WSConfig["WebSocketConfig"]:::socket
            PresenceCtrl["PresenceController"]:::socket
            PresenceMsg["PresenceMessage"]:::socket
        end

        subgraph "Integration Modules"
            direction TB
            subgraph "Kafka Integration"
                direction TB
                KafkaInt["Kafka Config & Listener"]:::external
            end
            subgraph "Twilio Integration"
                direction TB
                TwilioInt["Twilio Config & Controller"]:::external
            end
            subgraph "OpenAI Integration"
                direction TB
                OpenAIInt["OpenAI Config & Service"]:::external
            end
            subgraph "Social OAuth"
                direction TB
                OAuthInt["Google & Naver Controllers"]:::external
            end
        end

        EntryPoint["FttBackendApplication"]:::entry
    end

    %% External Systems
    Database["Relational Database"]:::db
    KafkaCluster["Apache Kafka Cluster"]:::external
    TwilioAPI["Twilio SMS Gateway"]:::external
    OpenAIAPI["OpenAI API"]:::external
    OAuthProviders["OAuth Providers (Google, Naver)"]:::external

    %% Connections
    Static -->|"served by"| SpaController
    SpaController -->|"HTTP REST"| Controllers
    Static -->|"WebSocket"| WSConfig

    Controllers -->|calls| Services
    Services -->|CRUD| Models
    Services -->|CRUD| Repos
    Models -->|persist| Database
    Repos -->|query| Database

    Services -->|auth| JwtFilter
    JwtFilter -->|uses| JwtUtils
    JwtFilter -->|configured in| SecConfig
    JwtEntry -->|handles| Controllers

    BatchSched["Batch Scheduler"]:::batch
    BatchSched -->|schedules| SmsSched
    SmsSched -->|publish| KafkaCluster
    KafkaCluster -->|consume| KafkaInt
    KafkaInt -->|send SMS| TwilioAPI

    Services -->|call| OpenAIAPI
    OpenAIInt -->|wraps| OpenAIAPI

    Services -->|redirect| OAuthProviders
    OAuthInt -->|callbacks| Controllers

    WSConfig -->|manages| PresenceCtrl
    PresenceCtrl -->|sends/receives| PresenceMsg

    EntryPoint -->|bootstraps| Controllers

    %% Click Events
    click Static "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/resources/static"
    click SpaController "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/controller/SpaForwardController.java"
    click Controllers "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/controller"
    click Services "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/service"
    click Models "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/model"
    click Repos "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/repository"
    click JwtFilter "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/config/JwtAuthenticationFilter.java"
    click JwtUtils "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/config/JwtUtils.java"
    click SecConfig "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/config/SecurityConfig.java"
    click JwtEntry "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/config/JwtAuthenticationEntryPoint.java"
    click BatchCfg "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/config/batch/BatchConfig.java"
    click SmsSched "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/config/batch/SmsReminderScheduler.java"
    click BatchCtrl "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/config/batch/BatchTriggerController.java"
    click WSConfig "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/socket/WebSocketConfig.java"
    click PresenceCtrl "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/socket/PresenceController.java"
    click PresenceMsg "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/socket/PresenceMessage.java"
    click KafkaInt "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/config/kafka"
    click TwilioInt "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/config/twilio"
    click OpenAIInt "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/config/openai"
    click OAuthInt "https://github.com/sungwookkk/ftt_backend/tree/main/src/main/java/ftt_backend/social"
    click EntryPoint "https://github.com/sungwookkk/ftt_backend/blob/main/src/main/java/ftt_backend/FttBackendApplication.java"

    %% Styles
    classDef frontend fill:#D5E8D4,stroke:#82B366;
    classDef api fill:#FFF2CC,stroke:#D6B656;
    classDef service fill:#E1D5E7,stroke:#9673A6;
    classDef data fill:#F8CECC,stroke:#B85450;
    classDef security fill:#DAE8FC,stroke:#6C8EBF;
    classDef batch fill:#F5F5F5,stroke:#999999;
    classDef socket fill:#E0FFE0,stroke:#00A050;
    classDef external fill:#FFE6CC,stroke:#D99025,stroke-dasharray: 5 5;
    classDef db fill:#FFFFFF,stroke:#000000,stroke-width:2px;
    classDef entry fill:#CCFFFF,stroke:#33CCCC;
```
