# kouki-sakata/portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/kouki-sakata/portfolio
- Repository: https://github.com/kouki-sakata/portfolio

## Overview

以下では、提供いただいたファイルツリーとREADMEをもとに、TeamDevelopプロジェクトのシステム設計図を「最も正確かつ分かりやすく」描くための手順とポイントをまとめます。主にフルスタックJava Spring BootアプリケーションかつCI/CDパイプラインを備えたモノリシックシステムとして扱い、図に落とし込むべき要素と関係性を説明します。

##### プロジェクトタイプと目的の特定
- タイプ：Java Spring BootベースのフルスタックWebアプリケーション（企業向け勤怠管理システム想定）
- フロントエンド：Thymeleafテンプレート + 静的リソース（CSS/JS）
- バックエンド：Controller → Service → MyBatis Mapper → MySQL
- CI/CD：GitHub Actions（feature.yml、ci.yml、release.yml）によるパイプライン自動化

##### ファイル構造から読み取れる主なコンポーネント
- src/main/java/com/example/teamdev
- config／annotation／aspect：アプリ起動設定、AOP、セキュリティ、キャッシュなど
- controller：HTTPリクエスト受け口（MVCのC）
- service：ビジネスロジック
- mapper & resources/mapper：DBアクセス(MyBatis)
- entity, dto, form：データモデルとリクエスト・レスポンス定義
- util, exception：ユーティリティ・例外処理
- src/main/resources
- templates：UI（Thymeleaf）
- static：クライアントサイドJS/CSS/画像
- application-*.properties：環境別設定
- infra
- Dockerfile, docker-compose.yml：コンテナ構築
- .github/workflows：CI/CD定義

##### READMEからの追加インサイト
- GitHub Actionsベースのパイプライン（Feature、Main CI、Release）
- Blue-Green／Canaryデプロイ戦略
- 環境ごとのSpringProfile切替
- セキュリティスキャン（OWASP、Trivy、GitLeaks、SonarCloud）

##### システム設計図に盛り込むべき主要コンポーネントと相互作用
a. 開発者・リポジトリ 周辺
- 開発者（IDE → git push）
- GitHubリポジトリ
- GitHub Actionsワークフロー（feature.yml / ci.yml / release.yml）
- Container Registry (GitHub Container Registry)
- Slack通知、SonarCloud、Secrets Manager
b. アプリケーション実行環境
- Load Balancer / Ingress（GKE, AWS ALB等）
- Spring Boot アプリケーション（Embedded Tomcat）
- Controller レイヤー
- Service レイヤー
- MyBatis Data Access レイヤー
- AOP/セキュリティ/キャッシュ基盤
- MySQL データベース（Dockerコンテナ or RDS）
c. クライアント
- Webブラウザ（静的リソース + HTMLテンプレート）
- AJAXリクエスト（DataTables, Vanilla JS）
d. 周辺サービス
- 外部セキュリティスキャンツール（Trivy, OWASP Dependency Check）
- CI/CD関連シークレット（GitHub Secrets, NVD API Key）
- Monitoring/Logging（Slack, GitHub Artifacts）

##### 図の具体的構成ガイドライン
- レイヤー分け：
1) User → Webブラウザ
2) Load Balancer / Ingress
3) Spring Boot モノリス（3サブレイヤー：Controller / Service / Data Access + AOP/Caching）
4) MySQL
5) CI/CDパイプライン & Container Registry
- 環境別切り替え：dev/staging/prodを色分け
- 矢印：
- データフロー（ブラウザ→Controller→Service→DB）
- デプロイフロー（git push→GitHub Actions→Docker Registry→環境）
- カラー & 形状：
- 長方形：コンポーネント（アプリケーション、DB、CI/CD）
- 角丸長方形：外部サービス（SonarCloud, Slack, Secrets Manager）
- 矢印：実行 or データの流れを明確化
- 線種：実行フロー（実線）、データフロー（破線）などで区別

##### 特に強調すべき設計原則とパターン
- MVCパターン + Serviceレイヤー分離
- AOPによる横断的関心事の隔離（SessionValidationAspect, CacheConfig）
- プロファイルベースの環境設定（application-*.properties）
- Blue-Green/Canaryのデプロイ戦略
- Git Flowブランチ戦略による安定したリリース管理

##### 作成時のチェックリスト
- 各コンポーネントに一貫したラベル（例：「AuthService」「NewsMapper」ではなく「Authentication Service」「MyBatis Mapper レイヤー」）
- 矢印の方向一致（左→右、上→下など）と矢羽根の明示
- 色分けと凡例を必ず図の下部に記載
- CI/CDフローは横一列に並べ、各ステージ（Validate, Test, Build, Deploy）をブロックで示す
- 環境変数・シークレット管理はセキュリティアイコンで強調

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    User["Web Browser"]:::external
    User -->|"HTTP Request"| LB

    %% Ingress Layer
    LB["Load Balancer / Ingress"]:::infra
    LB -->|"Forward Request"| App

    %% Application Monolith
    subgraph "Spring Boot Monolith"
        direction TB
        App["TeamDevelopApplication"]:::backend
        Config["Configuration Layer"]:::backend
        Annotation["Annotation Definitions"]:::backend
        Aspect["AOP Aspects"]:::backend
        Controller["Controller Layer"]:::backend
        GlobalEx["Global Exception Handler"]:::backend
        Service["Service Layer"]:::backend
        MapperIF["MyBatis Mapper Interfaces"]:::backend
        MapperXML["MyBatis SQL Mappings"]:::backend
        Entity["Entity Models"]:::backend
        DTO["DTOs"]:::backend
        Form["Form Objects"]:::backend
        Util["Utility Classes"]:::backend
        ExDef["Exception Definitions"]:::backend
        Static["Static Resources"]:::frontend
        Templates["Thymeleaf Templates"]:::frontend
        Props["Application Properties"]:::backend
        DBInit["DB Init & Migration Scripts"]:::backend

        App --> Config --> Annotation --> Aspect --> Controller --> GlobalEx --> Service --> MapperIF --> MapperXML --> Entity --> DTO --> Form --> Util --> ExDef
        Controller --> Static
        Controller --> Templates
        Config --> Props
        DBInit
    end

    App -->|"JDBC"| DB

    %% Database Layer
    DB["MySQL Database"]:::db

    %% CI/CD Pipeline Side
    subgraph "CI/CD Pipeline & Registry"
        direction TB
        Dev["Developer (IDE)"]:::external
        Repo["GitHub Repository"]:::infra
        FeatureWF["Feature Workflow"]:::infra
        CIWF["CI Workflow"]:::infra
        ReleaseWF["Release Workflow"]:::infra
        Registry["Container Registry"]:::infra
        Sonar["SonarCloud"]:::external
        Slack["Slack Notification"]:::external
        Secrets["Secrets Manager"]:::external

        Dev -->|"git push"| Repo
        Repo --> FeatureWF --> Registry
        Repo --> CIWF --> Registry
        Repo --> ReleaseWF --> Registry
        FeatureWF --> Sonar
        CIWF --> Sonar
        ReleaseWF --> Sonar
        FeatureWF --> Slack
        CIWF --> Slack
        ReleaseWF --> Slack
        FeatureWF --> Secrets
        CIWF --> Secrets
        ReleaseWF --> Secrets
        Registry -->|"Deploy Image"| LB
    end

    %% Click Events
    click App "https://github.com/kouki-sakata/portfolio/blob/main/src/main/java/com/example/teamdev/TeamDevelopApplication.java"
    click Config "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/config"
    click Annotation "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/annotation"
    click Aspect "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/aspect"
    click Controller "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/controller"
    click GlobalEx "https://github.com/kouki-sakata/portfolio/blob/main/src/main/java/com/example/teamdev/controller/advice/GlobalExceptionHandler.java"
    click Service "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/service"
    click MapperIF "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/mapper"
    click MapperXML "https://github.com/kouki-sakata/portfolio/tree/main/src/main/resources/com/example/teamdev/mapper"
    click Entity "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/entity"
    click DTO "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/dto"
    click Form "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/form"
    click Util "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/util"
    click ExDef "https://github.com/kouki-sakata/portfolio/tree/main/src/main/java/com/example/teamdev/exception"
    click Static "https://github.com/kouki-sakata/portfolio/tree/main/src/main/resources/static"
    click Templates "https://github.com/kouki-sakata/portfolio/tree/main/src/main/resources/templates"
    click Props "https://github.com/kouki-sakata/portfolio/blob/main/src/main/resources/application-*.properties"
    click DBInit "https://github.com/kouki-sakata/portfolio/blob/main/src/main/resources/01_schema.sql"
    click DBInit "https://github.com/kouki-sakata/portfolio/blob/main/src/main/resources/02_data.sql"
    click DBInit "https://github.com/kouki-sakata/portfolio/blob/main/src/main/resources/03_optimization_migration.sql"
    click Registry "https://github.com/kouki-sakata/portfolio/tree/main/Dockerfile"
    click Registry "https://github.com/kouki-sakata/portfolio/blob/main/docker-compose.yml"
    click FeatureWF "https://github.com/kouki-sakata/portfolio/blob/main/.github/workflows/feature.yml"
    click CIWF "https://github.com/kouki-sakata/portfolio/blob/main/.github/workflows/ci.yml"
    click ReleaseWF "https://github.com/kouki-sakata/portfolio/blob/main/.github/workflows/release.yml"

    %% Styles
    classDef frontend fill:#E8F4FD,stroke:#0288D1,color:#0288D1
    classDef backend fill:#F1F8E9,stroke:#7CB342,color:#558B2F
    classDef infra fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef db fill:#F3E5F5,stroke:#8E24AA,color:#6A1B9A
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#455A64
```
