@startuml
!theme vibrant
title Wasot: Emitter-Consumer Architecture

skinparam packageStyle rectangle

' The event enum that is broadcasted
enum ElementEvent {
  BlockStarted { meta_line: MetaLine }
  BlockFinished { line_index: Option<usize> }
  TextFinished { line_index: usize, lines: Vec<String> }
}

' The communication channel
class "Channel" as Channel

' Abstract roles
interface Emitter
interface Consumer

' Concrete implementations
package "Emitters (Event Sources)" {
  class "WasotFileParser" as Parser
  class "CacheReplayer" as Replayer
}

package "Consumers (Event Sinks)" {
  class "SqliteWriter" as Sqlite
  class "CacheFileWriter" as Cache
}

' Show implementations of the interfaces
Parser .up.|> Emitter
Replayer .up.|> Emitter

Sqlite .up.|> Consumer
Cache .up.|> Consumer

' Show the data flow and relationships
note left of Parser
  An Emitter creates the channel
  and sends events into it.
end note

note right of Sqlite
  A Consumer subscribes to the
  channel and processes events.
end note


' Emitters send events to the channel
Parser -right-> Channel : sends
Replayer -right-> Channel : sends

' Consumers receive events from the channel
Channel -right-> Sqlite : receives
Channel -right-> Cache : receives

' The channel carries the ElementEvent type
Channel o-- ElementEvent : carries

@enduml
