How elixir-maru/maru_params works
Main components
• Core Parser Module: Represent the central component (Maru.Params) that orchestrates how parameters are collected, parsed, transformed, and validated.
• Type System/Validators: Identify each “type” module (see lib/maru/params/types) such as Atom, Base64, Boolean, DateTime, etc. Group them under a “Type Handlers” or “Validators” component.
• Parameter Builder and Pipeline: Include modules that build and configure the parsing logic (e.g., builder modules, pipeline chaining using type operators like “Base64 |> Integer”).
• Controller Integration: Since the library supports the Phoenix framework, include an integration module (Maru.Params.PhoenixController) that acts as an adapter when used within Phoenix controllers.
• Exception Handling: Represent error management and exception modules (e.g., lib/maru/params/exceptions.ex) that dictate how the system reacts to invalid input.
• Configuration & Options: Note that the library also involves configuration (through config/config.exs and runtime options for types) which can be represented as a separate configuration component.
Relationships and Interactions
• Input Flow: Start with external requests coming into a Phoenix controller or direct API endpoint that uses this library.
• Processing Pipeline: Illustrate how the input data flows into the core parser, which then passes the data to the various type/validation modules.
• Error/Exception Flow: Show that if any type conversion or validation fails, control flows into the exception module, which either raises an error or returns a formatted error response.
Architectural Patterns & Design Principles
• Modularity: Emphasize the separation of concerns by having distinct modules for each type and for adapter functionality (Phoenix integration).
• Pipeline Processing: Note that the library supports chained operations on parameter types (using the pipeline notion: Json |> List[Integer] etc.) which is a key conceptual and diagrammatic element.
• Extensibility: Indicate that the architecture allows for extension via custom types and validators, as well as integration points (e.g., custom JSON libraries or ecto_enum validation).
Technologies and Dependencies
• Elixir (base language) and its mix project structure.
• Integration dependencies such as Phoenix, Plug, Jason, Decimal, and ecto.
• GitHub workflows (CI/CD) for testing and integration, represented optionally in a “DevOps/CI” bubble if needed.
Creating a Detailed Sketch
• From there, connect to a central “Maru.Params Core Engine” that manages parameter parsing.
• A side branch showing the “Pipeline Processing” where transformation sequences (Base64 → Integer, Json → List[Integer], etc.) are applied.