# vinislima/42sp_common_core_ft_printf architecture

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

- Interactive diagram: https://gitdiagram.com/vinislima/42sp_common_core_ft_printf
- Repository: https://github.com/vinislima/42sp_common_core_ft_printf

## Overview

##### Main Components
- ft_printf Core Module: Represent the central module (ft_printf.c) that parses the format string and decides which auxiliary functions to call.
- Auxiliary/Helper Modules: Create separate components for each of the helper functions—ft_putchar, ft_putstr, ft_putnbr, ft_putunbr, ft_puthexa, and ft_putptr. Each of these modules is responsible for handling a different conversion or printing functionality.
- Build/Compilation Process: Include the Makefile as a component that compiles the source (.c) files into object (.o) files and archives them into the static library (libftprintf.a).

##### Relationships and Data Flow
- Interface Layer: The header file (ft_printf.h) should be shown as the common interface that connects the ft_printf core and all helper modules, emphasizing that all functions share the same declarations.

##### Architectural Principles and Patterns
- Modular Design: Clearly illustrate that each printing functionality is encapsulated within its own module/file (separation of concerns), making maintenance and testing easier.
- Build Automation: Reflect the role of the Makefile in automating the build process, showing how it compiles and aggregates the individual modules into a single static library.

- A boundary (or a separate section) to show the build process: “Makefile” leading to “Compilation” and then “libftprintf.a (Static Library)”.
- Optionally, include an external “Client” block that links with the static library to produce a runnable executable.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Core Module"
        core["ft_printf (Core)"]:::core
        header["ft_printf.h"]:::header
    end

    subgraph "Helper Modules"
        char["ft_putchar – Character Printer"]:::helper
        str["ft_putstr – String Printer"]:::helper
        nbr["ft_putnbr – Number Printer"]:::helper
        unbr["ft_putunbr – Unsigned Number Printer"]:::helper
        hexa["ft_puthexa – Hexadecimal Printer"]:::helper
        ptr["ft_putptr – Pointer Printer"]:::helper
    end

    subgraph "Output"
        output["Standard Output"]:::output
    end

    subgraph "Build Process"
        makefile["Makefile"]:::build
        compilation["Compilation (.o files)"]:::build
        staticLib["libftprintf.a (Static Library)"]:::build
    end

    client["Client Application"]:::client

    %% Connections between Core and Header
    header --- core

    %% Connections from Core to Helper Modules with format specifier labels
    core -->|"%%c"| char
    core -->|"%%s"| str
    core -->|"%%d"| nbr
    core -->|"%%u"| unbr
    core -->|"%%x/%%X"| hexa
    core -->|"%%p"| ptr

    %% All Helper Modules output to Standard Output
    char -->|"write"| output
    str -->|"write"| output
    nbr -->|"write"| output
    unbr -->|"write"| output
    hexa -->|"write"| output
    ptr -->|"write"| output

    %% Header association with Helper Modules
    header --- char
    header --- str
    header --- nbr
    header --- unbr
    header --- hexa
    header --- ptr

    %% Build process connections
    makefile --> compilation
    compilation --> staticLib
    staticLib --> client

    %% Click Events
    click core "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_printf.c"
    click header "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_printf.h"
    click char "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_putchar.c"
    click str "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_putstr.c"
    click nbr "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_putnbr.c"
    click unbr "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_putunbr.c"
    click hexa "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_puthexa.c"
    click ptr "https://github.com/vinislima/42sp_common_core_ft_printf/blob/main/ft_putptr.c"
    click makefile "https://github.com/vinislima/42sp_common_core_ft_printf/tree/main/Makefile"

    %% Styles
    classDef core fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef header fill:#fcf3cf,stroke:#b7950b,stroke-width:2px;
    classDef helper fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef build fill:#abebc6,stroke:#28b463,stroke-width:2px;
    classDef output fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef client fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
```
