# cafeuroff/libft architecture

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

- Interactive diagram: https://gitdiagram.com/cafeuroff/libft
- Repository: https://github.com/cafeuroff/libft

## Overview

##### Main Components
- Library Core: The entire collection of functions forms the core of the library.
- Memory Management Functions: Functions such as ft_memset, ft_memcpy, ft_memmove, and ft_calloc.
- String Manipulation Functions: Functions handling string length, duplication, joining, trimming, etc. (e.g., ft_strlen, ft_strdup, ft_strjoin, ft_strtrim, ft_split, etc.)
- Character and Conversion Functions: Functions for character classification and conversion (ft_isalnum, ft_toupper, ft_tolower, ft_itoa).
- Linked List Functions: Functions that operate on singly linked lists (ft_lstnew, ft_lstadd_front, ft_lstadd_back, ft_lstclear, etc.)
- I/O Functions: Functions to output strings and numbers (ft_putchar_fd, ft_putstr_fd, ft_putnbr_fd, ft_putendl_fd).

##### Relationships & Interactions
- The header file (libft.h) acts as the interface linking all the functional modules, so it should be included centrally.

##### Architectural Patterns / Design Principles
- Modular Design: Each file/function serves a single, specific purpose (Single Responsibility Principle).
- Reusability: The library is meant to be included and reused in other C projects.
- Cohesion: Grouping functions by category (strings, memory, lists, etc.) underlines high cohesion within modules.

##### Relevant Technologies & Tools
- Programming Language: C
- Build Tool: Make (Makefile)
- Compilation Artefact: Typically, a static library (commonly a .a file) generated from the compiled object files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("Makefile (Build Process)"):::build
    B("Libft Library (Static Library)"):::library
    C("libft.h (Header Interface)"):::header

    %% Top-level connections
    A --> B
    C --> B

    %% Module Headings
    MMod("Memory Functions Module"):::module
    StrMod("String Functions Module"):::module
    CharMod("Character & Conversion Functions Module"):::module
    LListMod("Linked List Functions Module"):::module
    IOMod("I/O Functions Module"):::module

    B --> MMod
    B --> StrMod
    B --> CharMod
    B --> LListMod
    B --> IOMod

    %% Memory Functions Files
    M1("ft_bzero.c"):::file
    M2("ft_calloc.c"):::file
    M3("ft_memset.c"):::file
    M4("ft_memcpy.c"):::file
    M5("ft_memmove.c"):::file
    M6("ft_memchr.c"):::file
    M7("ft_memcmp.c"):::file

    MMod --> M1
    M1 --> M2
    M2 --> M3
    M3 --> M4
    M4 --> M5
    M5 --> M6
    M6 --> M7

    %% String Functions Files
    S1("ft_strlen.c"):::file
    S2("ft_strdup.c"):::file
    S3("ft_strjoin.c"):::file
    S4("ft_strtrim.c"):::file
    S5("ft_split.c"):::file
    S6("ft_strchr.c"):::file
    S7("ft_striteri.c"):::file
    S8("ft_strlcat.c"):::file
    S9("ft_strlcpy.c"):::file
    S10("ft_strmapi.c"):::file
    S11("ft_strncmp.c"):::file
    S12("ft_strnstr.c"):::file
    S13("ft_strrchr.c"):::file
    S14("ft_substr.c"):::file

    StrMod --> S1
    S1 --> S2
    S2 --> S3
    S3 --> S4
    S4 --> S5
    S5 --> S6
    S6 --> S7
    S7 --> S8
    S8 --> S9
    S9 --> S10
    S10 --> S11
    S11 --> S12
    S12 --> S13
    S13 --> S14

    %% Character & Conversion Functions Files
    CC1("ft_atoi.c"):::file
    CC2("ft_itoa.c"):::file
    CC3("ft_tolower.c"):::file
    CC4("ft_toupper.c"):::file
    CC5("ft_isalnum.c"):::file
    CC6("ft_isalpha.c"):::file
    CC7("ft_isascii.c"):::file
    CC8("ft_isdigit.c"):::file
    CC9("ft_islower.c"):::file
    CC10("ft_isprint.c"):::file

    CharMod --> CC1
    CC1 --> CC2
    CC2 --> CC3
    CC3 --> CC4
    CC4 --> CC5
    CC5 --> CC6
    CC6 --> CC7
    CC7 --> CC8
    CC8 --> CC9
    CC9 --> CC10

    %% Linked List Functions Files
    L1("ft_lstnew.c"):::file
    L2("ft_lstadd_front.c"):::file
    L3("ft_lstadd_back.c"):::file
    L4("ft_lstclear.c"):::file
    L5("ft_lstdelone.c"):::file
    L6("ft_lstiter.c"):::file
    L7("ft_lstlast.c"):::file
    L8("ft_lstmap.c"):::file
    L9("ft_lstsize.c"):::file

    LListMod --> L1
    L1 --> L2
    L2 --> L3
    L3 --> L4
    L4 --> L5
    L5 --> L6
    L6 --> L7
    L7 --> L8
    L8 --> L9

    %% I/O Functions Files
    IO1("ft_putchar_fd.c"):::file
    IO2("ft_putstr_fd.c"):::file
    IO3("ft_putnbr_fd.c"):::file
    IO4("ft_putendl_fd.c"):::file

    IOMod --> IO1
    IO1 --> IO2
    IO2 --> IO3
    IO3 --> IO4

    %% Click Events
    click C "https://github.com/cafeuroff/libft/blob/main/libft.h"
    click A "https://github.com/cafeuroff/libft/tree/main/Makefile"

    click M1 "https://github.com/cafeuroff/libft/blob/main/ft_bzero.c"
    click M2 "https://github.com/cafeuroff/libft/blob/main/ft_calloc.c"
    click M3 "https://github.com/cafeuroff/libft/blob/main/ft_memset.c"
    click M4 "https://github.com/cafeuroff/libft/blob/main/ft_memcpy.c"
    click M5 "https://github.com/cafeuroff/libft/blob/main/ft_memmove.c"
    click M6 "https://github.com/cafeuroff/libft/blob/main/ft_memchr.c"
    click M7 "https://github.com/cafeuroff/libft/blob/main/ft_memcmp.c"

    click S1 "https://github.com/cafeuroff/libft/blob/main/ft_strlen.c"
    click S2 "https://github.com/cafeuroff/libft/blob/main/ft_strdup.c"
    click S3 "https://github.com/cafeuroff/libft/blob/main/ft_strjoin.c"
    click S4 "https://github.com/cafeuroff/libft/blob/main/ft_strtrim.c"
    click S5 "https://github.com/cafeuroff/libft/blob/main/ft_split.c"
    click S6 "https://github.com/cafeuroff/libft/blob/main/ft_strchr.c"
    click S7 "https://github.com/cafeuroff/libft/blob/main/ft_striteri.c"
    click S8 "https://github.com/cafeuroff/libft/blob/main/ft_strlcat.c"
    click S9 "https://github.com/cafeuroff/libft/blob/main/ft_strlcpy.c"
    click S10 "https://github.com/cafeuroff/libft/blob/main/ft_strmapi.c"
    click S11 "https://github.com/cafeuroff/libft/blob/main/ft_strncmp.c"
    click S12 "https://github.com/cafeuroff/libft/blob/main/ft_strnstr.c"
    click S13 "https://github.com/cafeuroff/libft/blob/main/ft_strrchr.c"
    click S14 "https://github.com/cafeuroff/libft/blob/main/ft_substr.c"

    click CC1 "https://github.com/cafeuroff/libft/blob/main/ft_atoi.c"
    click CC2 "https://github.com/cafeuroff/libft/blob/main/ft_itoa.c"
    click CC3 "https://github.com/cafeuroff/libft/blob/main/ft_tolower.c"
    click CC4 "https://github.com/cafeuroff/libft/blob/main/ft_toupper.c"
    click CC5 "https://github.com/cafeuroff/libft/blob/main/ft_isalnum.c"
    click CC6 "https://github.com/cafeuroff/libft/blob/main/ft_isalpha.c"
    click CC7 "https://github.com/cafeuroff/libft/blob/main/ft_isascii.c"
    click CC8 "https://github.com/cafeuroff/libft/blob/main/ft_isdigit.c"
    click CC9 "https://github.com/cafeuroff/libft/blob/main/ft_islower.c"
    click CC10 "https://github.com/cafeuroff/libft/blob/main/ft_isprint.c"

    click L1 "https://github.com/cafeuroff/libft/blob/main/ft_lstnew.c"
    click L2 "https://github.com/cafeuroff/libft/blob/main/ft_lstadd_front.c"
    click L3 "https://github.com/cafeuroff/libft/blob/main/ft_lstadd_back.c"
    click L4 "https://github.com/cafeuroff/libft/blob/main/ft_lstclear.c"
    click L5 "https://github.com/cafeuroff/libft/blob/main/ft_lstdelone.c"
    click L6 "https://github.com/cafeuroff/libft/blob/main/ft_lstiter.c"
    click L7 "https://github.com/cafeuroff/libft/blob/main/ft_lstlast.c"
    click L8 "https://github.com/cafeuroff/libft/blob/main/ft_lstmap.c"
    click L9 "https://github.com/cafeuroff/libft/blob/main/ft_lstsize.c"

    click IO1 "https://github.com/cafeuroff/libft/blob/main/ft_putchar_fd.c"
    click IO2 "https://github.com/cafeuroff/libft/blob/main/ft_putstr_fd.c"
    click IO3 "https://github.com/cafeuroff/libft/blob/main/ft_putnbr_fd.c"
    click IO4 "https://github.com/cafeuroff/libft/blob/main/ft_putendl_fd.c"

    %% Styles
    classDef build fill:#f9d5bb,stroke:#333,stroke-width:2px;
    classDef library fill:#c1e1c1,stroke:#333,stroke-width:2px;
    classDef header fill:#ffecb3,stroke:#333,stroke-width:2px;
    classDef module fill:#bbdefb,stroke:#333,stroke-width:2px;
    classDef file fill:#ffe0b2,stroke:#333,stroke-width:1px;

    class A build;
    class B library;
    class C header;
    class MMod,StrMod,CharMod,LListMod,IOMod module;
```
