# qawatake/obsdconv architecture

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

- Interactive diagram: https://gitdiagram.com/qawatake/obsdconv
- Repository: https://github.com/qawatake/obsdconv

## Overview

##### Main Components and Their Roles
- CLI / Main Entry Point:
- Represented by main.go along with several helper files (e.g., passarg.go).
- This is where command-line flags are parsed (e.g., src, dst, and various option flags like -std, -obs, etc.).

- Configuration Component:
- Files like config.go and config_test.go indicate configuration management.
- It processes and holds the settings from CLI flags and possibly configuration files.

- Conversion Engine:
- The convert package (with files such as convert.go, error.go, link.go and several corresponding test files) is responsible for converting the Obsidian-specific syntax.
- This includes removing tags, transforming internal links, processing H1 for front matter fields (title & aliases), and handling image embeds.

- File Processing Module:
- The process package (files like process.go, component.go, walk.go) handles file system interactions:
▪ Recursively scanning directories,
▪ Skipping files or folders (based on .obsdconvignore),
▪ Managing input (src) and output (dst) directories.

- Scan/Utility Module:
- The scan package (with scan.go and util.go) likely performs additional directory or file content scanning, ensuring that conditions (e.g., filtering, alias extraction) are met.

- Testing and Samples:
- The sample and testdata directories provide examples and test cases.

- CI/CD Workflows:
- The .github/workflows directory and its YAML files define automated testing and release pipelines.

##### Relationships and Data Flow
- The CLI/Entry Point sends parsed configuration data to the Configuration Module.
- Using these settings, the File Processing Module scans for Obsidian markdown files in the source directory.
- For each file found, control is passed to the Conversion Engine, where content is parsed, filtered (tags, H1, links) and converted.
- The Conversion Engine may call on functions in the Scan/Utility Module to resolve internal references or perform detailed checks (e.g., for strict reference checking).
- Finally, processed content is written to the destination directory (dst).

##### Architectural Patterns and Design Principles
- Modularity: Separate packages (convert, process, scan) each address distinct concerns.
- Separation of Concerns: The tool cleanly distinguishes CLI handling, configuration, file I/O, text conversion, and testing.
- Error Handling: Tests and modules like convert_test.go, process_test.go show that the system is built to handle errors (e.g., in link resolution).

## Diagram (Mermaid)

```mermaid
flowchart TD
    CLI("CLI/Entry Point"):::cli
    Config("Configuration Module"):::config
    FileProc("File Processing Module"):::fileProc
    Conversion("Conversion Engine"):::conversion
    Scan("Scan/Utility Module"):::scan
    Output("File Output (dst)"):::output
    Testing("Testing & Samples"):::testing
    CI("CI/CD Pipeline"):::ci

    CLI -->|"sendsFlags"| Config
    Config -->|"passesSettings"| FileProc
    FileProc -->|"scansFiles"| Conversion
    Conversion -->|"convertsContent"| Output
    Conversion -->|"uses"| Scan

    %% Supporting flows (non-runtime)
    Testing ---|"verifies"| CLI
    Testing ---|"verifies"| Config
    Testing ---|"verifies"| FileProc
    Testing ---|"verifies"| Conversion
    CI ---|"triggers"| Testing

    %% Click Events
    click CLI "https://github.com/qawatake/obsdconv/blob/main/main.go"
    click Config "https://github.com/qawatake/obsdconv/blob/main/config.go"
    click FileProc "https://github.com/qawatake/obsdconv/tree/main/process/"
    click Conversion "https://github.com/qawatake/obsdconv/tree/main/convert/"
    click Scan "https://github.com/qawatake/obsdconv/tree/main/scan/"
    click Testing "https://github.com/qawatake/obsdconv/tree/main/sample/"
    click CI "https://github.com/qawatake/obsdconv/tree/main/.github/workflows/"

    %% Styles
    classDef cli fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef config fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef fileProc fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef conversion fill:#fdfd96,stroke:#000,stroke-width:2px;
    classDef scan fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef output fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef testing fill:#FFE4E1,stroke:#000,stroke-width:2px;
    classDef ci fill:#E0FFFF,stroke:#000,stroke-width:2px;
```
