# palxiao/poster-design architecture

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

- Interactive diagram: https://gitdiagram.com/palxiao/poster-design
- Repository: https://github.com/palxiao/poster-design

## Overview

##### Main Components
- Frontend Client:
- Uses Vue3 for component-driven UI, Vite for a fast development build, and Pinia for state management.
- Contains views, components, modules (business features such as image cutting, crop, design board, widget panels), routing (under "src/router"), and centralized state management (under "src/store").
- Backend Service:
- Found under the "service" folder, which includes configuration files, Express API endpoints, and supporting service logic (e.g., image generation, user management, and file operations).
- Provides example APIs and serves as the proof-of-concept backend that demonstrates how to integrate with frontend requests.
- Reusable Packages:
- DevOps / Deployment:
- The Docker configuration is in the "docker" folder with separate Dockerfiles for the API and web server.
- A docker-compose configuration (docker/docker-compose.yaml) orchestrates multi-container deployments, ensuring both the frontend web server and backend API are containerized.
- External Tools & Libraries:
- The README mentions integration with external tools like Puppeteer for image generation and html2canvas for canvas capture, as well as AI-based image extraction and PSD parsing libraries.

##### Relationships and Data Flow
- The frontend application interacts with the back-end service primarily via HTTP API calls (documented in the "src/api" and "service/src/control" directories).
- User interactions in the design editor (e.g., dragging, cropping, text editing) trigger state changes in the Vue-based UI, which may then invoke API endpoints to generate high-resolution output images or perform image processing.
- In a containerized deployment, the docker-compose setup ensures that the “web” (frontend) and “api” (backend) containers can communicate and work together seamlessly.

##### Architectural Patterns and Design Principles
- Modular Design: The project is organized as a monorepo with clearly separated packages (for instance, reusable UI components and specialized image processing applications) and a clear folder separation for frontend, backend, and services.
- Separation of Concerns: There is a distinct separation between frontend presentation (Vue components, views, and state management) and backend logic (Express-based API services).
- Containerization: The use of Docker and docker-compose encapsulates various parts of the system into containers, enabling consistent deployments.
- API-driven Development: The design encourages a service-oriented architecture where the frontend relies on back-end APIs for tasks like image generation and template processing.

##### Final Detailing
- Integration points: Docker (which brings both frontend and backend together) and reusable packages (which are shared libraries).
- Be detailed; separating the design into as many functional and infrastructural components as possible will provide a complete technical overview that can guide further development or debugging.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        F1["Frontend Client (Vue3, Vite, Pinia)"]:::frontend
        F2["UI Components (views, router, store)"]:::frontend
        F3["Reusable Packages"]:::frontend

        F4["Color Picker Module"]:::package
        F5["Image Extraction Module"]:::package

        F1 --> F2
        F1 --> F3
        F3 --> F4
        F3 --> F5
    end

    %% Application/Business Logic Layer
    subgraph "Application/Business Logic Layer"
        B1["Backend API (Express)"]:::backend
        B2["API Control (service/src/control)"]:::backend
        B3["Service Modules (service/src/service)"]:::backend
        B4["Image Generation (Puppeteer, html2canvas)"]:::backend
        B5["PSD Parsing & AI Extraction"]:::backend

        B1 --> B2
        B1 --> B3
        B3 --> B4
        B3 --> B5
    end

    %% Infrastructure / Containerization Layer
    subgraph "Infrastructure/Containerization"
        I1["Docker Compose (docker/docker-compose.yaml)"]:::infrastructure
        I2["Frontend Container (web)"]:::infrastructure
        I3["Backend Container (api)"]:::infrastructure

        I1 --> I2
        I1 --> I3
    end

    %% Interactions between layers
    F1 -->|"HTTP_API"| B1

    %% Click Events
    click F2 "https://github.com/palxiao/poster-design/tree/main/src"
    click F4 "https://github.com/palxiao/poster-design/tree/main/packages/color-picker"
    click F5 "https://github.com/palxiao/poster-design/tree/main/packages/image-extraction"
    click B2 "https://github.com/palxiao/poster-design/tree/main/service/src/control"
    click B3 "https://github.com/palxiao/poster-design/tree/main/service/src/service"
    click I1 "https://github.com/palxiao/poster-design/blob/main/docker/docker-compose.yaml"
    click I2 "https://github.com/palxiao/poster-design/tree/main/docker/web/Dockerfile"
    click I3 "https://github.com/palxiao/poster-design/tree/main/docker/api/Dockerfile"

    %% Styling
    classDef frontend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef backend fill:#BBDEFB,stroke:#1565C0,stroke-width:2px;
    classDef infrastructure fill:#FFECB3,stroke:#FF6F00,stroke-width:2px;
    classDef package fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
```
