# sukulent/namefix architecture

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

- Interactive diagram: https://gitdiagram.com/sukulent/namefix
- Repository: https://github.com/sukulent/namefix

## Overview

##### Project Type and Purpose
- Namefix is a command-line utility (open-source tool) written in C++ for normalizing and renaming filenames. It leverages a third-party Unicode transliteration library and an argument-parsing library (args) to process files on the local filesystem.

##### File Structure Analysis
- Top-level files:
- LICENSE.md, CHANGELOG.md, README.md – documentation
- makefile – build and install rules
- man/namefix.1 – manual page
- src/ directory:
- main.cpp / main.hpp – entry point, orchestrates flag handling and file iteration
- args.hxx – wrapper for command-line parsing
- No separate modules or services: this is a single monolithic binary.

##### Key Components
a. CLI Interface (User)
b. Argument Parser (args library)
c. Controller / Orchestrator (main.cpp)
d. Filename-Fixing Core
– Extension extractor
– Override processor
– ASCII conversion pipeline (normalize, transliterate, cleanup)
– Truncation & character-replacement logic (spaces, periods, non-ASCII)
e. Filesystem Module
– Check existence, read permissions
– Rename or Copy (based on flags)
f. Logger / Reporting
– verbose, report, dry-run outputs
g. External Dependencies
– Unicode library for transliteration
– std::filesystem (C++17)

##### Relationships and Data Flow
- User invokes “namefix [OPTIONS] [input…]” → passes to Argument Parser
- Parsed flags & paths → Controller
- Controller loops over each input path:
1) Query Filesystem Module: exists? directory? symlink?
2) Pass filename to Core Pipeline:
a) Separate extensions
b) Apply overrides
c) Normalize & transliterate to ASCII
d) Truncate & replace spaces/periods/non-ASCII
3) Construct new path
4) Logger: if report/verbose/dry-run → print info
5) Filesystem Module: rename or copy (depending on keep flags)
- End loop → print summary (errors count, if any) → exit

##### Architectural Patterns and Principles
- Monolithic, procedural pipeline
- Single responsibility units: argument parsing, core processing, filesystem operations, logging
- Clear separation between “data processing” (filename transformation) and “side-effects” (I/O)

##### Essential Elements
- Component labels (e.g., “Filename-Fixing Core”)
- Callouts for major flags that alter flow: --dry-run, --report, --keep
- Blue = internal processing
- Green = I/O operations
- Orange = external libraries

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Boundary"
        User["User CLI"]:::cloud
    end

    subgraph "External Libraries"
        ArgsLib["args library"]:::external
        UnicodeLib["Unicode Transliteration Library"]:::external
        StdFS["std::filesystem"]:::external
    end

    subgraph "Internal Processing"
        Parser["Argument Parser"]:::processing
        Controller["Controller/Orchestrator"]:::processing
        subgraph "Filename-Fixing Core"
            ExtExtractor["Extension Extractor"]:::processing
            Override["Override Processor"]:::processing
            NormPipeline["Normalize & Transliterate Pipeline"]:::processing
            TruncReplace["Truncate & Replace Logic"]:::processing
        end
    end

    subgraph "Side-Effects (I/O)"
        FSModule["Filesystem Module"]:::io
        Logger["Logger/Reporting"]:::io
    end

    subgraph "Documentation & Build"
        README["README.md"]:::docs
        CHANGELOG["CHANGELOG.md"]:::docs
        LICENSE["LICENSE.md"]:::docs
        MAN["Manual Page"]:::docs
        Build["Build & Install Rules (makefile)"]:::docs
    end

    User --> Parser
    Parser --> Controller
    Controller --> ExtExtractor
    ExtExtractor --> Override
    Override --> NormPipeline
    NormPipeline --> TruncReplace

    TruncReplace --> D1{"--dry-run?"}
    D1 -->|yes| Logger
    D1 -->|no| FSModule
    FSModule -->|rename/copy| Logger
    Logger --> Controller
    Controller --> Summary["Print Summary & Exit"]:::io

    Parser --> ArgsLib
    NormPipeline --> UnicodeLib
    FSModule --> StdFS

    classDef processing fill:#E6F0FF,stroke:#1E90FF,color:#000
    classDef io fill:#E6FFE6,stroke:#32CD32,color:#000
    classDef external fill:#FFF4E6,stroke:#FFA500,color:#000
    classDef docs fill:#F0F0F0,stroke:#A9A9A9,color:#000
    classDef cloud fill:#F5F5F5,stroke:#808080,color:#000

    click Parser "https://github.com/sukulent/namefix/blob/master/src/args.hxx"
    click ArgsLib "https://github.com/sukulent/namefix/blob/master/src/args.hxx"
    click Controller "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click ExtExtractor "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click Override "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click NormPipeline "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click TruncReplace "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click FSModule "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click Logger "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click UnicodeLib "https://github.com/sukulent/namefix/tree/master/makefile"
    click StdFS "https://github.com/sukulent/namefix/blob/master/src/main.cpp"
    click Build "https://github.com/sukulent/namefix/tree/master/makefile"
    click README "https://github.com/sukulent/namefix/blob/master/README.md"
    click CHANGELOG "https://github.com/sukulent/namefix/blob/master/CHANGELOG.md"
    click LICENSE "https://github.com/sukulent/namefix/blob/master/LICENSE.md"
    click MAN "https://github.com/sukulent/namefix/blob/master/man/namefix.1"
```
