# alexdachin/gophix architecture

> Architecture diagram of the GitHub repository alexdachin/gophix, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexdachin/gophix
- Repository: https://github.com/alexdachin/gophix

## Overview

##### Main Components

a) Input Layer:
- Google Photos Takeout folder structure
- Both media files (photos/videos) and their associated JSON metadata files

b) Core Processing Components:
- Command Handler (for 'fix' and 'clean-json' commands)
- File Processing Pipeline
- Extension Management System
- Metadata Processing System

c) External Dependencies:
- ExifTool integration (show as an external system)

##### Component Organization

**┌─ Input Layer ─────────────────────┐**
- Takeout Directory Structure       │
- Media Files (.jpg, .png, etc)   │
- JSON Metadata Files             │
- ┬───────────────────┘
- ↓
**┌─ Core Processing ─────────────────┐**
- ┌─ Command Handler ──────┐        │
- fix                  │        │
- clean-json          │        │
- ┬────────────┘        │
- ↓                      │
- ┌─ Processing Pipeline ─┐        │
- ┌─ Files Utils ────┐  │        │
- Classification │  │        │
- JSON Handling  │  │        │
- ┘  │        │
- ┌─ Extensions ────┐  │        │
- Format Check  │  │        │
- Extension Fix │  │        │
- ┘  │        │
- ┌─ Metadata ──────┐  │        │
- Extraction    │  │        │
- Merging       │  │        │
- ┘  │        │
- ┬──────────┘        │
- ┬───────────────────┘
- ↓
**┌─ External Tools ─────────────────┐**
- ExifTool                         │
- ┬───────────────────┘
- ↓
**┌─ Output Layer ──────────────────┐**
- Fixed Media Files             │
- XMP Sidecar Files (if needed) │
- Cleaned JSON Files            │
- ┘

##### Important Flows to Highlight

- File reading flow from input directory
- Processing pipeline sequence
- Metadata merging process
- Output file generation

##### Additional Details

Annotations for:
- Supported file formats
- JSON metadata structure
- Command-line interface options
- Error handling strategies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        TD[Takeout Directory]
        MF[Media Files]
        JF[JSON Files]
        TD --> MF
        TD --> JF
    end

    subgraph Core
        CH[Command Handler]:::command
        
        subgraph Pipeline
            FP[File Processing Pipeline]:::pipeline
            
            subgraph Utils
                FC[File Classification]:::utils
                JH[JSON Processing]:::utils
                JV[JSON Validation]:::utils
            end
            
            subgraph Components
                EM[Extension Management]:::component
                MP[Metadata Processing]:::component
            end
            
            FP --> FC
            FP --> JH
            FP --> JV
            FP --> EM
            FP --> MP
        end
        
        CH --> FP
    end

    subgraph External
        ET[ExifTool]
    end

    subgraph Output
        FM[Fixed Media Files]
        XS[XMP Sidecar Files]
        CJ[Cleaned JSON Files]
    end

    Input --> CH
    MP --> ET
    Core --> Output

    classDef command fill:#a8d08d
    classDef pipeline fill:#95b3d7
    classDef utils fill:#b8cce4
    classDef component fill:#e6b8b7
    classDef external fill:#fbd5b5

    click CH "https://github.com/alexdachin/gophix/blob/master/main.go"
    click EM "https://github.com/alexdachin/gophix/blob/master/utils/extensions/extensions.go"
    click FP "https://github.com/alexdachin/gophix/blob/master/utils/files/files.go"
    click FC "https://github.com/alexdachin/gophix/blob/master/utils/files/classify_files.go"
    click JH "https://github.com/alexdachin/gophix/blob/master/utils/files/get_json_file.go"
    click JV "https://github.com/alexdachin/gophix/blob/master/utils/files/check_unused_json.go"
    click MP "https://github.com/alexdachin/gophix/blob/master/utils/metadata/metadata.go"

    subgraph Legend
        L1[Command Handler]:::command
        L2[Pipeline]:::pipeline
        L3[Utils]:::utils
        L4[Components]:::component
        L5[External Tools]:::external
    end
```
