# antibios/dicom architecture

> Architecture diagram of the GitHub repository antibios/dicom, 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/antibios/dicom
- Repository: https://github.com/antibios/dicom

## Overview

##### Main Components

a. Input Layer:
- Supported input sources (File System and io.Reader)
- Main entry points (ParseFile and Parse functions)

b. Core Processing Pipeline:
- Parser Component (parse.go)
- Dataset Handler (dataset.go)
- Element Processing (element.go)
- Reader/Writer Components (read.go, write.go)

c. Specialized Package Components (organize in logical groups):
##### Data Processing Packages
- pkg/frame (Frame handling)
- pkg/charset (Character set handling)
- pkg/dcmtime (DICOM time processing)
- pkg/personname (Person name handling)

##### Core Utilities
- pkg/dicomio (Reader/Writer utilities)
- pkg/tag (DICOM tag definitions)
- pkg/uid (UID handling)
- pkg/vrraw (Value Representation)

##### Key Relationships to Highlight

a. Data Flow:
- How data moves from input through the parser
- Frame streaming capability
- Demonstrate both parsing and writing paths

b. Component Dependencies:
- How core components interact with utility packages
- Relationship between Parser, Dataset, and Elements

##### Special Features to Emphasize

a. Multi-frame Support:
- Frame extraction pipeline
- Both encapsulated and native pixel data handling

b. Streaming Capabilities:
- Channel-based streaming architecture
- How frames are delivered to clients during parsing

##### Technical Details

a. Key Interfaces:
- Reader/Writer interfaces from pkg/dicomio
- Frame handling interfaces
- Dataset structure

b. Performance Considerations:
- Parallel processing capabilities
- Streaming data paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef input fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef utility fill:#FFD700,stroke:#333,stroke-width:2px
    classDef processing fill:#FFA500,stroke:#333,stroke-width:2px
    classDef testing fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Input Layer
    subgraph Input
        FileSystem["File System Input"]:::input
        IOReader["io.Reader Input"]:::input
    end

    %% Core Processing
    subgraph CoreProcessing
        Parser["Parser"]:::core
        Dataset["Dataset Handler"]:::core
        Element["Element Processor"]:::core
        Reader["Reader"]:::core
        Writer["Writer"]:::core
    end

    %% Data Processing Packages
    subgraph DataProcessing
        Frame["Frame Handler"]:::processing
        Charset["Character Set"]:::processing
        DCMTime["DICOM Time"]:::processing
        PersonName["Person Name"]:::processing
        NativeFrame["Native Frame"]:::processing
        EncapFrame["Encapsulated Frame"]:::processing
    end

    %% Core Utilities
    subgraph Utilities
        DicomIO["DICOM IO"]:::utility
        TagDef["Tag Definitions"]:::utility
        UID["UID Handler"]:::utility
        VRRaw["Value Representation"]:::utility
    end

    %% Testing Components
    subgraph Testing
        MockReader["Mock Reader"]:::testing
        FuzzTests["Fuzz Tests"]:::testing
    end

    %% CLI Tool
    CLI["CLI Tool"]:::utility

    %% Relationships
    FileSystem --> Parser
    IOReader --> Parser
    Parser --> Dataset
    Dataset --> Element
    Element --> Reader
    Element --> Writer
    Parser --> Frame
    Frame --> NativeFrame
    Frame --> EncapFrame
    Parser --> DicomIO
    DicomIO --> Reader
    DicomIO --> Writer
    Parser --> TagDef
    Parser --> UID
    Parser --> VRRaw
    Dataset --> Charset
    Dataset --> DCMTime
    Dataset --> PersonName
    CLI --> Parser
    MockReader --> DicomIO
    FuzzTests --> Parser

    %% Click events
    click Parser "https://github.com/antibios/dicom/blob/main/parse.go"
    click Dataset "https://github.com/antibios/dicom/blob/main/dataset.go"
    click Element "https://github.com/antibios/dicom/blob/main/element.go"
    click Reader "https://github.com/antibios/dicom/blob/main/read.go"
    click Writer "https://github.com/antibios/dicom/blob/main/write.go"
    click Frame "https://github.com/antibios/dicom/blob/main/pkg/frame/frame.go"
    click Charset "https://github.com/antibios/dicom/blob/main/pkg/charset/charset.go"
    click DCMTime "https://github.com/antibios/dicom/tree/main/pkg/dcmtime/"
    click PersonName "https://github.com/antibios/dicom/tree/main/pkg/personname/"
    click DicomIO "https://github.com/antibios/dicom/blob/main/pkg/dicomio/reader.go"
    click TagDef "https://github.com/antibios/dicom/blob/main/pkg/tag/tag_definitions.go"
    click UID "https://github.com/antibios/dicom/blob/main/pkg/uid/uid.go"
    click VRRaw "https://github.com/antibios/dicom/blob/main/pkg/vrraw/vrraw.go"
    click CLI "https://github.com/antibios/dicom/blob/main/cmd/dicomutil/main.go"
    click NativeFrame "https://github.com/antibios/dicom/blob/main/pkg/frame/native.go"
    click EncapFrame "https://github.com/antibios/dicom/blob/main/pkg/frame/encapsulated.go"
    click MockReader "https://github.com/antibios/dicom/blob/main/mocks/pkg/dicomio/mock_reader.go"
    click FuzzTests "https://github.com/antibios/dicom/blob/main/fuzz/dicom_fuzz_test.go"

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Core Components"]:::core
        L3["Utility Components"]:::utility
        L4["Processing Components"]:::processing
        L5["Testing Components"]:::testing
    end
```
