# oussmac/printf architecture

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

- Interactive diagram: https://gitdiagram.com/oussmac/printf
- Repository: https://github.com/oussmac/printf

## Overview

##### Main Components
- Core Function (ft_printf): This file (ft_printf.c) is the heart of the project. It handles the format string input, initializes the variadic arguments via va_list, and determines how to process each format specifier.
- Helper Functions: Several utility files (ft_putstr_fd.c, ft_putchar_fd.c, ft_putnbr_fd.c, ft_putuns_fd.c, ft_printhex_fd.c) supply specialized functionality. Each one represents a component responsible for printing strings, characters, numbers, unsigned numbers, or hexadecimal values, respectively.
- Header File (ft_printf.h): Contains function prototypes and common definitions that bind the overall components together.
- Build/Configuration: The Makefile is used for compiling the program.
- Attachments/Supporting Material: The attachment folder contains images that further explain the variadic argument mechanism and parts of the implementation.

##### Relationships and Data Flow
- From the Variadic Arguments node, indicate a decision point or branching mechanism based on the current format specifier read from the format string.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The ft_printf function separates the formatting logic from the actual output functions. Each helper function is dedicated to handling a specific type of conversion.
- Modularization: The design is modular, with one main entry point delegating tasks to different functional components, which makes it easier to extend (e.g., adding more format specifiers).

##### Detail
- To capture all components even if small. In this case, not only include ft_printf.c and the helper files but also the configuration file (Makefile) and supporting images (from attachment) that describe the variadic function mechanism.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["ft_printf (Main Function)<br>(Format String & Arguments)"]:::core
    B["Format Parsing & Variadic Handler<br>(stdarg.h: va_start,va_arg,etc.)"]:::core

    C["ft_putchar_fd"]:::helper
    D["ft_putstr_fd"]:::helper
    E["ft_putnbr_fd"]:::helper
    F["ft_putuns_fd"]:::helper
    G["ft_printhex_fd"]:::helper

    H(("Output (FD)")):::output

    I["Makefile"]:::build
    J["ft_printf.h"]:::build
    K["Attachments (Directory)"]:::build
    L["README"]:::build

    A --> B
    B -->|"%c"| C
    B -->|"%s"| D
    B -->|"%d"| E
    B -->|"%u"| F
    B -->|"%x"| G
    C --> H
    D --> H
    E --> H
    F --> H
    G --> H

    %% Supporting and build configuration connections
    A --- J
    A --- I
    I --- K
    K --- L

    %% Click Events
    click A "https://github.com/oussmac/printf/blob/master/ft_printf.c"
    click B "https://github.com/oussmac/printf/blob/master/ft_printf.c"
    click C "https://github.com/oussmac/printf/blob/master/ft_putchar_fd.c"
    click D "https://github.com/oussmac/printf/blob/master/ft_putstr_fd.c"
    click E "https://github.com/oussmac/printf/blob/master/ft_putnbr_fd.c"
    click F "https://github.com/oussmac/printf/blob/master/ft_putuns_fd.c"
    click G "https://github.com/oussmac/printf/blob/master/ft_printhex_fd.c"
    click J "https://github.com/oussmac/printf/blob/master/ft_printf.h"
    click I "https://github.com/oussmac/printf/tree/master/Makefile"
    click K "https://github.com/oussmac/printf/tree/master/attachment"
    
    %% Styles
    classDef core fill:#d0e1f9,stroke:#2e6da4,stroke-width:2px;
    classDef helper fill:#dff0d8,stroke:#3c763d,stroke-width:2px;
    classDef output fill:#fcf8e3,stroke:#8a6d3b,stroke-width:2px,stroke-dasharray: 5 5;
    classDef build fill:#f2dede,stroke:#a94442,stroke-width:2px;
    
    %% Layout adjustments for vertical orientation
    linkStyle default stroke:#555,stroke-width:1.5px;
    
    %% End of Diagram
```
