# font-king/fontory_be architecture

> Architecture diagram of the GitHub repository font-king/fontory_be, 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/font-king/fontory_be
- Repository: https://github.com/font-king/fontory_be

## Overview

##### Project Type and Purpose
- This is a back-end service for an application named FONTory_BE. Its main purpose is to manage various domains such as authentication (OAuth2 and JWT-based), bookmarks, file operations (with S3 integration), font management, and member as well as provide services.
- The use of Gradle as the build tool, Docker configurations (Dockerfile and docker-compose.yml), and monitoring setups (Prometheus and Grafana configuration files) indicates that the project supports containerized deployments and is production-ready with observability instrumentation.

##### File Structure
- The src/main/java/org/fontory/fontorybe directory contains multiple modules, each mapped to a domain:
- authentication: handling security, token generation, OAuth2 flows.
- bookmark: managing bookmarks (with controllers, domain exceptions, and service implementations).
- file: integrating with cloud storage (AWS S3) and handling file upload/download.
- font: operations related to fonts (creation, deletion, update, status monitoring etc).
- member: CRUD operations and member management along with error handling.
- provide: likely manages external or internal resource data.
- The layered folder naming (controller, service, domain, infrastructure) clearly follows a typical hexagonal or layered architecture, separating the presentation, business logic, and persistence layers.
- Additional directories for configuration (src/main/java/org/fontory/fontorybe/config) and global filters/interceptors indicate cross-cutting concerns (such as security, logging, performance).

##### Recommended Components
a. Main Components:
- Client / API Consumers: Representing any external clients (mobile/web) that call the REST endpoints.
- Authentication Service:
- Contains controllers for login, OAuth2 handlers, JWT token management.
- Integrates with external OAuth2 providers.
- Domain Modules:
- Bookmark Module: Controller, service, domain entities (e.g., BookmarkEntity) and repository abstractions.
- File Module: Handling file upload/download requests, error management, and integration with AWS S3 (see S3Config and AmazonS3BucketService).
- Font Module: Manages font data and workflow endpoints (create, update, delete, progress monitoring).
- Member Module: Manages user/member-related actions such as creation, updates, disabling, and validation.
- Provide Module: Deals with resource provisioning, including domain exceptions and repository implementations.
- Common Infrastructure and Configurations:
- Global Exception Handling, Logging Aspects, Security configurations (WebConfig, SecurityConfig), and Health checks.
- Integration with external services (e.g., S3 for file storage, Prometheus for monitoring and Grafana dashboards).
- Database:
- Persistence layer for all modules which interacts via JPA repositories (e.g., BookmarkJpaRepository, FontJpaRepository, MemberJpaRepository, ProvideJpaRepository).

b. Supporting Components:
- CI/CD Pipeline Elements:
- Presence of GitHub Actions (workflows like CICD_DEVELOP.yml, CI_TEST.yml) which are part of the overall DevOps/automation workflow.
- Test Layers:
- Integration, unit, and mock tests are set up to verify the system components.

##### Relationships and Interactions
- Requests from external clients are received by the REST controllers that reside in each module (authentication, bookmark, file, font, member, provide).
- Cross-cutting concerns like authentication and exception handling are applied at the entry point (e.g., filters such as RequestUUIDFilter and AuthenticationEntryPoint).
- The controllers call the service layer which in turn interact with domain objects and perform business logic.
- The service layer communicates with the persistence layer (infrastructure package) via JPA repositories/other repository abstractions.
- Integration with external systems (AWS S3, monitoring tools like Prometheus and Grafana) is done through dedicated configuration and adapter classes.

##### Architectural Patterns and Technologies
- Layered (or hexagonal) architecture: Controllers → Services → Domain/Repositories.
- Use of OAuth2 and JWT for security.
- Cloud integration patterns using AWS S3 for file storage.
- Monitoring and logging integration using Prometheus and Grafana.
- Containerization and deployment using Docker and Docker Compose.
- CI/CD setup using GitHub Actions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client/API Consumer"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        authC["Authentication Controller"]:::controller
        bookmarkC["Bookmark Controller"]:::controller
        fileC["File Controller"]:::controller
        fontC["Font Controller"]:::controller
        memberC["Member Controller"]:::controller
        provideC["Provide Controller"]:::controller
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        authS["Authentication Service"]:::service
        bookmarkS["Bookmark Service"]:::service
        fileS["File Service"]:::service
        fontS["Font Service"]:::service
        memberS["Member Service"]:::service
        provideS["Provide Service"]:::service
    end

    %% Data Persistence Layer
    subgraph "Data Persistence Layer"
        DB["Database (SQL)"]:::database
    end

    %% Global Configurations
    subgraph "Global Configurations"
        commonEx["Global Exception Handler & Health Checks"]:::config
        secConfig["Security & Web Configurations"]:::config
        s3config["AWS S3 Config"]:::config
    end

    %% External Integrations
    subgraph "External Integrations"
        oauth["OAuth2 Provider"]:::external
        s3["AWS S3 Storage"]:::external
        prometheus["Prometheus"]:::external
        grafana["Grafana"]:::external
    end

    %% DevOps & Deployment
    subgraph "DevOps & Deployment"
        cicd["CI/CD Pipeline"]:::devops
        dfile["Dockerfile"]:::devops
        dcompose["docker-compose.yml"]:::devops
    end

    %% Client calls to Presentation Layer
    Client --> authC
    Client --> bookmarkC
    Client --> fileC
    Client --> fontC
    Client --> memberC
    Client --> provideC

    %% Presentation to Business Layer
    authC --> authS
    bookmarkC --> bookmarkS
    fileC --> fileS
    fontC --> fontS
    memberC --> memberS
    provideC --> provideS

    %% Business Layer to Data Persistence
    authS --> DB
    bookmarkS --> DB
    fileS --> DB
    fontS --> DB
    memberS --> DB
    provideS --> DB

    %% External Integration Connections
    authS -->|"uses"| oauth
    fileS -->|"integratesWith"| s3

    %% Monitoring Flow
    authS --> prometheus
    bookmarkS --> prometheus
    fileS --> prometheus
    fontS --> prometheus
    memberS --> prometheus
    provideS --> prometheus
    prometheus --> grafana

    %% Global Configurations applied to Presentation Layer (dashed connections)
    secConfig --- authC
    secConfig --- bookmarkC
    secConfig --- fileC
    secConfig --- fontC
    secConfig --- memberC
    secConfig --- provideC

    commonEx --- authC
    commonEx --- bookmarkC
    commonEx --- fileC
    commonEx --- fontC
    commonEx --- memberC
    commonEx --- provideC

    %% DevOps connections
    cicd --> dfile
    cicd --> dcompose

    %% Click Events
    click authS "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/authentication"
    click bookmarkS "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/bookmark"
    click fileS "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/file"
    click fontS "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/font"
    click memberS "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/member"
    click provideS "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/provide"
    click commonEx "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/common/controller"
    click secConfig "https://github.com/font-king/fontory_be/tree/develop/src/main/java/org/fontory/fontorybe/config"
    click s3config "https://github.com/font-king/fontory_be/blob/develop/src/main/java/org/fontory/fontorybe/config/S3Config.java"
    click cicd "https://github.com/font-king/fontory_be/tree/develop/.github/workflows"
    click dfile "https://github.com/font-king/fontory_be/tree/develop/Dockerfile"
    click dcompose "https://github.com/font-king/fontory_be/blob/develop/docker-compose.yml"
    click prometheus "https://github.com/font-king/fontory_be/blob/develop/prometheus-config.yaml"
    click grafana "https://github.com/font-king/fontory_be/tree/develop/grafana/dashboards"

    %% Styles
    classDef controller fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef service fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef database fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef config fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
    classDef devops fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
```
