# plumlee211/get_next_line architecture

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

- Interactive diagram: https://gitdiagram.com/plumlee211/get_next_line
- Repository: https://github.com/plumlee211/get_next_line

## Overview

##### Project type and purpose
- This is a small C-language library/exercise (“get_next_line”) whose goal is to read one line at a time from a file descriptor, manage dynamic memory (linked lists, buffers), and demonstrate leak detection/debugging. It also bundles a test harness (gnlTester) with Docker/Makefile to validate both mandatory and bonus implementations.

##### File structure
- Top-level:
- README.md – project overview
- get_next_line/ – library source, headers, utils, test harness
- get_next_line/:
- get_next_line.c, get_next_line.h – core function (mandatory)
- get_next_line_bonus.c, get_next_line_bonus.h – bonus version (multiple FDs)
- get_next_line_utils.c / get_next_line_utils_bonus.c – helper routines (string operations, list management)
- gnl_main.c – example driver that calls get_next_line on newline.txt
- empty.txt / newline.txt – sample data for manual testing
- gnlTester/ – automated tester
◦ Dockerfile & Makefile – containerized environment and build rules
◦ files/ – a suite of input cases (various newline/no-newline permutations)
◦ tests/ – C++ test entry points for mandatory and bonus

##### README for additional insights
- Emphasis on:
- Understanding linked lists vs. arrays
- Detecting and diagnosing memory leaks (AddressSanitizer)
- File system concepts: FD table, i-nodes, EOF
- Debug tools: lldb, -fsanitize=address

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef codeModule fill:#f9f,stroke:#333,stroke-width:1px
    classDef container fill:#bbf,stroke:#333,stroke-width:1px
    classDef infra fill:#eee,stroke:#333,stroke-width:1px
    classDef storage fill:#f39,stroke:#333,stroke-width:1px
    classDef dashed border-dashed

    subgraph "Host Environment"
        HostOS["Host OS"]:::infra
        subgraph "Docker Container"
            Container["Docker Container"]:::container
            Container --> Make
            Container --> DockF
            subgraph "Test Harness"
                Make["Makefile"]:::codeModule
                DockF["Dockerfile"]:::codeModule
                subgraph "Build & Run"
                    TestRunner["Test Runner"]:::codeModule
                end
                subgraph "Test Input Corpus"
                    TestFiles["Files Corpus"]:::storage
                end
                subgraph "Automated Tests"
                    MandTest["mandatory.cpp"]:::codeModule
                    BonusTest["bonus.cpp"]:::codeModule
                end
                subgraph "Test Utils"
                    CheckCPP["check.cpp"]:::codeModule
                    CheckH["check.hpp"]:::codeModule
                    ColorCPP["color.cpp"]:::codeModule
                    ColorH["color.hpp"]:::codeModule
                    GnlCPP["gnl.cpp"]:::codeModule
                    GnlH["gnl.hpp"]:::codeModule
                    LeaksCPP["leaks.cpp"]:::codeModule
                    LeaksH["leaks.hpp"]:::codeModule
                    SigCPP["sigsegv.cpp"]:::codeModule
                    SigH["sigsegv.hpp"]:::codeModule
                end
            end
        end
        HostOS --> Container
        ASan["AddressSanitizer"]:::dashed
        ASan -.-> Container
    end

    subgraph "Core Library"
        CoreMandC["get_next_line.c"]:::codeModule
        CoreMandH["get_next_line.h"]:::codeModule
        UtilsMand["get_next_line_utils.c"]:::codeModule
        BonusC["get_next_line_bonus.c"]:::codeModule
        BonusH["get_next_line_bonus.h"]:::codeModule
        UtilsBonus["get_next_line_utils_bonus.c"]:::codeModule
    end

    subgraph "Example Driver"
        Driver["gnl_main.c"]:::codeModule
        EmptyTxt["empty.txt"]:::storage
        NewlineTxt["newline.txt"]:::storage
    end

    %% Data flows
    EmptyTxt --> Driver
    NewlineTxt --> Driver
    Driver --> CoreMandC
    Driver --> BonusC

    TestFiles --> TestRunner
    MandTest --> TestRunner
    BonusTest --> TestRunner
    CheckCPP --> TestRunner
    ColorCPP --> TestRunner
    GnlCPP --> TestRunner
    LeaksCPP --> TestRunner
    SigCPP --> TestRunner
    TestRunner --> CoreMandC
    TestRunner --> BonusC

    %% Click events
    click CoreMandC "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/get_next_line.c"
    click CoreMandH "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/get_next_line.h"
    click UtilsMand "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/get_next_line_utils.c"
    click BonusC "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/get_next_line_bonus.c"
    click BonusH "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/get_next_line_bonus.h"
    click UtilsBonus "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/get_next_line_utils_bonus.c"
    click Driver "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnl_main.c"
    click EmptyTxt "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/empty.txt"
    click NewlineTxt "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/newline.txt"
    click TestRoot "https://github.com/plumlee211/get_next_line/tree/main/get_next_line/gnlTester/"
    click Make "https://github.com/plumlee211/get_next_line/tree/main/get_next_line/gnlTester/Makefile"
    click DockF "https://github.com/plumlee211/get_next_line/tree/main/get_next_line/gnlTester/Dockerfile"
    click TestFiles "https://github.com/plumlee211/get_next_line/tree/main/get_next_line/gnlTester/files/"
    click MandTest "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/tests/mandatory.cpp"
    click BonusTest "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/tests/bonus.cpp"
    click CheckCPP "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/check.cpp"
    click CheckH "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/check.hpp"
    click ColorCPP "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/color.cpp"
    click ColorH "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/color.hpp"
    click GnlCPP "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/gnl.cpp"
    click GnlH "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/gnl.hpp"
    click LeaksCPP "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/leaks.cpp"
    click LeaksH "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/leaks.hpp"
    click SigCPP "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/sigsegv.cpp"
    click SigH "https://github.com/plumlee211/get_next_line/blob/main/get_next_line/gnlTester/utils/sigsegv.hpp"
```
