# kksshh0612/server architecture

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

- Interactive diagram: https://gitdiagram.com/kksshh0612/server
- Repository: https://github.com/kksshh0612/server

## Overview

##### Core Project Nature & Purpose
- This is a backend service for the Nest.net website focused on supporting various functionalities such as user authentication, attendance management, posting different types of content, and handling file uploads.
- The system is layered following a typical Spring Boot application structure (Controller, Service, Repository, Domain/DTO layers).

##### Main Architectural Components
a. Web Layer (Frontend/Controller):
- Controllers for managing endpoints are organized by features (e.g., attendance, auth, post [with subtypes: unified, notice, introduction, exam collection, photo], comment, executive, file, manager, member, life4cut, memberprofile).
- How these controllers receive HTTP requests and then delegate them to service layer.

b. Service Layer:
- Contains business logic for each functional area (e.g., AttendanceService, AuthService, PostService, etc.).
- Also includes specialized services like MailService and SlackService that handle external integrations.

c. Persistence / Repository Layer:
- Repositories that interface with the database for various domain entities are structured in packages matching functional groups (e.g., member, attendance, post, file).
- Domain classes are mapped under the “domain” packages.

d. Domain & DTO:
- Domain objects represent the core data models (e.g., Member, Post, Attendance, etc.).
- DTOs (Data Transfer Objects) exist for both request and response types. They ensure that only the necessary data is passed between layers.

e. Security & Authentication:
- Detailed configurations exist for security – JWT-based authentication, cookie handling, custom authorization filters, and overall SecurityConfig. Classes like Authenticator, CustomAuthorizationFilter, TokenProvider, and related error handlers are key.

f. Configuration & Integration:
- There are configuration packages for Swagger (API documentation), Redis (caching or session management), and general Web/MVC configuration.
- Environment-specific configuration files in src/main/resources (e.g., application-dev.yml, application-prod.yml) allow tuning based on the deployment environment.

g. Build & Deployment Artifacts:
- Build scripts (build.gradle, settings.gradle, gradlew files) and a Dockerfile demonstrate containerization and CI/CD integration.

##### Relationships & Data Flow
- Additionally, show any external integration points such as MailService and SlackService connecting to external systems.
- Interplay between Authentication (JWT, Cookies) and the secured endpoints.

##### Architectural Patterns & Design Principles
- N-tier layered architecture: clear separation between presentation (controllers), service, and data access.
- Use of DTOs in controller-service interaction to decouple domain from API contracts.
- Security is handled via a dedicated configuration package and filters following best practices.
- Configuration-driven environment management (multiple application.yml files).

##### Final Recommendations
– Security & Authentication (JWT, cookie management, authorization filters)
– Functional modules (attendance, posts [notice, introduction, exam collection, photo, unified], member, etc.)
– External integrations (Mail, Slack, Redis)
– Infrastructure (Gradle build, Docker container, Environment Configurations)
- Dependencies, including directional data flows (such as “data validation from Controller to Service”, “database CRUD via Repository”, etc.).

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Users
    EU["External Users"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        WC["Web Controllers"]:::controllers
    end

    %% Business Logic Layer
    subgraph "Business Layer"
        SL["Service Layer"]:::services
        MS["Mail Service"]:::services
        SS["Slack Service"]:::services
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        RL["Repository Layer"]:::repositories
        DM["Domain Models"]:::domain
        DTO["DTOs"]:::domain
    end

    %% Security & Authentication
    subgraph "Security & Authentication"
        AC["Authentication Config"]:::security
        JC["JWT Classes"]:::security
        SC["Security Configuration"]:::security
    end

    %% Configuration & Integration
    subgraph "Configuration & Integration"
        SW["Swagger"]:::config
        RC["Redis Config"]:::config
        WCfg["Web/MVC Config"]:::config
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        GB["Gradle Build Files"]:::infra
        DC["Docker Container"]:::infra
        EC["Environment Configs"]:::infra
    end

    %% Data Flow
    EU -->|"HTTPRequest"| WC
    WC -->|"delegates"| SL
    SL -->|"CRUD"| RL
    SL -->|"uses"| DM
    SL -->|"DTOtransfer"| DTO
    SL -->|"sendsEmail"| MS
    SL -->|"sendsSlack"| SS

    %% Security Relations
    SC -->|"secures"| WC
    SC -->|"secures"| SL
    AC -->|"authenticates"| WC
    JC -->|"validatesToken"| WC

    %% Configuration Dependencies
    SW -->|"docs"| WC
    RC -->|"caching"| SL
    WCfg -->|"configuresWeb"| WC

    %% Build & Deployment Flow
    GB -->|"buildsContainer"| DC
    DC -->|"runsApp"| WC
    DC -->|"deploysWith"| EC

    %% Click Events
    click WC "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/controller"
    click SL "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/service"
    click RL "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/repository"
    click DM "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/domain"
    click DTO "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/dto"
    click AC "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/config/auth"
    click JC "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/config/jwt"
    click SC "https://github.com/kksshh0612/server/blob/main/src/main/java/NestNet/NestNetWebSite/config/security/SecurityConfig.java"
    click SW "https://github.com/kksshh0612/server/blob/main/src/main/java/NestNet/NestNetWebSite/config/swagger/SwaggerConfig.java"
    click RC "https://github.com/kksshh0612/server/tree/main/src/main/java/NestNet/NestNetWebSite/config/redis"
    click WCfg "https://github.com/kksshh0612/server/blob/main/src/main/java/NestNet/NestNetWebSite/config/web/WebConfig.java"
    click MS "https://github.com/kksshh0612/server/blob/main/src/main/java/NestNet/NestNetWebSite/service/mail/MailService.java"
    click SS "https://github.com/kksshh0612/server/blob/main/src/main/java/NestNet/NestNetWebSite/service/slack/SlackService.java"
    click GB "https://github.com/kksshh0612/server/blob/main/build.gradle"
    click DC "https://github.com/kksshh0612/server/tree/main/Dockerfile"
    click EC "https://github.com/kksshh0612/server/tree/main/src/main/resources"

    %% Styles
    classDef controllers fill:#fef2c0,stroke:#333,stroke-width:2px;
    classDef services fill:#c0f0f9,stroke:#333,stroke-width:2px;
    classDef repositories fill:#d0f9c0,stroke:#333,stroke-width:2px;
    classDef domain fill:#f9d0c0,stroke:#333,stroke-width:2px;
    classDef security fill:#f9c0d0,stroke:#333,stroke-width:2px;
    classDef config fill:#c0d0f9,stroke:#333,stroke-width:2px;
    classDef infra fill:#dcdcdc,stroke:#333,stroke-width:2px;
    classDef external fill:#ffcccc,stroke:#333,stroke-width:2px;
```
