# mocco329/phorest architecture

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

- Interactive diagram: https://gitdiagram.com/mocco329/phorest
- Repository: https://github.com/mocco329/phorest

## Overview

##### Main Components
- Backend (dev/BE): This is a Spring Boot application managing core business logic, REST APIs, security (JWT, authentication, and OAuth possibly via Kakao), and database interactions via JPA with MySQL. It includes dedicated packages for controllers, services, repositories, domain models, DTOs, and various configurations (e.g., SecurityConfig, SwaggerConfig, S3 uploader integration, etc.).
- Frontend (dev/FE): A React application using Redux for state management. It is organized into pages, components, APIs (to interact with the backend), assets, and store modules. This part handles the client-side user interface for users to view and interact with the photo community service.
- IoT Modules (dev/IoT): These contain several subprojects:
- AR_JS: Uses external AR libraries (NFT marker creator) to generate or interact with AR content.
- PyQT: Multiple versions are present for developing photo booth or kiosk functionality using Qt and OpenCV. These likely handle image capture, UI for photo booths, and even some processing (face tracking and more).
- Infrastructure & External Services:
- AWS: The system is or was deployed on AWS (EC2, S3 for storage) with Nginx for routing.
- Jenkins and GitLab: Automated build and deployment pipelines are set up to trigger on pushes/merges.
- Database: MySQL (as inferred from the README and BE config).
- External APIs: There is integration with Kakao (for messaging, etc.) and possibly other external AR services.

##### Relationships & Interactions
- Clients (end-users) interact with the Frontend (React) which makes API calls to the Backend.
- The Backend provides REST endpoints for user authentication, photo management, frame creation, messaging, etc.
- The Backend communicates with the database (MySQL) for persistent storage and with AWS S3 to store images and other assets.
- The IoT modules (photo booth devices / AR applications) interact with the Backend either by submitting captured images (via QR code triggered URLs) or by fetching configuration data.
- Build and deployment are managed via Jenkins (monitoring the dev branch in GitLab), which then updates the services on AWS EC2.
- Security is ensured using JWT-based authentication and Spring Security configuration layers.

##### Architectural Patterns & Design Principles
- Layered Architecture in the Backend: Separate layers for controllers, services, and repositories, adhering to principles like separation of concerns.
- RESTful API Design: Clearly defined endpoints for various photo and user actions.
- Frontend as Single-Page Application (SPA): Organized with React components, Redux state management and clear separation of presentation and API handling.
- IoT Modules as Independent but Integrated Systems: Although built in different languages (JavaScript and Python/PyQT), they represent distinct deployment units that integrate with the main system via network calls.
- Build and Deployment Automation: Using Jenkins for CI/CD, ensuring that integration across FE/BE/IoT is continuously tested and deployed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    User["User Browser"]:::user

    %% Frontend Subgraph
    subgraph "Frontend (React + Redux)"
        FE["Frontend Client<br>(Pages, Components, APIs, Store)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Spring Boot + MySQL + AWS S3)"
        BE["Backend Core<br>(Spring Boot)"]:::backend
        API["API Controllers"]:::backend
        SRV["Service Layer"]:::backend
        SEC["Security Components<br>(JWT, SecurityConfig)"]:::backend
        TPI["Third-Party Integration<br>(S3, Kakao)"]:::backend
    end

    %% IoT Modules Subgraph
    subgraph "IoT Modules"
        AR["AR Module<br>(AR_JS)"]:::iot
        PYQT["PyQT Modules<br>(Photo Booth & Kiosk)"]:::iot
        FT["Face Tracker Module"]:::iot
    end

    %% Infrastructure & CI/CD Subgraph
    subgraph "Infrastructure & CI/CD"
        DB[(MySQL Database)]:::database
        S3[(AWS S3)]:::external
        AWS["AWS EC2"]:::external
        CI["CI/CD Pipeline<br>(Jenkins & GitLab)"]:::external
        NGINX["Nginx Router"]:::external
    end

    %% Relationships
    User -->|"uses"| FE
    FE -->|"APIcalls"| API

    API -->|"calls"| SRV
    SRV -->|"persists"| DB
    SRV -->|"uploads"| S3

    API -->|"secures"| SEC
    SRV -->|"integrates"| TPI

    %% IoT interactions with Backend API
    AR -->|"uploads/config"| API
    PYQT -->|"uploads/config"| API
    FT -->|"sendsData"| API

    %% Deployment Pipelines
    CI -->|"deploysto"| AWS
    AWS -->|"hosts"| BE
    AWS -->|"routesvia"| NGINX

    %% Click Events for Backend Components
    click BE "https://github.com/mocco329/phorest/tree/master/dev/BE"
    click API "https://github.com/mocco329/phorest/tree/master/dev/BE/src/main/java/a101/phorest/controller"
    click SRV "https://github.com/mocco329/phorest/tree/master/dev/BE/src/main/java/a101/phorest/service"
    click SEC "https://github.com/mocco329/phorest/blob/master/dev/BE/src/main/java/a101/phorest/config/SecurityConfig.java"
    click SEC "https://github.com/mocco329/phorest/tree/master/dev/BE/src/main/java/a101/phorest/jwt"
    click SEC "https://github.com/mocco329/phorest/tree/master/dev/BE/src/main/java/a101/phorest/auth"
    click TPI "https://github.com/mocco329/phorest/blob/master/dev/BE/src/main/java/a101/phorest/S3Config.java"
    click TPI "https://github.com/mocco329/phorest/blob/master/dev/BE/src/main/java/a101/phorest/S3Uploader.java"
    click TPI "https://github.com/mocco329/phorest/blob/master/dev/BE/src/main/java/a101/phorest/dto/KakaoDTO.java"
    click TPI "https://github.com/mocco329/phorest/blob/master/dev/BE/src/main/java/a101/phorest/service/KakaoService.java"

    %% Click Events for Frontend Components
    click FE "https://github.com/mocco329/phorest/tree/master/dev/FE"
    click FE "https://github.com/mocco329/phorest/tree/master/dev/FE/src/pages"
    click FE "https://github.com/mocco329/phorest/tree/master/dev/FE/src/components"
    click FE "https://github.com/mocco329/phorest/tree/master/dev/FE/src/api"
    click FE "https://github.com/mocco329/phorest/tree/master/dev/FE/src/store"

    %% Click Events for IoT Components
    click AR "https://github.com/mocco329/phorest/tree/master/dev/IoT/AR_js"
    click PYQT "https://github.com/mocco329/phorest/tree/master/dev/IoT/PyQT"
    click FT "https://github.com/mocco329/phorest/tree/master/dev/IoT/face_tracker"

    %% Styling
    classDef frontend fill:#d3e8ff,stroke:#1f78b4,stroke-width:2px;
    classDef backend fill:#ffe6cc,stroke:#ff8c00,stroke-width:2px;
    classDef iot fill:#e6ffe6,stroke:#2ca02c,stroke-width:2px;
    classDef database fill:#fff2cc,stroke:#b58900,stroke-width:2px;
    classDef external fill:#fce5cd,stroke:#d35400,stroke-width:2px;
    classDef user fill:#f9d5e5,stroke:#c0392b,stroke-width:2px;
```
