# lyqht/mini-qr architecture

> Architecture diagram of the GitHub repository lyqht/mini-qr, 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/lyqht/mini-qr
- Repository: https://github.com/lyqht/mini-qr

## Overview

##### Main Components
- Frontend / PWA Layer:
- Entry point: index.html; application startup via src/main.js that bootstraps the Vue application (App.vue).
- UI Components: Organized into “src/components” and specifically grouped reusable UI pieces under “src/components/ui” (dialogs, drawers, popovers, button groups, etc).
- Assets & Presets: Static preset configurations and style presets under “src/assets/presets” which define predefined QR code styles.
- Internationalization: Managed via the “locales” folder containing language JSONs for over 30+ languages.

- Testing & Quality:
- Playwright e2e tests in “tests/e2e” guarantee front-end functionality.
- Linting and formatting configurations (e.g., .eslintrc.cjs, .prettierrc.json) ensure code quality.

- Deployment & DevOps:
- Dockerfile, docker-compose.yml, and GitHub workflows (under .github/workflows) streamline builds, containerization, and CI/CD pipelines.
- PWA support integrated into the application, with service worker and manifest configurations (likely generated/handled by Vite PWA plugins and public folder resources).

##### Relationships and Interactions
- The entry point (index.html and src/main.js) boots the Vue app, which renders the App.vue component.
- App.vue orchestrates routing, state management, and renders different UI components that are responsible for specific functions such as QR code creation (components like QRCodeCreate.vue), scanning (QRCodeScan.vue, QRCodeCameraScanner.vue) and previewing (StyledQRCode.vue).
- The presets (QR code styling configurations) from src/assets/presets are applied within the UI to offer customizable designs.
- Interaction with the device’s camera (for scanning) or clipboard (for copying) happens within specialized components.
- E2E tests simulate typical user flows, ensuring that user interactions trigger the correct internal component communication.
- Deployment is containerized using Docker, ensuring that the entire front-end can be hosted easily (self-hosting option described in the README).

##### Architectural Patterns & Design Principles
- Component-Based Architecture: The project extensively uses Vue’s component system, splitting the UI into reusable parts.
- Separation of Concerns: Clear folder delineation between presentation (UI components), business logic (utils, lib), assets (presets, images) and configuration (Docker, Vite, ESLint).
- Internationalization: The inclusion of many locale files emphasizes the need to design a system that readily supports multiple languages.
- PWA Design: Capturing service worker, offline capabilities, and an installable app experience.
- DevOps & CI/CD: With Docker files and GitHub actions, an automated build and test process is integrated to support continuous deployment.

##### Elements
- "Entry Point (index.html & main.js)"
- "Vue Application (App.vue)"
- "UI Components (QR Code Creation, Scanning, etc.)"
- "Business Logic & Utilities (QR Code generation, i18n, etc.)"
- "Assets & Presets (Static configurations for QR styles)"
- "Testing (Playwright e2e)"

- "Docker Configuration" (Dockerfile & docker-compose)
- "CI/CD Pipeline" (GitHub workflows)

- Data flow from the user triggering events (e.g., scanning or creating a QR code) through UI components to business logic.
- Interaction between i18n utilities and UI components.
- Build/test/deploy flows from source code through Docker and GitHub Actions.

##### Final Recommendations
- To include annotations next to each component explaining its main responsibilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client-Side Application
    subgraph "Client-Side Application"
        EntryHTML["index.html"]:::frontend
        MainJS["src/main.js"]:::frontend
        AppVue["App.vue"]:::frontend
        UIComp["src/components (QR Code Components)"]:::frontend
        UIReusable["src/components/ui (Reusable UI)"]:::frontend
    end

    %% Business Logic & Assets
    subgraph "Business Logic & Assets"
        Lib["src/lib (Business Logic)"]:::business
        Utils["src/utils (Utilities)"]:::business
        Assets["src/assets/presets (Assets & Presets)"]:::assets
        Locales["locales (Internationalization)"]:::assets
    end

    %% Testing & Quality
    subgraph "Testing & Quality"
        E2E["tests/e2e (Playwright e2e tests)"]:::testing
        Quality["Linting/Formatting (.eslintrc, .prettierrc)"]:::testing
    end

    %% Deployment & DevOps
    subgraph "Deployment & DevOps"
        Docker["Docker Configuration (Dockerfile, docker-compose)"]:::deployment
        CICD["CI/CD (.github/workflows)"]:::deployment
    end

    %% Connections within Client-Side
    EntryHTML --> AppVue
    MainJS --> AppVue
    AppVue --> UIComp
    AppVue --> UIReusable

    %% Connections between UI and Business Logic
    UIComp -->|"calls"| Lib
    UIComp -->|"calls"| Utils
    UIReusable -->|"calls"| Lib
    UIReusable -->|"calls"| Utils

    %% Connections from Utilities to Assets & Internationalization
    Utils -->|"integrates"| Locales
    Utils -->|"uses"| Assets

    %% Testing relationships
    UIComp -->|"testedBy"| E2E
    UIReusable -->|"testedBy"| E2E
    Quality ---|"enforces"| UIComp
    Quality ---|"enforces"| UIReusable

    %% Deployment relationships
    AppVue ---|"builds"| Docker
    UIComp ---|"builds"| Docker
    UIReusable ---|"builds"| Docker
    Docker -->|"triggeredBy"| CICD
    Quality -->|"runsIn"| CICD

    %% Click Events
    click EntryHTML "https://github.com/lyqht/mini-qr/blob/main/index.html"
    click MainJS "https://github.com/lyqht/mini-qr/blob/main/src/main.js"
    click AppVue "https://github.com/lyqht/mini-qr/blob/main/src/App.vue"
    click UIComp "https://github.com/lyqht/mini-qr/tree/main/src/components"
    click UIReusable "https://github.com/lyqht/mini-qr/tree/main/src/components/ui"
    click Lib "https://github.com/lyqht/mini-qr/tree/main/src/lib"
    click Utils "https://github.com/lyqht/mini-qr/tree/main/src/utils"
    click Assets "https://github.com/lyqht/mini-qr/tree/main/src/assets/presets"
    click Locales "https://github.com/lyqht/mini-qr/tree/main/locales"
    click E2E "https://github.com/lyqht/mini-qr/tree/main/tests/e2e"
    click Docker "https://github.com/lyqht/mini-qr/tree/main/Dockerfile"
    click Docker "https://github.com/lyqht/mini-qr/blob/main/docker-compose.yml"
    click CICD "https://github.com/lyqht/mini-qr/tree/main/.github/workflows"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef business fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef assets fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef testing fill:#ffcdd2,stroke:#c62828,stroke-width:2px;
    classDef deployment fill:#d1c4e9,stroke:#6a1b9a,stroke-width:2px;
```
