# eoussama/fut-card-generator architecture

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

- Interactive diagram: https://gitdiagram.com/eoussama/fut-card-generator
- Repository: https://github.com/eoussama/fut-card-generator

## Overview

- Command Line Interface (CLI) – Implemented in src/cli and include/cli. This module handles user parameters and calls the underlying C++ generation engine.
- Python API – Found in api/app.py and its related helper modules and routes. This serves as an HTTP layer to wrap the CLI functionality and expose endpoints (GET /, POST /generate) to generate cards.
- Assets and Templates – Represented by the assets/ directory (including card images, fonts, logos) and the include/template directories. These are used by both the CLI and API to generate the visual card output.
- Docker & Deployment – Dockerfiles (docker/Dockerfile, Dockerfile.api, Dockerfile.dev) along with scripts in scripts/ provide containerized deployment and development environments.
- External Dependencies – The external/ directory indicates imported libraries or adaptations (like argparse, json) which are integrated into the project.

##### Relationships and data flow
- The API, implemented in Python, acts as an adapter: it receives HTTP requests (with arguments and file uploads) → translates them into command-line-like parameters → invokes the underlying C++ executable/library.
- The core library communicates with asset management, template handling, and drawing modules. Most functional modules in the src/ and include/ directories interact to produce the final Fut card.
- Error handling by showing a connection from the core functions to various exception components (found in include/exceptions and src/exceptions) to handle failures such as image download or loading issues.
- Data/information flow regarding configuration and internationalization that uses language dictionaries (see include/core/i18n and assets/i18n).

##### Architectural patterns/design principles
- Separation of Concerns – Different modules (CLI, API, core library) are separated clearly.
- Modularity – Several modules (card, template, player, and exception handling) are distinctly organized in both the include/ and src/ directories.
- Reusability – The library can be reused in multiple interfaces (command line and web).

##### Technology specifics
- C++ and CMake for building the core binary.
- Python with Flask for the API.
- Docker for containerization.
- External libraries included from the external/ directory, possibly for argument processing and JSON utilities.
- Assets like images and fonts are stored under assets/ for use by both the API and CLI modules.

##### Detail the inter-component interactions
- That both the CLI and API layers rely on the same underlying card generation engine.
- That Docker scripts (with deployment containers) encapsulate both the API server and the development/build processes.
- Annotations for important configuration files (e.g., CMakeLists.txt, Dockerfiles) that facilitate building and deployment.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Presentation Layer"
        CLI["CLI Interface"]:::cli
        API["API Layer (Flask)"]:::api
    end

    subgraph "C++ Core Library"
        CORE["Card Generation Engine"]:::core
        INTL["Internationalization Module"]:::core
        ERR["Error Handling Module"]:::core
        ATM["Asset & Template Manager"]:::core
    end

    subgraph "Assets & Templates"
        ASSETS["Assets"]:::asset
        TEMPLATE["Template Processor"]:::asset
    end

    DOCKER["Docker & Deployment"]:::docker
    EXTERNAL["External Dependencies"]:::external

    CLI -->|"calls"| CORE
    API -->|"calls"| CORE
    CORE -->|"uses"| ATM
    CORE -->|"handlesTrans"| INTL
    CORE -->|"alerts"| ERR
    ATM -->|"fetches"| ASSETS
    ATM -->|"processes"| TEMPLATE

    DOCKER -->|"containerizes"| API
    DOCKER -->|"containerizes"| CLI
    EXTERNAL -->|"integratedWith"| CORE

    %% Click Events
    click CORE "https://github.com/eoussama/fut-card-generator/tree/main/include/core"
    click CORE "https://github.com/eoussama/fut-card-generator/tree/main/src/core"
    click INTL "https://github.com/eoussama/fut-card-generator/tree/main/include/core/i18n"
    click INTL "https://github.com/eoussama/fut-card-generator/tree/main/src/core/i18n"
    click ERR "https://github.com/eoussama/fut-card-generator/tree/main/include/exceptions"
    click ERR "https://github.com/eoussama/fut-card-generator/tree/main/src/exceptions"
    click CLI "https://github.com/eoussama/fut-card-generator/tree/main/include/cli"
    click CLI "https://github.com/eoussama/fut-card-generator/tree/main/src/cli"
    click API "https://github.com/eoussama/fut-card-generator/blob/main/api/app.py"
    click API "https://github.com/eoussama/fut-card-generator/tree/main/api/helpers"
    click API "https://github.com/eoussama/fut-card-generator/tree/main/api/routes"
    click ASSETS "https://github.com/eoussama/fut-card-generator/tree/main/assets/"
    click TEMPLATE "https://github.com/eoussama/fut-card-generator/tree/main/include/template"
    click TEMPLATE "https://github.com/eoussama/fut-card-generator/tree/main/src/template"
    click DOCKER "https://github.com/eoussama/fut-card-generator/tree/main/docker/"
    click DOCKER "https://github.com/eoussama/fut-card-generator/tree/main/scripts/"
    click EXTERNAL "https://github.com/eoussama/fut-card-generator/tree/main/external/"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef cli fill:#ABEBC6,stroke:#239B56,stroke-width:2px;
    classDef api fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef asset fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
    classDef docker fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
```
