# devgather/tiary architecture

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

- Interactive diagram: https://gitdiagram.com/devgather/tiary
- Repository: https://github.com/devgather/tiary

## Overview

##### Main Components (Top Level)

- TIARY                                         |

**Frontend Layer      Security Layer       Application Layer    Infrastructure Layer**

##### Component Details

A. Frontend Layer:
- Static resources (/static/)
- HTML templates (Thymeleaf)
- CSS and JavaScript files
- With controllers through REST endpoints

B. Security Layer:
- OAuth2 authentication
- JWT token management
- Web security configuration
- User details service
- Authentication providers

C. Application Layer (Core):
- Controllers:
- Account management
- Profile handling
- TIL (Today I Learned) operations
- Comment functionality
- Tag management
- Services:
- Business logic implementation
- Data processing
- DTOs:
- Request/Response objects

D. Infrastructure Layer:
- Database:
- JPA repositories
- Domain entities (Account, Profile, TIL, Comment, Tag)
- AWS Integration:
- S3 for storage
- Mail Service
- Exception Handling

**User Request → Frontend → Security Filter → Controller → Service → Repository → Database**
- ↑          ↑                                ↓

- ┴───────────── Response ────────┘

##### Cross-Cutting Concerns
- Logging filter
- Exception handlers
- Security filters
- Properties configuration

##### External Services Integration
- AWS S3
- Email service
- OAuth providers

##### Additional Elements
- Deployment configuration (Docker)
- CI/CD workflow connections
- Database schema relationships
- Cache layers if applicable

Key Architectural Patterns to Highlight:
- MVC pattern implementation
- Repository pattern for data access
- DTO pattern for data transfer
- Filter chain for request processing
- OAuth2 + JWT for authentication

##### Domain-driven design principles

This design reflects a modern Spring Boot application with robust security, scalable architecture, and clean separation of concerns, as evidenced by the project structure and configuration files.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph TiarySystem["TIARY System"]
        direction TB
        
        subgraph FL["Frontend Layer"]
            SR["Static Resources"]:::frontend
            TH["Thymeleaf Templates"]:::frontend
            VC["View Controllers"]:::frontend
        end

        subgraph SL["Security Layer"]
            WSC["Web Security Config"]:::security
            OAuth["OAuth2 Implementation"]:::security
            JWT["JWT Management"]:::security
            UDS["User Details Service"]:::security
        end

        subgraph AL["Application Layer"]
            CTRL["Controllers"]:::application
            SVC["Services"]:::application
            DTO["DTOs"]:::application
        end

        subgraph IL["Infrastructure Layer"]
            direction TB
            
            subgraph DB["Database"]
                DE["Domain Entities"]:::database
                REP["Repositories"]:::database
            end
            
            AWS["AWS S3"]:::infrastructure
            EH["Exception Handling"]:::infrastructure
            MAIL["Mail Service"]:::infrastructure
            PROP["Properties Config"]:::infrastructure
        end

        subgraph CC["Cross-Cutting Concerns"]
            LOG["Logging Filter"]:::crosscut
            EXH["Exception Handlers"]:::crosscut
            SF["Security Filters"]:::crosscut
            CONF["Configuration"]:::crosscut
        end
    end

    %% External Services
    ES["External Services"]:::external

    %% Relationships
    SR --> VC
    TH --> VC
    VC --> CTRL
    CTRL --> SVC
    SVC --> REP
    REP --> DE
    CTRL --> DTO
    WSC --> SF
    OAuth --> UDS
    JWT --> SF
    SVC --> AWS
    SVC --> MAIL
    OAuth --> ES
    AWS --> ES
    MAIL --> ES

    %% Click Events
    click SR "https://github.com/Devgather/TIARY/tree/main/src/main/resources/static/"
    click TH "https://github.com/Devgather/TIARY/tree/main/src/main/resources/templates/"
    click VC "https://github.com/Devgather/TIARY/blob/main/src/main/java/me/tiary/controller/ViewController.java"
    click WSC "https://github.com/Devgather/TIARY/blob/main/src/main/java/me/tiary/config/WebSecurityConfig.java"
    click OAuth "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/security/oauth2/"
    click JWT "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/utility/jwt/"
    click UDS "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/security/web/userdetails/"
    click CTRL "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/controller/"
    click SVC "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/service/"
    click DTO "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/dto/"
    click DE "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/domain/"
    click REP "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/repository/"
    click AWS "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/utility/aws/"
    click EH "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/exception/"
    click PROP "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/properties/"
    click LOG "https://github.com/Devgather/TIARY/blob/main/src/main/java/me/tiary/filter/LoggingFilter.java"
    click EXH "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/exception/handler/"
    click CONF "https://github.com/Devgather/TIARY/tree/main/src/main/java/me/tiary/config/"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef security fill:#f1c40f,stroke:#f39c12,color:black
    classDef application fill:#2ecc71,stroke:#27ae60,color:white
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef database fill:#34495e,stroke:#2c3e50,color:white
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef crosscut fill:#9b59b6,stroke:#8e44ad,color:white
```
