$ show sasa1977/boundary
Boundary is an Elixir library that enables developers to define and enforce architectural boundaries within their applications. By specifying which modules belong to which boundaries and what dependencies are allowed between them, teams can prevent unwanted coupling and maintain clean architectural layers (e.g., keeping the web layer from directly accessing database modules). The library works as a mix compiler that hooks into Elixir's compilation process using compilation tracers. During compilation, it records all module/function calls, then validates these calls against the defined boundary rules. Violations are reported as compiler warnings, allowing developers to identify and fix dependency issues early in the development process. Beyond enforcement, Boundary provides a suite of mix tasks for visualizing and analyzing dependencies. These include tools to generate dependency graphs at both the module and function level, identify external dependencies, and create documentation groupings. The implementation demonstrates advanced Elixir techniques including effective use of GenServer for state management, ETS for efficient data storage during compilation, and clever tricks for incremental analysis to maintain performance in large projects.
The LLM identified 3 files worth highlighting for reuse:
A mix task that visualizes intra-module function calls by leveraging Elixir's compilation tracers. It records caller-callee relationships during compilation using ETS, then generates a Graphviz DOT file showing the call graph within a single module. Demonstrates skillful use of compilation metadata for static analysis.
A mix task that visualizes cross-module dependencies between specified boundaries. It uses the compilation tracer to collect inter-module references during compilation, then constructs a hierarchical graph with subgraphs representing different boundaries. Shows effective use of Graphviz subgraphs for architectural visualization.
A GenServer-based state management pattern for mix compilers that efficiently handles compilation data. It uses ETS tables for temporary storage during compilation, persists data to disk between runs, and implements incremental updates to avoid reprocessing unchanged modules. Serves as an excellent reference for building performant mix compilers.