# roma1011/shadowcaster architecture

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

- Interactive diagram: https://gitdiagram.com/roma1011/shadowcaster
- Repository: https://github.com/roma1011/shadowcaster

## Overview

##### Main Components
- Core Mapping Engine – This is represented by the Caster class (src/Caster.cs). It is responsible for initiating the mapping process.
- Mapping Strategies – The system supports different mapping strategies. Use the ShadowType enumeration (src/ShadowType.cs) to indicate the two strategy types (“ByProp” and “KeyValue”). Additionally, the CharacterCasing enumeration (src/CharacterCasing.cs) defines how property names are transformed.
- Utility/Helper Component – Although not explicitly described in the README, the presence of ShadowSeer (src/ShadowSeer.cs) hints at additional, possibly introspective or debugging/inspection functionality (e.g., assisting in analyzing or tracing the mapping process).

##### Relationships and Interactions
- Data Flow: The source input (which may be an object or a dictionary) is provided to the Caster's AsDestination<TDestination>() method.
- Decision Making: Within the mapping function, based on the provided ShadowType (and optionally CharacterCasing), the appropriate strategy is selected, and reflection is used to map the properties from the source to the destination.
- Error Handling: The mapping process can throw InvalidOperationException or InvalidCastException when there are issues with the source. This error handling mechanism should be noted as part of the process.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project cleanly segments its responsibilities – one class handles the mapping (Caster), while enumerations define configurable transformations, and possibly ShadowSeer assists in complex or introspective mapping tasks.
- Flexibility & Extensibility: Through its support for different mapping strategies (ByProp vs. KeyValue) and character casing rules, the design supports customization and scaling.
- Minimal Dependencies: Reflecting its lightweight nature, it is designed to be easily integrated into projects without external dependencies.

##### Incorporate Relevant Technologies and Libraries
- Reflection in .NET is the key underlying technology that enables runtime property mapping.
- The project is structured as a .NET library (evident from the ShadowCaster.csproj), making it portable for inclusion in other C# applications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    subgraph "Input Layer"
        A1("Source Object (ByProp)"):::input
        A2("Dictionary (KeyValue)"):::input
    end

    %% Mapping Engine
    subgraph "Mapping Engine"
        B("Caster (Mapping Engine)"):::core
    end

    %% Mapping Strategies
    subgraph "Mapping Strategies"
        C("ShadowType (ByProp/KeyValue)"):::enum
        D("CharacterCasing (Normal/Lower/Upper)"):::enum
    end

    %% Utility/Helper Component
    subgraph "Utility/Helper"
        E("ShadowSeer (Introspection)"):::util
    end

    %% Output Layer
    subgraph "Output Layer"
        H("Mapped Object (Destination)"):::output
    end

    %% Error Handling
    subgraph "Error Handling"
        F("InvalidOperationException"):::error
        G("InvalidCastException"):::error
    end

    %% Connections
    A1 -->|"Input"| B
    A2 -->|"Input"| B
    B -->|"SelectsStrategy"| C
    B -->|"AppliesCasing"| D
    B -->|"AssistsMapping"| E
    B -->|"MappingDone"| H
    B -- "Throws" --> F
    B -- "Throws" --> G

    %% Click Events
    click B "https://github.com/roma1011/shadowcaster/blob/main/src/Caster.cs"
    click C "https://github.com/roma1011/shadowcaster/blob/main/src/ShadowType.cs"
    click D "https://github.com/roma1011/shadowcaster/blob/main/src/CharacterCasing.cs"
    click E "https://github.com/roma1011/shadowcaster/blob/main/src/ShadowSeer.cs"

    %% Styles
    classDef input fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef enum fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef util fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef output fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef error fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
