# tvaroh/tagged-types architecture

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

- Interactive diagram: https://gitdiagram.com/tvaroh/tagged-types
- Repository: https://github.com/tvaroh/tagged-types

## Overview

##### Project Type Analysis
This is an open-source Scala library that:
- Supports both JVM and Scala.js platforms (evident from js/ and jvm/ directories)
- Uses a shared code approach (shared/ directory)
- Provides zero-dependency type-safety utilities
- Has cross-platform test capabilities

##### Main Components

A. Core Components Layer:
- TaggedType Base Implementation
- Type Tag System
- Auto-tagging System
- Typeclass Support

B. Platform-Specific Implementations:
- JVM Implementation
- Scala.js Implementation

C. Integration Points:
- Circe Integration
- Slick Integration

**[Platform Layer]**
- JVM Platform <-----> Scala.js Platform
- ↑                   ↑

**[Shared Core Layer]**
- TaggedType System
- Base Tagged Type Implementation
- Type Tag Operations
- Auto-tagging System
- ↑
**[Integration Layer]**
- Circe Integration <-> Slick Integration

##### Key Aspects to Highlight

a) Type Safety Flow:
- Raw Type -> Tagged Type System -> Type-safe Tagged Value

b) Cross-Platform Support:
How shared code is utilized across platforms

c) Extension Points:
Demonstrate how external libraries can integrate

##### Implementation Details

- Tag Application Operations (@@@, taggedWith)
- Un-tagging Operations (-@, unTagged)
- Auto-tagging System
- Typeclass Derivation

Top Section:
**[External Library Integration]**
- ↓
**[Type Safety Layer]**
- ↓
**[Platform Implementation]**

Middle Section:
**[Core Type Operations]**
- ← Tagged Types →
- ← Type Constraints →

Bottom Section:
**[Platform-Specific Tests]**

##### Additional Notes

- Notes for important type safety guarantees
- Document integration points with external libraries

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef core fill:#b3d1ff,stroke:#333
    classDef platform fill:#90EE90,stroke:#333
    classDef integration fill:#FFB366,stroke:#333
    classDef test fill:#E6E6E6,stroke:#333

    %% Core Type System Layer
    subgraph CoreSystem
        TaggedType["Core Tagged Type System"]:::core
        TypeOps["Type Tag Operations"]:::core
        AutoTag["Auto-tagging System"]:::core
        TaggedBool["Tagged Boolean Implementation"]:::core
        
        TaggedType --> TypeOps
        TaggedType --> AutoTag
        TaggedType --> TaggedBool
    end

    %% Platform Layer
    subgraph Platforms
        JVM["JVM Implementation"]:::platform
        ScalaJS["Scala.js Implementation"]:::platform
        
        TaggedType --> JVM
        TaggedType --> ScalaJS
    end

    %% Integration Layer
    subgraph Integrations
        Circe["Circe Integration"]:::integration
        Slick["Slick Integration"]:::integration
        
        JVM --> Circe
        JVM --> Slick
        ScalaJS --> Circe
    end

    %% Testing Layer
    subgraph Testing
        SharedTest["Shared Testing Framework"]:::test
        JVMTest["JVM Tests"]:::test
        JSTest["Scala.js Tests"]:::test
        
        SharedTest --> JVMTest
        SharedTest --> JSTest
    end

    %% Click Events
    click TaggedType "https://github.com/Tvaroh/tagged-types/blob/master/shared/src/main/scala/taggedtypes/package.scala"
    click TaggedBool "https://github.com/Tvaroh/tagged-types/blob/master/shared/src/main/scala/taggedtypes/TaggedBoolean.scala"
    click JVMTest "https://github.com/Tvaroh/tagged-types/blob/master/jvm/src/test/scala/taggedtypestests/JvmTagSpec.scala"
    click JSTest "https://github.com/Tvaroh/tagged-types/blob/master/js/src/test/scala/taggedtypestests/JsTagSpec.scala"
    click SharedTest "https://github.com/Tvaroh/tagged-types/blob/master/shared/src/test/scala/taggedtypestests/TagSpecBase.scala"

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        PlatComp["Platform Component"]:::platform
        IntComp["Integration Component"]:::integration
        TestComp["Test Component"]:::test
    end
```
