@startuml wasot_data_model
!theme vibrant

title Wasot Data Model

' Set overall direction for a clean flow
top to bottom direction

' ----- Main File and Metadata -----
class File {
    elements: List<Element> = []
}

class Metadata {
    id: String
    title: String
    lastChanged: String
    data: Map<String, String> = {}
}

File "1" *-- "1" Metadata

' ----- Element Hierarchy (Composite Pattern) -----
package "Elements" {
    note as CompositePatternNote
        <b>Composite Pattern</b>
        A `Block` can recursively contain
        other `Element`s (Blocks or Texts),
        forming a tree structure.
    end note

    abstract class Element
    class Block {
        type: String
        id: String?
        inlineText: String?
        --
        arguments: List<Argument> = []
        children: List<Element> = []
        --
        getKwArg(key: String): List<String>
        getArg(index: int): String
    }
    class Text {
        from: int
        to: int
        --
        lines: List<String> = []
    }

    Element <|-- Block
    Element <|-- Text
}

' ----- Argument Hierarchy -----
package "Arguments" {
    abstract class Argument
    class PositionalArgument {
        index: int
        value: String
    }
    class KeywordArgument {
        key: String
        value: String
    }
    Argument <|-- PositionalArgument
    Argument <|-- KeywordArgument
}

' ----- Relationships -----
File "1" *-- "0..*" Element : elements >
Block "1" *-- "0..*" Element : children >
Block "1" *-- "0..*" Argument : arguments >

@enduml