# andr-be/absoluteunit architecture

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

- Interactive diagram: https://gitdiagram.com/andr-be/absoluteunit
- Repository: https://github.com/andr-be/absoluteunit

## Overview

##### Main System Components

a) Input Layer:
- CLI Interface (AbsoluteUnitCLI.cs)
- Command Pattern Implementation
- Input Parsing System

b) Processing Layer:
- Measurement Engine
- Unit Type System
- Factory Components

c) Output Layer:
- Formatted Results
- Error Handling System

##### Detailed Component Breakdown

a) Parser System (Orange Section):
**MeasurementParser**
- ParserGroups
- CommandGroup
- MeasurementGroup
- UnitGroup

b) Unit Type System (Purple Section):
**UnitTypes**
- SIBase
- SIDerived
- SIPrefix
- USCustomary
- Miscellaneous

c) Factory System (Yellow Section):
**Factories**
- CommandFactory
- UnitFactory
- OutputWriter

##### Additional Elements

Supplementary information:
- Version information (.NET 8)
- Test coverage indicators
- External dependencies
- Configuration points

##### Notes for Implementation Details

- Where scientific notation is handled
- Prefix processing points
- Compound unit processing locations
- Error propagation paths

##### The error handling framework

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make this system robust and precise in handling unit conversions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI["CLI Layer"]
        CLI_Interface["CLI Interface"]:::input
        Command_Pattern["Command Pattern"]:::command
        Input_Validation["Input Validation"]:::validation
    end

    subgraph Processing["Processing Layer"]
        direction TB
        ME["Measurement Engine"]:::core
        
        subgraph Factories["Factory System"]
            direction TB
            CommandF["Command Factory"]:::factory
            UnitF["Unit Factory"]:::factory
            OutputW["Output Writer"]:::factory
        end
        
        subgraph Parsers["Parser System"]
            direction TB
            MP["Measurement Parser"]:::parser
            CG["Command Group"]:::parser
            MG["Measurement Group"]:::parser
            UG["Unit Group"]:::parser
        end
    end

    subgraph Domain["Domain Model Layer"]
        direction TB
        subgraph Commands["Command Types"]
            Convert["Convert Command"]:::command
            Express["Express Command"]:::command
            Simplify["Simplify Command"]:::command
            Calculate["Calculate Command"]:::command
        end
        
        subgraph Units["Unit Type System"]
            direction TB
            SIBase["SI Base Units"]:::unit
            SIDerived["SI Derived Units"]:::unit
            SIPrefix["SI Prefixes"]:::unit
            USCustomary["US Customary Units"]:::unit
            Misc["Miscellaneous Units"]:::unit
        end
        
        ErrorSystem["Error Handling System"]:::error
    end

    %% Relationships
    CLI_Interface --> Command_Pattern
    Command_Pattern --> Input_Validation
    Input_Validation --> MP
    MP --> |Parsing| ME
    MP --> CG & MG & UG
    
    CommandF --> Commands
    UnitF --> Units
    ME --> OutputW
    
    ErrorSystem -.-> CLI_Interface
    ErrorSystem -.-> ME
    ErrorSystem -.-> MP

    %% Click Events
    click CLI_Interface "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/AbsoluteUnitCLI.cs"
    click Convert "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Commands/Convert.cs"
    click Express "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Commands/Express.cs"
    click Simplify "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Commands/Simplify.cs"
    click Calculate "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Commands/Calculator.cs"
    click MP "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Parsers/MeasurementParser.cs"
    click CG "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Parsers/ParserGroups/CommandGroup.cs"
    click MG "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Parsers/ParserGroups/MeasurementGroup.cs"
    click UG "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Parsers/ParserGroups/UnitGroup.cs"
    click SIBase "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/UnitTypes/SIBase.cs"
    click SIDerived "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/UnitTypes/SIDerived.cs"
    click SIPrefix "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/UnitTypes/SIPrefix.cs"
    click USCustomary "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/UnitTypes/USCustomary.cs"
    click Misc "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/UnitTypes/Miscellaneous.cs"
    click CommandF "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Factories/CommandFactory.cs"
    click UnitF "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Factories/UnitFactory.cs"
    click OutputW "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Factories/OutputWriter.cs"
    click ME "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Structures/Measurement.cs"
    click ErrorSystem "https://github.com/andr-be/AbsoluteUnit/blob/master/AbsoluteUnit.Program/Errors.cs"

    %% Styles
    classDef input fill:#90EE90
    classDef command fill:#FFB6C1
    classDef validation fill:#ADD8E6
    classDef core fill:#4169E1
    classDef factory fill:#FFD700
    classDef parser fill:#FFA500
    classDef unit fill:#DDA0DD
    classDef error fill:#FF6347

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Command Components"]:::command
        L3["Validation Components"]:::validation
        L4["Core Processing"]:::core
        L5["Factory Components"]:::factory
        L6["Parser Components"]:::parser
        L7["Unit Components"]:::unit
        L8["Error Handling"]:::error
    end
```
