Skip to content

Architecture

The architecture of lyrics-core is designed around a unidirectional flow of data transformation: Input -> Parser -> Model -> Exporter -> Output.

Core Components

Model

The central data structure used throughout the application.

  • SyncedLyrics: The root container. Contains a list of lines, metadata (title, artists), and an ID.
  • ISyncedLine: Interface for a line of lyrics.
    • SyncedLine: Represents a standard line (LRC-style) with a start time and content.
    • KaraokeLine: Represents a karaoke line (KRC/TTML-style) with syllable-level timing info (KaraokeSyllable).

Parser

Responsible for converting raw strings or byte streams into the Model.

  • ILyricsParser: The common interface for all parsers.
  • LrcParser: Parses standard .lrc files.
  • KugouKrcParser: Parses encrypted or plain .krc files.
  • TTMLParser: Parses XML-based TTML (often used by Apple Music).
  • AutoParser: A facade that attempts to guess the format and use the appropriate parser.

Exporter

Responsible for converting the Model back into a specific string format.

  • ILyricsExporter: The common interface.
  • LrcExporter: Converts SyncedLyrics to LRC string.
  • TTMLExporter: Converts SyncedLyrics to TTML XML.

Utils

Helper classes for time parsing, encoding/decoding, and format guessing.

Data Flow

graph LR
    A[Raw Content] --> B{AutoParser}
    B --> F[SyncedLyrics]
    F --> D{Lyrics UI}
    F --> G{Exporter}
    G --> H[Outputs]