# sopt-all/36-sopkathon-server-web2 architecture

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

- Interactive diagram: https://gitdiagram.com/sopt-all/36-sopkathon-server-web2
- Repository: https://github.com/sopt-all/36-sopkathon-server-web2

## Overview

##### Project Type and Purpose
- This is a Spring Boot–based backend service (monolithic REST API) for the “솝커톤 웹2팀” application.
- It exposes endpoints for managing “pins” (geolocated markers), users, votes, and image uploads, persisting data in a relational database and storing images in AWS S3.

##### File-Structure Analysis
- Top-level build and config:
- Dockerfile, Gradle wrapper, build.gradle, settings.gradle → containerization & build.
- .github/workflows/main.yml → CI pipeline.
- Source code under src/main/java/com/sopkathon/teamweb:
- domain/*/controller → REST controllers.
- domain/*/service → business logic.
- domain/*/repository → Spring Data JPA repositories.
- domain/*/domain → JPA entities and constants.
- domain/*/dto → request/response DTOs.
- global/config → CORS, JPA auditing, S3, Swagger.
- infra/S3Service → AWS S3 integration.
- Test code under src/test.

##### README Insights
- Confirms this is the server component.

##### Diagramming the Architecture
a. Main Components
- External clients (e.g., Web app, mobile)
- API Layer (HTTP) → Controllers (PinController, ImageController, etc.)
- Service Layer → PinService, UserService, Vote logic, S3Service
- Persistence Layer → Spring Data JPA Repositories
- Database (e.g., MySQL, PostgreSQL)
- External Storage → AWS S3 bucket
- Configuration & Cross-cutting concerns → CORS, Swagger UI
b. Relationships & Data Flows
1. Client → HTTP(S) → Controller
2. Controller → Service → (optional) S3Service for images
3. Service → Repository → Database
4. Service → Repository → Vote/User/Pin tables
5. Async or direct HTTP to AWS S3 for image upload/download
c. Architectural Patterns
- Layered (Controller → Service → Repository)
- Domain-driven package structure
- Configuration classes centralize cross-cutting concerns
- Exception handling via GlobalExceptionHandler
d. Key Technologies
- Spring Boot (embedded Tomcat)
- Spring MVC (Controllers)
- Spring Data JPA & Hibernate
- AWS SDK (S3Service)
- Swagger (API docs)
- Gradle, Docker, GitHub Actions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Client["Web/Mobile Clients"]:::external

    %% API Layer
    subgraph "API Layer"
        PC["PinController"]:::api
        IC["ImageController"]:::api
    end

    %% Service Layer
    subgraph "Service Layer"
        PS["PinService"]:::service
        SS3["S3Service"]:::service
    end

    %% Repository Layer
    subgraph "Repository Layer"
        PR["PinRepository"]:::data
        UR["UserRepository"]:::data
        VR["VoteRepository"]:::data
    end

    %% Persistence and External Storage
    DB[(Database)]:::database
    S3([AWS S3 Bucket]):::external

    %% Configuration & Common Modules
    subgraph "Config & Common"
        CCors["CorsConfig"]:::config
        S3Conf["S3Config"]:::config
        SW["SwaggerConfig"]:::config
        JPAConf["EnableJpaAuditingConfig"]:::config
        GEx["GlobalExceptionHandler"]:::config
        BaseE["BaseEntity"]:::config
        RespDto["ResponseDto"]:::config
    end

    %% Data Flows
    Client -->|"HTTP"| PC
    Client -->|"HTTP"| IC
    PC -->|"calls"| PS
    IC -->|"calls"| SS3
    PS -->|"uses"| PR
    PS -->|"uses"| UR
    PS -->|"uses"| VR
    PR -->|"reads/writes"| DB
    UR -->|"reads/writes"| DB
    VR -->|"reads/writes"| DB
    SS3 -->|"upload/download"| S3

    %% Click Events
    click PC "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/domain/pin/controller/PinController.java"
    click IC "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/domain/image/ImageController.java"
    click PS "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/domain/pin/service/PinService.java"
    click PR "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/domain/pin/repository/PinRepository.java"
    click UR "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/domain/user/repository/UserRepository.java"
    click VR "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/domain/vote/repository/VoteRepository.java"
    click SS3 "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/infra/S3Service.java"
    click S3Conf "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/global/config/S3Config.java"
    click CCors "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/global/config/CorsConfig.java"
    click SW "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/global/config/SwaggerConfig.java"
    click JPAConf "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/global/config/EnableJpaAuditingConfig.java"
    click GEx "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/global/common/exception/GlobalExceptionHandler.java"
    click BaseE "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/global/common/entity/BaseEntity.java"
    click RespDto "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/global/common/dto/ResponseDto.java"
    click TeamwebApp "https://github.com/sopt-all/36-sopkathon-server-web2/blob/main/src/main/java/com/sopkathon/teamweb/TeamwebApplication.java"

    %% Styles
    classDef api fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef service fill:#E6F4EA,stroke:#22863A,color:#22863A;
    classDef data fill:#FFEDD5,stroke:#D94F00,color:#D94F00;
    classDef database fill:#FFE4E1,stroke:#B31D1D,color:#B31D1D;
    classDef external fill:#F0F0F0,stroke:#6A737D,color:#6A737D;
    classDef config fill:#F5F5F5,stroke:#D1D5DA,color:#444444;
```
