# genaker/fastfpc architecture

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

- Interactive diagram: https://gitdiagram.com/genaker/fastfpc
- Repository: https://github.com/genaker/fastfpc

## Overview

##### Main Components

a) Entry Points Layer:
- Two possible entry points:
- Nginx (with auto_prepend_file configuration)
- Direct PHP inclusion (bootstrap.php/index.php)

b) FPC Extension Core:
- Composer integration component
- Plugin system (CacheIdentifierPlugin)

c) Storage Layer:
- Redis cache storage
- Connection handling through php_redis extension

d) Optional Integration:
- CloudFlare CDN Worker (as an optional external cache layer)

##### Component Relationships

- HTTP Request → Entry Points → FPC.php
- FPC.php ↔ Redis Cache
- FPC.php → CacheIdentifierPlugin (for cache key generation)
- Optional: System → CloudFlare Worker → End User

##### Architectural Patterns to Highlight

- Early Bootstrap Pattern: Show how the system intercepts requests before Magento's full bootstrap
- Plugin System: Demonstrate the extension point for cache identification
- Cache Layer Architecture: Multiple cache layers (Redis + optional CloudFlare)

##### Important Details

- Performance metrics (0.000481128 second FPC generation time)
- Required dependencies (php_redis extension)
- Magento version compatibility (2.4.7)
- Configuration points (Nginx configuration, deployment options)

##### Technical Stack Indicators

- PHP
- Redis
- Nginx
- Magento 2
- CloudFlare Workers (optional)

This design should clearly communicate how the extension achieves its sub-millisecond performance while maintaining compatibility with Magento 2's architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Entry_Points
        NGINX[Nginx\n/etc/nginx/nginx.conf]:::entrypoint
        PHP[Direct PHP Inclusion\nbootstrap.php]:::entrypoint
        FPC_ENTRY["/fpc.php"]:::core
    end

    subgraph FPC_Core
        FPC_MAIN["FPC Core Processing\nMage/FPC/FPC.php"]:::core
        COMPOSER["Composer Integration\nMage/FPC/Composer.php"]:::core
        PLUGIN["Cache Identifier Plugin\nMage/FPC/Plugin/CacheIdentifierPlugin.php"]:::core
        CONFIG["Module Configuration\nMage/FPC/etc/module.xml"]:::config
        DI["Dependency Injection\nMage/FPC/etc/di.xml"]:::config
        DEPLOY["Deployment Handler\nMage/FPC/Console/Deploy.php"]:::core
        REG["Module Registration\nMage/FPC/registration.php"]:::core
    end

    subgraph Storage
        REDIS[(Redis Cache)]:::storage
    end

    subgraph External
        CF[CloudFlare CDN Worker]:::external
    end

    %% Connections
    NGINX --> FPC_ENTRY
    PHP --> FPC_ENTRY
    FPC_ENTRY --> FPC_MAIN
    FPC_MAIN <--> REDIS
    FPC_MAIN --> PLUGIN
    FPC_MAIN --> CF
    COMPOSER --> FPC_MAIN
    CONFIG --> FPC_MAIN
    DI --> FPC_MAIN
    DEPLOY --> FPC_MAIN
    REG --> FPC_MAIN

    %% Click Events
    click FPC_ENTRY "https://github.com/Genaker/FastFPC/blob/main/fpc.php"
    click FPC_MAIN "https://github.com/Genaker/FastFPC/blob/main/Mage/FPC/FPC.php"
    click COMPOSER "https://github.com/Genaker/FastFPC/blob/main/Mage/FPC/Composer.php"
    click PLUGIN "https://github.com/Genaker/FastFPC/blob/main/Mage/FPC/Plugin/CacheIdentifierPlugin.php"
    click CONFIG "https://github.com/Genaker/FastFPC/blob/main/Mage/FPC/etc/module.xml"
    click DI "https://github.com/Genaker/FastFPC/blob/main/Mage/FPC/etc/di.xml"
    click DEPLOY "https://github.com/Genaker/FastFPC/blob/main/Mage/FPC/Console/Deploy.php"
    click REG "https://github.com/Genaker/FastFPC/blob/main/Mage/FPC/registration.php"

    %% Styles
    classDef core fill:#2374ab,stroke:#000,color:#fff
    classDef entrypoint fill:#57a773,stroke:#000,color:#fff
    classDef storage fill:#ef476f,stroke:#000,color:#fff
    classDef external fill:#7209b7,stroke:#000,color:#fff
    classDef config fill:#8a8a8a,stroke:#000,color:#fff

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Entry Points]:::entrypoint
        L3[(Storage)]:::storage
        L4[External Services]:::external
        L5[Configuration]:::config
    end

    %% Notes
    note["Performance: 0.000481128s FPC generation
    Requires: php_redis extension
    Magento Compatibility: 2.4.7"]
```
