# elliotchance/gedcom architecture

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

## Overview

##### Main Components

a. Core Library Layer:
- Main data structures (Document, Node, Individual, Family, etc.)
- Encoder/decoder components for GEDCOM file processing

b. Query Engine Layer:
- Query engine ('q' package) as a separate module
- Parser, engine, and various expression types
- Different formatters (CSV, JSON, HTML, GEDCOM)

c. HTML Generation Layer:
- HTML rendering system
- Core components and specialized renderers
- To the main GEDCOM processing layer

d. CLI Tools Layer:
- Main command-line tools:
- gedcomq (query tool)
- diff (comparison tool)
- publish (HTML generation)
- warnings (validation)

##### Relationships and Data Flow

- GEDCOM file input → Decoder → Internal representation
- Internal representation → Encoder → GEDCOM file output
- Query flow: Input → Parser → Engine → Formatter → Output
- HTML generation flow: GEDCOM data → HTML components → Static website

##### Important Design Elements

- Warning system components
- Comparison/diff functionality
- Merge operations
- Various node types (Individual, Family, Event, etc.)

##### Specific Implementation Details

Interfaces:
- Noder interface
- Gedcomer interface
- Warner interface
- Various node implementations

##### External Interactions

Include:
- File I/O operations
- HTML output
- Query input/output formats
- API integration points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["Command Line Tools"]
        CLI_Main["Main CLI"]:::cli
        CLI_Query["Query Tool"]:::cli
        CLI_Diff["Diff Tool"]:::cli
        CLI_Publish["Publish Tool"]:::cli
        CLI_Warnings["Warnings Tool"]:::cli
    end

    subgraph Core["Core GEDCOM Processing"]
        Doc["Document Handler"]:::core
        NodeIF["Node Interface"]:::core
        Enc["Encoder"]:::core
        Dec["Decoder"]:::core
        
        subgraph DataStructures["Data Structures"]
            IndNode["Individual Node"]:::core
            FamNode["Family Node"]:::core
            EventNode["Event Node"]:::core
            DateNode["Date Node"]:::core
        end
    end

    subgraph Query["Query Engine"]
        QEngine["Engine"]:::query
        QParser["Parser"]:::query
        
        subgraph Formatters["Formatters"]
            FCSV["CSV Formatter"]:::query
            FJSON["JSON Formatter"]:::query
            FHTML["HTML Formatter"]:::query
            FGED["GEDCOM Formatter"]:::query
        end

        subgraph Expressions["Expression Types"]
            BinExpr["Binary Expression"]:::query
            AccExpr["Accessor Expression"]:::query
            CallExpr["Call Expression"]:::query
        end
    end

    subgraph HTML["HTML Generation"]
        HTMLCore["Core Components"]:::html
        Publisher["Main Publisher"]:::html
        
        subgraph Pages["Page Generators"]
            IndPage["Individual Page"]:::html
            FamListPage["Family List Page"]:::html
            StatsPage["Statistics Page"]:::html
            PlacePage["Place Page"]:::html
        end
    end

    subgraph Warning["Warning System"]
        WarnIF["Warning Interface"]:::warning
        
        subgraph WarnTypes["Warning Types"]
            WarnChild["Child Born Before Parent"]:::warning
            WarnAge["Individual Too Old"]:::warning
            WarnSex["Multiple Sexes"]:::warning
            WarnDate["Unparsable Date"]:::warning
        end
    end

    subgraph Diff["Comparison System"]
        NodeDiff["Node Diff"]:::diff
        IndComp["Individual Comparison"]:::diff
        HTMLDiff["HTML Diff"]:::diff
    end

    Dec --> Doc
    Doc --> Enc
    Doc --> DataStructures
    NodeIF --> DataStructures
    
    QEngine --> Formatters
    QParser --> QEngine
    Expressions --> QEngine
    
    Doc --> Publisher
    Publisher --> Pages
    HTMLCore --> Pages
    
    Doc --> WarnIF
    WarnIF --> WarnTypes
    
    Doc --> NodeDiff
    NodeDiff --> HTMLDiff
    
    CLI_Query --> QEngine
    CLI_Diff --> Diff
    CLI_Publish --> Publisher
    CLI_Warnings --> Warning

    %% Click Events
    click Doc "https://github.com/elliotchance/gedcom/blob/master/document.go"
    click NodeIF "https://github.com/elliotchance/gedcom/blob/master/node.go"
    click Enc "https://github.com/elliotchance/gedcom/blob/master/encoder.go"
    click Dec "https://github.com/elliotchance/gedcom/blob/master/decoder.go"
    click IndNode "https://github.com/elliotchance/gedcom/blob/master/individual_node.go"
    click FamNode "https://github.com/elliotchance/gedcom/blob/master/family_node.go"
    click EventNode "https://github.com/elliotchance/gedcom/blob/master/event_node.go"
    click DateNode "https://github.com/elliotchance/gedcom/blob/master/date_node.go"
    click QEngine "https://github.com/elliotchance/gedcom/blob/master/q/engine.go"
    click QParser "https://github.com/elliotchance/gedcom/blob/master/q/parser.go"
    click FCSV "https://github.com/elliotchance/gedcom/blob/master/q/csv_formatter.go"
    click FJSON "https://github.com/elliotchance/gedcom/blob/master/q/json_formatter.go"
    click FHTML "https://github.com/elliotchance/gedcom/blob/master/q/html_formatter.go"
    click FGED "https://github.com/elliotchance/gedcom/blob/master/q/gedcom_formatter.go"
    click BinExpr "https://github.com/elliotchance/gedcom/blob/master/q/binary_expr.go"
    click AccExpr "https://github.com/elliotchance/gedcom/blob/master/q/accessor_expr.go"
    click CallExpr "https://github.com/elliotchance/gedcom/blob/master/q/call_expr.go"
    click HTMLCore "https://github.com/elliotchance/gedcom/tree/master/html/core/"
    click Publisher "https://github.com/elliotchance/gedcom/blob/master/html/publish.go"
    click IndPage "https://github.com/elliotchance/gedcom/blob/master/html/individual_page.go"
    click FamListPage "https://github.com/elliotchance/gedcom/blob/master/html/family_list_page.go"
    click StatsPage "https://github.com/elliotchance/gedcom/blob/master/html/statistics_page.go"
    click PlacePage "https://github.com/elliotchance/gedcom/blob/master/html/place_page.go"
    click CLI_Main "https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/main.go"
    click CLI_Query "https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/query.go"
    click CLI_Diff "https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/diff.go"
    click CLI_Publish "https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/publish.go"
    click CLI_Warnings "https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/warnings.go"
    click WarnIF "https://github.com/elliotchance/gedcom/blob/master/warner.go"
    click WarnChild "https://github.com/elliotchance/gedcom/blob/master/child_born_before_parent_warning.go"
    click WarnAge "https://github.com/elliotchance/gedcom/blob/master/individual_too_old_warning.go"
    click WarnSex "https://github.com/elliotchance/gedcom/blob/master/multiple_sexes_warning.go"
    click WarnDate "https://github.com/elliotchance/gedcom/blob/master/unparsable_date_warning.go"
    click NodeDiff "https://github.com/elliotchance/gedcom/blob/master/node_diff.go"
    click IndComp "https://github.com/elliotchance/gedcom/blob/master/individual_comparison.go"
    click HTMLDiff "https://github.com/elliotchance/gedcom/blob/master/html/diff_page.go"

    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px;
    classDef query fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef html fill:#FFB347,stroke:#333,stroke-width:2px;
    classDef cli fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef warning fill:#FF6961,stroke:#333,stroke-width:2px;
    classDef diff fill:#779ECB,stroke:#333,stroke-width:2px;
```
