# yevgnen/pybrat architecture

> Architecture diagram of the GitHub repository yevgnen/pybrat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yevgnen/pybrat
- Repository: https://github.com/yevgnen/pybrat

## Overview

##### Project Type Identification
This is a specialized Python library tool focused on parsing annotations from the brat annotation tool. The architecture should reflect its primary data processing pipeline.

##### Main Components

a) Input Layer:
- Brat Annotation Files (.ann files)
- Source Text Files (.txt files)

b) Core Processing Components:
- BratParser (Main Parser Class)
- Parser Components (show internal modules)
- Utility Functions

c) Output Layer:
- Structured Data Classes (Example, Entity, Event, Relation)
- JSON Export Capability

**[Input] -> [Processing] -> [Output]**

##### Data Flow Representation

- Raw files → Parser
- Parser → Structured Data Classes
- Structured Data Classes → JSON Export

##### Additional Elements

- Error handling options
- Data class relationships
- File format specifications

##### Technical Details to Highlight

- That the parser is initialized with error handling options
- Dataclass nature of the output objects
- Conversion capability to dictionary/JSON format

## Diagram (Mermaid)

```mermaid
graph TB
    %% Input Layer
    subgraph Input
        ANN[".ann Files"]
        TXT[".txt Files"]
    end

    %% Processing Layer
    subgraph Processing
        BP["BratParser"]
        click BP "https://github.com/yevgnen/pybrat/blob/main/pybrat/parser.py"
        
        subgraph Parser["Parser Components"]
            PARS["Parser Logic"]
            click PARS "https://github.com/yevgnen/pybrat/blob/main/pybrat/parser.py"
            UTIL["Utility Functions"]
            click UTIL "https://github.com/yevgnen/pybrat/blob/main/pybrat/utils.py"
            INIT["Package Entry"]
            click INIT "https://github.com/yevgnen/pybrat/blob/main/pybrat/__init__.py"
            TYPES["Type Hints"]
            click TYPES "https://github.com/yevgnen/pybrat/blob/main/pybrat/py.typed"
        end
        
        ERR{"Error Handling"}
        CONFIG["Package Config"]
        click CONFIG "https://github.com/yevgnen/pybrat/blob/main/pyproject.toml"
    end

    %% Output Layer
    subgraph Output
        subgraph DataClasses
            EX["Example"]
            click EX "https://github.com/yevgnen/pybrat/blob/main/examples/example.py"
            ENT["Entity"]
            EVT["Event"]
            REL["Relation"]
        end
        JSON["JSON Export"]
    end

    %% Connections
    ANN --> BP
    TXT --> BP
    BP --> ERR
    ERR -->|error='ignore'| Parser
    ERR -->|error='raise'| Parser
    Parser --> DataClasses
    DataClasses --> JSON

    %% Styling
    classDef input fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef processing fill:#90EE90,stroke:#333,stroke-width:2px
    classDef output fill:#FFB347,stroke:#333,stroke-width:2px
    classDef parser fill:#98FB98,stroke:#333,stroke-width:2px
    classDef config fill:#DDA0DD,stroke:#333,stroke-width:2px

    class ANN,TXT input
    class BP,ERR processing
    class PARS,UTIL,INIT,TYPES parser
    class EX,ENT,EVT,REL,JSON output
    class CONFIG config

    %% Legend
    subgraph Legend
        L1["Input Files"]:::input
        L2["Processing"]:::processing
        L3["Output"]:::output
        L4["Configuration"]:::config
    end
```
