# w-nabe/animahtmlfixer architecture

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

- Interactive diagram: https://gitdiagram.com/w-nabe/animahtmlfixer
- Repository: https://github.com/w-nabe/animahtmlfixer

## Overview

##### Project Overview
- Purpose: The AnimaHTMLFixer is an open-source PHP tool designed to process HTML files exported by Anima (using Figma or Adobe XD designs) and adjust them according to specific naming conventions and configurations. It leverages the PHP “Didom” library to modify HTML markup, applying SEO tags, link changes, animation classes, and more.
- Project Type: It is a web-based PHP library/tool that simplifies turning design exports (HTML/CSS) into production-quality web pages.
- Requirements: A PHP-capable server is needed along with prearranged naming conventions in the exported design files.

##### Analyzing the File Structure – Main Components
- Core PHP Files (in the root): Files like _check-ua.inc, _didom_functions.inc, _operate_views.inc, and _wp_variables.inc represent key backend logic helping in processing HTML content.
- The “anima” Directory:
- Contains subdirectories such as config, css, images, include, js, and view.
- “anima/config”: Holds configuration CSVs and text snippets (for header/footer inserts) that control how HTML gets modified (site name, breakpoints, meta tags, SEO, links).
- “anima/css” & “anima/js”: Contain the styling and JavaScript files that can be modified (including responsive styles for page, dividers for different breakpoints, and custom scripts).
- “anima/include”: Contains PHP include files that perform additional tasks (like including components for embedded Google Forms, Maps, Instagram, YouTube).
- “anima/view”: This folder provides the HTML templates and CSS preview files that serve as the output structure post-transformation.
- The “vendor” Directory: This hints at managed dependencies (possibly including the Didom PHP library).
- Other Assets: Files like .htaccess and index.php handle web server configuration and the entry point for the PHP application.

##### Components and Relationships
a. Web Server Environment:
- PHP runtime environment that executes the core PHP files.
- .htaccess file as the entry/redirect mechanism.
b. Input (Design Export):
- Externally exported HTML/CSS files from Anima (coming via Figma or Adobe XD plugins) which are copied into the anima/view directory.
c. Processing Layer:
- PHP Scripts (including _didom_functions.inc and related inc files) that process the HTML content. This layer uses the Didom library for modifying elements based on class names and naming conventions.
- Configuration Files: Show the “anima/config” CSVs and text snippet files that feed parameters to the processing logic.
d. Output/Presentation Layer:
- Processed HTML files (located in anima/view) including specific styling (anima/css) and behavior (anima/js) along with images.
- The “include” files (like googleform.inc, googlemap.inc, etc.) that inject external or interactive elements.
e. External Systems:
- Anima (and indirectly Figma/XD): Represent the design tools that generate the export files.
- Optional external integrations such as Google Maps, YouTube, Instagram that are embedded via naming rules and include files.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly separates configuration (CSV files, text snippets), content (HTML templates under anima/view), style (CSS in anima/css), and functionality (PHP processing components).
- Naming Conventions Driven: The entire architecture relies on consistent naming (for layers, links, animations, etc.) to automate HTML transformations.
- Modular Design: Components are split into different directories (core processing, configuration, front-end assets), which can be individually updated or extended.
- Configuration over Code: Many site settings (SEO, links, breakpoints) are centralized in config CSV files, ensuring that changes do not require in-depth code modifications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Design Export
    A["Design Export (Anima/Figma/XD)"]:::external

    %% Web Server Environment Subgraph
    subgraph "Web Server Environment"
        WS1[".htaccess"]:::server
        WS2["index.php"]:::server
    end

    %% PHP Processing Engine Subgraph (Core PHP Files)
    subgraph "PHP Processing Engine"
        CP1["_check-ua.inc"]:::php
        CP2["_didom_functions.inc"]:::php
        CP3["_operate_views.inc"]:::php
        CP4["_wp_variables.inc"]:::php
    end

    %% Configuration Files Node
    CONFIG["Configuration Files (anima/config)"]:::config

    %% External Dependencies Node
    VENDOR["Vendor Dependencies (vendor)"]:::external

    %% Frontend Assets Subgraph
    subgraph "Frontend Assets"
        FE1["CSS Assets (anima/css)"]:::frontend
        FE2["JS Assets (anima/js)"]:::frontend
        FE3["View Templates (anima/view)"]:::frontend
    end

    %% Additional Interactive/External Components Node
    INTERACT["Interactive Components (anima/include)"]:::interactive

    %% Connections
    A -->|"inputs"| WS2
    A -->|"inputs"| WS1

    WS2 -->|"forwards request"| CP1
    WS1 -->|"applies redirects"| CP1

    CONFIG -->|"provides settings"| CP1
    VENDOR -->|"supports processing"| CP1

    CP1 -->|"invokes"| CP2
    CP2 -->|"continues"| CP3
    CP3 -->|"finalizes"| CP4

    CP4 -->|"renders output"| FE3
    CP4 -->|"applies styles"| FE1
    CP4 -->|"attaches scripts"| FE2

    CONFIG -->|"feeds configuration"| FE3

    INTERACT -->|"embedded in"| FE3

    %% Click Events
    click WS1 "https://github.com/w-nabe/animahtmlfixer/blob/main/.htaccess"
    click WS2 "https://github.com/w-nabe/animahtmlfixer/blob/main/index.php"
    click CP1 "https://github.com/w-nabe/animahtmlfixer/blob/main/_check-ua.inc"
    click CP2 "https://github.com/w-nabe/animahtmlfixer/blob/main/_didom_functions.inc"
    click CP3 "https://github.com/w-nabe/animahtmlfixer/blob/main/_operate_views.inc"
    click CP4 "https://github.com/w-nabe/animahtmlfixer/blob/main/_wp_variables.inc"
    click CONFIG "https://github.com/w-nabe/animahtmlfixer/tree/main/anima/config"
    click FE1 "https://github.com/w-nabe/animahtmlfixer/tree/main/anima/css"
    click FE2 "https://github.com/w-nabe/animahtmlfixer/tree/main/anima/js"
    click FE3 "https://github.com/w-nabe/animahtmlfixer/tree/main/anima/view"
    click INTERACT "https://github.com/w-nabe/animahtmlfixer/tree/main/anima/include"
    click VENDOR "https://github.com/w-nabe/animahtmlfixer/tree/main/vendor"

    %% Styles
    classDef external fill:#f9e79f,stroke:#000,stroke-width:1px;
    classDef server fill:#aed6f1,stroke:#000,stroke-width:1px;
    classDef php fill:#abebc6,stroke:#000,stroke-width:1px;
    classDef config fill:#f5cba7,stroke:#000,stroke-width:1px;
    classDef frontend fill:#fcf3cf,stroke:#000,stroke-width:1px;
    classDef interactive fill:#d2b4de,stroke:#000,stroke-width:1px;
```
