# heeyeon205/newsion-server architecture

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

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

## Overview

##### Project type and purpose
- This is a full‐stack news summary and community platform (“NEWSION”) with:
- A React+Vite+Tailwind front‐end
- A Spring Boot 3.4 monolithic back‐end in Java 17
- MySQL for primary data, Redis for caching, Elasticsearch for search, AWS S3 for file storage
- External integrations: OAuth2 (Google/Kakao/Naver), PortOne payment gateway, ELK logging stack

##### File structure
- Top‐level “src/main/java/com/newsvision” is organized by module:
- admin, board (community), category, news (Naver+GPT), poll (voting), notice, user, mypage, elasticsearch
- global cross‐cutting concerns: auth, aws, exception, jwt, payment, redis, security, swagger, utils
- Persistence layer: repositories in each module
- Service layer: business logic grouped per module
- Controller layer: REST API endpoints per module
- Infrastructure: docker/es-kibana for ELK, application.yml configuration

##### README for additional insights
- Tech stack confirms DB (MySQL), cache (Redis), search (Elasticsearch), infra (Docker, AWS)
- Teams implemented OAuth2, JWT, ELK logging, payment via PortOne

- Client Layer:
- Web Browser (end user / admin interfaces)
- Front‐end Layer:
- React App (deployed on CDN or S3/CloudFront)
- API Gateway / Load Balancer (e.g., AWS ALB / Nginx)
- Back‐end Layer (Spring Boot Monolith):
- Presentation (Controllers)
- Application Services (business logic modules)
- Domain Entities & Repositories (MySQL)
- Cache (Redis)
- Search (Elasticsearch cluster)
- Notification (NoticeService sending in‐app notifications)
- External Services:
- OAuth2 Providers (Google, Kakao, Naver)
- PortOne Payment Gateway
- AWS S3 (file uploads)
- ELK Stack (Logstash, Elasticsearch, Kibana for logs)
- Data Stores:
- MySQL Primary Database
- Redis Cache & Token Blacklist
- Elasticsearch (search indexes for news & board)

b. Relationships & interactions:
- Browser → React App (HTTP/HTTPS)
- React App → API Gateway → Spring Boot Controllers (REST calls)
- Controllers → Service Layer → Repositories (CRUD in MySQL)
- Service Layer ↔ Redis for caching tokens, session info, popular keywords
- Service Layer ↔ Elasticsearch (indexing & search queries)
- Service Layer ↔ AWS S3 (upload/download media)
- Service Layer ↔ OAuth2 providers (token exchange)
- Service Layer ↔ PortOne (payment initialization, refunds)
- Spring Boot logs → Logstash agent → Elasticsearch (logs) → Kibana UI

c. Architectural patterns & design principles:
- Layered (Controller → Service → Repository)
- Package per feature (modular monolith)
- Externalized configuration (application.yml, Docker Compose)
- Dependency inversion via Spring DI
- Separation of cross‐cutting concerns (global/auth, jwt, exception, aws)

d. Key technologies & frameworks:
- Spring Boot + Spring Security + OAuth2 + JWT
- Spring Data JPA (MySQL), Spring Data Redis, Elasticsearch Java Client
- Docker Compose for ELK
- React + Vite + TailwindCSS
- AWS SDK for S3

##### Diagramming conventions
- Use parallelograms or clouds for external services (OAuth2, S3, Payment Gateway)
- Blue for internal components
- Green for data stores
- Orange for external systems
- Related modules inside a larger “Spring Boot Monolith” boundary

##### Detailed capture of essential elements
- Layers inside the monolith: Presentation, Business Logic (feature packages), Persistence
- ELK sidecar container connected to the monolith’s log output
- Caching strategy and token blacklist in Redis
- Index pipelines in Elasticsearch for popular keywords, board & news documents

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        Browser["Web Browser"]:::external
    end

    subgraph "Front-end Layer"
        React["React + Vite + Tailwind App"]:::internal
    end

    Browser -->|"HTTP/HTTPS"| React
    React -->|"API Calls"| ALB["API Gateway / Load Balancer"]:::internal

    subgraph "Spring Boot Monolith"
        direction TB
        Entry["NewsVisionApplication"]:::internal
        subgraph "Presentation Layer"
            Controllers["Controllers"]:::internal
        end
        subgraph "Business Logic Layer"
            Services["Services"]:::internal
        end
        subgraph "Persistence Layer"
            Repos["Repositories (MySQL)"]:::datastore
        end
        Entry --> Controllers --> Services --> Repos
        Services --> RedisCache["Redis Cache"]:::datastore
        Services --> ESCluster["Elasticsearch Cluster"]:::datastore
        Services --> S3["AWS S3"]:::external
        Services --> OAuth2["OAuth2 Providers"]:::external
        Services --> PaymentGW["PortOne Payment Gateway"]:::external
        Entry -.-> Logstash["Logstash Agent"]:::external
    end

    ALB --> Controllers

    Logstash -->|"forwards logs"| ELKES["ELK Stack (Logs Elasticsearch)"]:::datastore
    ELKES --> Kibana["Kibana UI"]:::external

    Repos --> MySQL["MySQL Database"]:::datastore

    click Entry "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/NewsVisionApplication.java"
    click Controllers "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/admin/controller"
    click Controllers "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/board/controller"
    click Controllers "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/news/controller"
    click Controllers "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/poll/controller/PollController.java"
    click Controllers "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/notice/controller/NoticeController.java"
    click Controllers "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/user/controller"
    click Controllers "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/auth/AuthController.java"
    click Controllers "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/mypage/controller/MyPageController.java"
    click Controllers "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/elasticsearch/controller"
    click Services "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/admin/service"
    click Services "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/board/service"
    click Services "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/news/service"
    click Services "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/poll/service"
    click Services "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/notice/service/NoticeService.java"
    click Services "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/user/service"
    click Services "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/mypage/service/MypageService.java"
    click Services "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/elasticsearch/service"
    click Repos "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/board/repository"
    click Repos "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/news/repository"
    click Repos "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/poll/repository"
    click Repos "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/notice/repository"
    click Repos "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/user/repository"
    click Repos "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/category/CategoryRepository.java"
    click Repos "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/jwt/RefreshTokenRepository.java"
    click Repos "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/jwt/TempTokenRepository.java"
    click RedisCache "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/redis/RedisConfig.java"
    click RedisCache "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/redis/TokenBlacklistService.java"
    click ESCluster "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/elasticsearch/config/ElasticsearchConfig.java"
    click ESCluster "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/elasticsearch/document"
    click ESCluster "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/elasticsearch/repository"
    click S3 "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/aws/AwsS3Config.java"
    click S3 "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/aws/FileUploaderService.java"
    click S3 "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/aws/S3Uploader.java"
    click OAuth2 "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/global/security/oauth"
    click OAuth2 "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/security/CustomUserDetails.java"
    click OAuth2 "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/security/CustomUserDetailsService.java"
    click PaymentGW "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/payment/config/PortOneConfig.java"
    click PaymentGW "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/payment/controller/PaymentController.java"
    click PaymentGW "https://github.com/heeyeon205/newsion-server/blob/main/src/main/java/com/newsvision/global/payment/service/PaymentService.java"
    click PaymentGW "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/global/payment/domain"
    click PaymentGW "https://github.com/heeyeon205/newsion-server/tree/main/src/main/java/com/newsvision/global/payment/dto"
    classDef internal fill:#D0E8FF,stroke:#333
    classDef external fill:#FFE0B2,stroke:#333
    classDef datastore fill:#C8E6C9,stroke:#333
```
