# slijkhuis/2024-advent-of-code architecture

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

- Interactive diagram: https://gitdiagram.com/slijkhuis/2024-advent-of-code
- Repository: https://github.com/slijkhuis/2024-advent-of-code

## Overview

##### Project Type and Purpose
- The project is a challenge-based repository designed to solve daily puzzles for Advent of Code 2024.
- Each puzzle (or “day”) has its own directory (named “01”, “02”, …, “25”) that contains the solution implementation and test files.
- The README instructs on how to prepare the puzzle input (“task prep”), run tests (“task test1”, “task test2”), and execute puzzle solutions (“task run1”, “task run2”).

##### Analyzing the File Structure
- Top-level directories:
- Directories named “01” through “25” represent individual puzzle days.
- A “pkg” directory contains shared utility code (e.g., collection utilities, parsing utilities, grid and graph handling, tree structures) that is reused across the different puzzle solutions.
- A “prep” folder includes code that helps set up or initialize the puzzle environment.
- Important configuration files and scripts:
- “Taskfile.yml” is used to automate tasks (setup, testing, execution).
- “go.mod” and “go.sum” indicate the project’s dependency management using Go modules.

##### System Components
a. Main Components:
- Task Runner: Represented by the Taskfile and associated commands (prep, test1, test2, run1, run2). This component orchestrates the workflow.
- Puzzle Day Modules: Each folder (“01”, “02”, …, “25”) is an encapsulated module containing main.go and one or more test files (and sometimes subdirectories like “failedattempts”).
- Utility Package (“pkg/aoc”): This is a shared library of utility functions to streamline common operations (parsing, collections, grids, etc.).
- Setup/Preparation Module: The "prep" directory, which provides startup logic to generate new puzzle templates and download the puzzle input.
- Build/System Config: This includes configuration files like “.mise.toml” and “go.mod”, which manage the build environment and dependencies.

b. Relationships and Interactions:
- The Task Runner (via Taskfile commands) triggers actions such as environment setup (“task prep”) that creates a new puzzle directory with a “main.go” template.
- Each Puzzle Day Module depends upon the shared components from the Utility Package to solve problems (data structures, parsing logic, etc.).
- The testing workflow (using tasks “test1” and “test2”) involves reading test data from manually populated test files located within each day’s folder, invoking functions (part1 and part2) defined in the main.go of respective directories.
- There is a dependency from the “prep” module and Taskfile to the file system, as the user is expected to copy test data from the puzzle text into the test files manually.

c. Architectural Patterns and Design Principles:
- Modular Design: Each day's solution is isolated into its own directory, promoting separation of concerns.
- Reusability: The “pkg” directory centralizes commonly used utility functions, reducing duplication.
- Task-Driven Workflow: The Taskfile acts as an orchestration layer, abstracting away direct command-line operations.
- Minimal yet effective structure, where each component has a clear role (puzzle solving, utility functions, and environment setup).

d. Relevant Technologies and Frameworks:
- Language: Go (indicated by main.go and go module files).
- Task Automation: Taskfile (specified in Taskfile.yml).
- Dependency Management: Go Modules (go.mod, go.sum).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Configuration Files
    subgraph "Configuration Files"
        GMOD["go.mod"]:::config
        GOSUM["go.sum"]:::config
        MISETOML[".mise.toml"]:::config
    end

    %% Core Components
    TR["Task Runner (Taskfile)"]:::automation
    SM["Setup/Preparation Module (prep)"]:::setup
    UP["Utility Package (pkg/aoc)"]:::utility

    %% Puzzle Day Modules
    subgraph "Puzzle Day Modules"
        direction TB
        D01["Day 01 (main.go, tests)"]:::day
        D02["Day 02 (main.go, tests)"]:::day
        D03["Day 03 (main.go, tests)"]:::day
        D04["Day 04 (main.go, tests)"]:::day
        D05["Day 05 (main.go, tests)"]:::day
        D06["Day 06 (main.go, tests)"]:::day
        D07["Day 07 (main.go, tests)"]:::day
        D08["Day 08 (main.go, tests)"]:::day
        D09["Day 09 (main.go, tests)"]:::day
        D10["Day 10 (main.go, tests)"]:::day
        D11["Day 11 (main.go, tests)"]:::day
        D12["Day 12 (main.go, tests)"]:::day
        D13["Day 13 (main.go, tests)"]:::day
        D14["Day 14 (main.go, tests)"]:::day
        D15["Day 15 (main.go, tests)"]:::day
        D16["Day 16 (main.go, tests)"]:::day
        D17["Day 17 (main.go, tests)"]:::day
        D18["Day 18 (main.go, tests)"]:::day
        D19["Day 19 (main.go, tests, failedattempts)"]:::day
        D20["Day 20 (main.go, tests, failedattempts)"]:::day
        D21["Day 21 (main.go, tests)"]:::day
        D22["Day 22 (main.go, tests)"]:::day
        D23["Day 23 (main.go, tests, failedattempts)"]:::day
        D24["Day 24 (main.go, tests)"]:::day
        D25["Day 25 (main.go, tests)"]:::day
    end

    %% Relationships
    TR -->|"taskprep"| SM
    TR -->|"uses"| GMOD
    TR -->|"uses"| MISETOML
    TR -->|"triggers"| D01
    TR -->|"triggers"| D25

    D01 -->|"uses"| UP
    D02 -->|"uses"| UP
    D03 -->|"uses"| UP
    D04 -->|"uses"| UP
    D05 -->|"uses"| UP
    D06 -->|"uses"| UP
    D07 -->|"uses"| UP
    D08 -->|"uses"| UP
    D09 -->|"uses"| UP
    D10 -->|"uses"| UP
    D11 -->|"uses"| UP
    D12 -->|"uses"| UP
    D13 -->|"uses"| UP
    D14 -->|"uses"| UP
    D15 -->|"uses"| UP
    D16 -->|"uses"| UP
    D17 -->|"uses"| UP
    D18 -->|"uses"| UP
    D19 -->|"uses"| UP
    D20 -->|"uses"| UP
    D21 -->|"uses"| UP
    D22 -->|"uses"| UP
    D23 -->|"uses"| UP
    D24 -->|"uses"| UP
    D25 -->|"uses"| UP

    %% Styles
    classDef automation fill:#FFCCCC,stroke:#CC0000,stroke-width:2px;
    classDef setup fill:#CCFFCC,stroke:#009900,stroke-width:2px;
    classDef day fill:#CCCCFF,stroke:#000099,stroke-width:2px;
    classDef utility fill:#FFFFCC,stroke:#999900,stroke-width:2px;
    classDef config fill:#FFEECC,stroke:#CC9900,stroke-width:2px;

    %% Click Events
    click TR "https://github.com/slijkhuis/2024-advent-of-code/blob/main/Taskfile.yml"
    click SM "https://github.com/slijkhuis/2024-advent-of-code/tree/main/prep"
    click UP "https://github.com/slijkhuis/2024-advent-of-code/tree/main/pkg/aoc"
    click GMOD "https://github.com/slijkhuis/2024-advent-of-code/blob/main/go.mod"
    click GOSUM "https://github.com/slijkhuis/2024-advent-of-code/blob/main/go.sum"
    click MISETOML "https://github.com/slijkhuis/2024-advent-of-code/blob/main/.mise.toml"
    click D01 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/01/main.go"
    click D02 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/02/main.go"
    click D03 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/03/main.go"
    click D04 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/04/main.go"
    click D05 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/05/main.go"
    click D06 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/06/main.go"
    click D07 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/07/main.go"
    click D08 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/08/main.go"
    click D09 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/09/main.go"
    click D10 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/10/main.go"
    click D11 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/11/main.go"
    click D12 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/12/main.go"
    click D13 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/13/main.go"
    click D14 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/14/main.go"
    click D15 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/15/main.go"
    click D16 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/16/main.go"
    click D17 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/17/main.go"
    click D18 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/18/main.go"
    click D19 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/19/main.go"
    click D20 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/20/main.go"
    click D21 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/21/main.go"
    click D22 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/22/main.go"
    click D23 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/23/main.go"
    click D24 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/24/main.go"
    click D25 "https://github.com/slijkhuis/2024-advent-of-code/blob/main/25/main.go"
```
