# nyaro30/printf architecture

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

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

## Overview

ft_printf is a small C library that scans a format string, consumes variadic arguments, dispatches conversions, writes output, and returns the character count. It has separate mandatory and bonus implementations (both export `ft_printf`), with bonus parsing for flags, width, and precision. The graph preserves the documented conversion and formatting stages; links among unsampled helpers are omitted where their call sites are not evidenced.

Main entry points: [`ft_printf.c`](https://github.com/nyaro30/printf/blob/main/ft_printf.c) (Mandatory printf), [`ft_print_bonus_part3.c`](https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part3.c) (Conversion dispatch), [`ft_putchar.c`](https://github.com/nyaro30/printf/blob/main/ft_putchar.c) (Character output), [`ft_printf_bonus.c`](https://github.com/nyaro30/printf/blob/main/ft_printf_bonus.c) (Bonus printf)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Printf entry points"]
  node_mandatory["Mandatory printf<br/>[ft_printf.c]"]
  node_bonus_entry["Bonus printf<br/>[ft_printf_bonus.c]"]
end

subgraph group_formatting["Format parsing"]
  node_bonus_parser["Flag parser<br/>[ft_parse_bonus.c]"]
end

subgraph group_conversions["Conversion handlers"]
  node_bonus_dispatch["Conversion dispatch"]
  node_char_string["Char and string"]
  node_numeric["Numeric formatting"]
  node_pointer["Pointer formatting"]
end

subgraph group_output["Output primitives"]
  node_bonus_helpers["Bonus helpers<br/>[ft_utils_bonus.c]"]
  node_bonus_helpers2["Bonus helpers<br/>[ft_utils_bonus2.c]"]
  node_putchar["Character output<br/>[ft_putchar.c]"]
  node_putstr["String output<br/>[ft_putstr.c]"]
  node_signed["Signed decimal<br/>[ft_putnbr.c]"]
  node_unsigned["Unsigned decimal"]
  node_hex["Hexadecimal<br/>[ft_putnbr_hex.c]"]
  node_pointer_out["Pointer output<br/>[ft_putptr.c]"]
end

node_caller(("Calling program"))

node_caller -->|"calls"| node_mandatory
node_caller -.->|"calls"| node_bonus_entry
node_mandatory -->|"writes via"| node_putchar
node_mandatory -->|"dispatches to"| node_putstr
node_mandatory -->|"dispatches to"| node_signed
node_mandatory -->|"dispatches to"| node_unsigned
node_mandatory -->|"dispatches to"| node_hex
node_mandatory -->|"dispatches to"| node_pointer_out
node_bonus_entry -->|"parses with"| node_bonus_parser
node_bonus_entry -->|"dispatches to"| node_bonus_dispatch
node_bonus_dispatch -->|"dispatches to"| node_char_string
node_bonus_dispatch -->|"dispatches to"| node_numeric
node_bonus_dispatch -->|"dispatches to"| node_pointer
node_char_string -->|"writes via"| node_putchar
node_numeric -->|"uses helpers"| node_bonus_helpers
node_numeric -->|"writes via"| node_putchar
node_pointer -->|"uses helpers"| node_bonus_helpers
node_pointer -->|"writes via"| node_putchar

click node_mandatory "https://github.com/nyaro30/printf/blob/main/ft_printf.c"
click node_bonus_entry "https://github.com/nyaro30/printf/blob/main/ft_printf_bonus.c"
click node_bonus_parser "https://github.com/nyaro30/printf/blob/main/ft_parse_bonus.c"
click node_bonus_dispatch "https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part3.c"
click node_char_string "https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part1.c"
click node_numeric "https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part2.c"
click node_pointer "https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part3.c"
click node_bonus_helpers "https://github.com/nyaro30/printf/blob/main/ft_utils_bonus.c"
click node_bonus_helpers2 "https://github.com/nyaro30/printf/blob/main/ft_utils_bonus2.c"
click node_putchar "https://github.com/nyaro30/printf/blob/main/ft_putchar.c"
click node_putstr "https://github.com/nyaro30/printf/blob/main/ft_putstr.c"
click node_signed "https://github.com/nyaro30/printf/blob/main/ft_putnbr.c"
click node_unsigned "https://github.com/nyaro30/printf/blob/main/ft_putnbr_unsigned.c"
click node_hex "https://github.com/nyaro30/printf/blob/main/ft_putnbr_hex.c"
click node_pointer_out "https://github.com/nyaro30/printf/blob/main/ft_putptr.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mandatory,node_bonus_entry toneBlue
class node_bonus_parser toneAmber
class node_bonus_dispatch,node_char_string,node_numeric,node_pointer toneMint
class node_bonus_helpers,node_bonus_helpers2,node_putchar,node_putstr,node_signed,node_unsigned,node_hex,node_pointer_out toneRose
class node_caller toneIndigo
```

## Components

### Printf entry points

- [Mandatory printf](https://github.com/nyaro30/printf/blob/main/ft_printf.c): `ft_printf.c`
- [Bonus printf](https://github.com/nyaro30/printf/blob/main/ft_printf_bonus.c): `ft_printf_bonus.c`

### Format parsing

- [Flag parser](https://github.com/nyaro30/printf/blob/main/ft_parse_bonus.c): `ft_parse_bonus.c`

### Conversion handlers

- [Conversion dispatch](https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part3.c): `ft_print_bonus_part3.c`
- [Char and string](https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part1.c): `ft_print_bonus_part1.c`
- [Numeric formatting](https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part2.c): `ft_print_bonus_part2.c`
- [Pointer formatting](https://github.com/nyaro30/printf/blob/main/ft_print_bonus_part3.c): `ft_print_bonus_part3.c`

### Output primitives

- [Bonus helpers](https://github.com/nyaro30/printf/blob/main/ft_utils_bonus.c): `ft_utils_bonus.c`
- [Bonus helpers](https://github.com/nyaro30/printf/blob/main/ft_utils_bonus2.c): `ft_utils_bonus2.c`
- [Character output](https://github.com/nyaro30/printf/blob/main/ft_putchar.c): `ft_putchar.c`
- [String output](https://github.com/nyaro30/printf/blob/main/ft_putstr.c): `ft_putstr.c`
- [Signed decimal](https://github.com/nyaro30/printf/blob/main/ft_putnbr.c): `ft_putnbr.c`
- [Unsigned decimal](https://github.com/nyaro30/printf/blob/main/ft_putnbr_unsigned.c): `ft_putnbr_unsigned.c`
- [Hexadecimal](https://github.com/nyaro30/printf/blob/main/ft_putnbr_hex.c): `ft_putnbr_hex.c`
- [Pointer output](https://github.com/nyaro30/printf/blob/main/ft_putptr.c): `ft_putptr.c`

### Other components

- **Calling program**

## Connections

- Calling program → Mandatory printf: calls (evidence: `README.md`)
- Calling program → Bonus printf: calls (evidence: `README.md`)
- Mandatory printf → Character output: writes via (evidence: `ft_printf.c`)
- Mandatory printf → String output: dispatches to (evidence: `ft_printf.c`)
- Mandatory printf → Signed decimal: dispatches to (evidence: `ft_printf.c`)
- Mandatory printf → Unsigned decimal: dispatches to (evidence: `ft_printf.c`)
- Mandatory printf → Hexadecimal: dispatches to (evidence: `ft_printf.c`)
- Mandatory printf → Pointer output: dispatches to (evidence: `ft_printf.c`)
- Bonus printf → Flag parser: parses with (evidence: `ft_printf_bonus.c`)
- Bonus printf → Conversion dispatch: dispatches to (evidence: `ft_printf_bonus.c`)
- Conversion dispatch → Char and string: dispatches to (evidence: `ft_print_bonus_part3.c`)
- Conversion dispatch → Numeric formatting: dispatches to (evidence: `ft_print_bonus_part3.c`)
- Conversion dispatch → Pointer formatting: dispatches to (evidence: `ft_print_bonus_part3.c`)
- Char and string → Character output: writes via (evidence: `ft_print_bonus_part1.c`)
- Numeric formatting → Bonus helpers: uses helpers (evidence: `ft_print_bonus_part2.c`)
- Numeric formatting → Character output: writes via (evidence: `ft_print_bonus_part2.c`)
- Pointer formatting → Bonus helpers: uses helpers (evidence: `ft_print_bonus_part3.c`)
- Pointer formatting → Character output: writes via (evidence: `ft_print_bonus_part3.c`)
