# joelonsql/wherr architecture

> Architecture diagram of the GitHub repository joelonsql/wherr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joelonsql/wherr
- Repository: https://github.com/joelonsql/wherr

## Overview

##### Main Components

a) Core Components:
- wherr-macro crate (Procedural Macro Implementation)
- wherr main crate (Core Functionality)
- Error Handling Integration Layer
- Optional Anyhow Integration Component

b) Key Interactions:
- Compile-time macro processing
- Runtime error wrapping
- Integration with Rust's error handling system

**[wherr-macro Crate]**

- Procedural Macro Processor
- Code Transformation Logic

**[wherr Main Crate]**

- Error Wrapper Implementation
- File/Line Capture Logic
- Integration Interfaces

**[External Integration]**

- Standard Rust Error Handling
- Anyhow Integration (Optional)

##### Flow Directions

- Compile-time transformation flow (top to middle)
- Runtime error propagation (bottom to top)
- Integration point connections (horizontal)

##### Additional Details

Annotations showing:
- File/line capture points
- Error transformation stages
- Integration boundaries with external crates

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef compiletime fill:#b3d9ff,stroke:#333
    classDef runtime fill:#90EE90,stroke:#333
    classDef integration fill:#FFE5B4,stroke:#333
    classDef error fill:#FFB6C1,stroke:#333

    %% Compile Time Layer
    subgraph CompileTime
        MacroCrate["wherr-macro Crate"]
        ProcMacro["Procedural Macro Processor"]
        CodeTransform["Code Transformation Logic"]
    end

    %% Core Implementation Layer
    subgraph CoreImpl
        MainCrate["wherr Main Crate"]
        ErrorWrapper["Error Wrapper Implementation"]
        FileLineCapture["File/Line Capture Logic"]
        IntegrationInterface["Integration Interfaces"]
    end

    %% Integration Layer
    subgraph Integration
        StdError["Standard Rust Error Handling"]
        AnyhowInteg["Anyhow Integration"]
        UsageExamples["Usage Examples"]
    end

    %% Relationships
    MacroCrate --> ProcMacro
    ProcMacro --> CodeTransform
    CodeTransform --> MainCrate
    MainCrate --> ErrorWrapper
    MainCrate --> FileLineCapture
    MainCrate --> IntegrationInterface
    IntegrationInterface --> StdError
    IntegrationInterface --> AnyhowInteg
    ErrorWrapper --> UsageExamples
    
    %% Style Applications
    class MacroCrate,ProcMacro,CodeTransform compiletime
    class MainCrate,ErrorWrapper,FileLineCapture,IntegrationInterface runtime
    class StdError,AnyhowInteg,UsageExamples integration

    %% Click Events
    click MacroCrate "https://github.com/joelonsql/wherr/blob/master/wherr-macro/src/lib.rs"
    click MainCrate "https://github.com/joelonsql/wherr/blob/master/wherr/src/lib.rs"
    click StdError "https://github.com/joelonsql/wherr/blob/master/wherr/tests/box_error_tests.rs"
    click AnyhowInteg "https://github.com/joelonsql/wherr/blob/master/wherr/tests/anyhow_error_tests.rs"
    click UsageExamples "https://github.com/joelonsql/wherr/blob/master/wherr/examples/with_wherr.rs"

    %% Legend
    subgraph Legend
        CompileTime["Compile Time Component"]:::compiletime
        Runtime["Runtime Component"]:::runtime
        IntegrationPoint["Integration Point"]:::integration
    end
```
