How yagogarea/advent_of_code works
Main Components Identification
• Advent of Code Day Solutions: Each puzzle day (e.g., aoc_2024_day1, aoc_2024_day2, …, aoc_2024_day14) is implemented as its own Erlang application inside the apps/aoc_2024 directory. Each application contains a source for the solution logic (e.g., aoc_2024_dayX.erl) along with its app descriptor file.
• AOC Manager: Found in apps/aoc_manager, this application is responsible for initializing new puzzle day directories using templates and possibly coordinating some common functionality such as HTTP requests to retrieve problem statements.
• AOC Puzzle: Located in apps/aoc_puzzle, this module likely handles retrieving and processing Advent of Code puzzle data, interfacing with the web (e.g., sending HTTP requests).
• AOC Utilities: Found in apps/aoc_utils, this library contains helper modules (for list, matrix, and string operations) which are shared across the various day solution apps.
• Templates: The embedded templates are stored in the templates directory, which provide a default structure (both for the application files and test stubs) used by the AOC Manager during day initialization.
• Build and Test Configuration: The root-level rebar.config and test directories indicate how the system is built and tested, providing deployment details.
Relationships and Interactions
• The AOC Manager is the central orchestrator that, via its init_day function, uses the templates to auto-generate new directory structures for a new puzzle day.
• When initializing a new day, the AOC Manager makes an HTTP request (through functionality provided perhaps by the AOC Puzzle app) to fetch the HTML of the puzzle page and then parses it to extract the problem statement.
• Each day's solution module (aoc_2024_dayX) is designed to implement two key functions: one for part one (sol) and one for part two (sol2), which operate on the input provided.
• The AOC Utilities module is a shared library used by various components for common data processing operations needed by the various puzzle solutions.
• The templates folder provides the baseline code that contracts new days’ code to ensure consistency across the puzzle apps.
Architectural Patterns and Design Principles
• Modularity: Each day’s solution is isolated in its own application, facilitating maintainability and independent development.
• Encapsulation: Support functions (e.g., AOC Manager, AOC Puzzle, and AOC Utilities) encapsulate common behavior ensuring reuse without redundancy.
• Use of rebar build tool: The entire project is organized with rebar’s conventions, meaning each app has its app descriptor and configuration, and tests are organized separately.
• Template-driven Initialization: The use of generated templates captures a design pattern that promotes rapid setup and uniform code structure across different days.