# fani-kiran/unity-assetduplicator architecture

> Architecture diagram of the GitHub repository fani-kiran/unity-assetduplicator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fani-kiran/unity-assetduplicator
- Repository: https://github.com/fani-kiran/unity-assetduplicator

## Overview

##### File structure
- Top-level directory only contains:
- DuplicateFolder.py – the single Python script implementing the full logic
- README.md – usage instructions
- No subdirectories or external modules; all functionality lives in DuplicateFolder.py.
- No build configs, no web front-end, no database—this is purely a file‐system CLI tool.

##### README for additional insights
- Requirements: Python 3.5+, Mac OS
- Workflow:
1. Copy target folder out of Unity project
2. Clean it of unwanted assets/scripts
3. Run script with “-i FolderName”
4. Script processes .meta files and assets
5. Copy back into Unity for import

- User (CLI) – issues the command in a shell/terminal
- Argument Parser – reads “-i <folder>” flag
- Folder Copier – makes an in‐memory or on‐disk copy of the input folder
- File Scanner – recursively enumerates all files and .meta files in the copied folder
- GUID Updater – for each .meta file, generates a new GUID and replaces references in YAML
- File Writer – writes updated .meta files and any renamed asset files back to disk
- Logger/Console Output – reports progress and errors to the user
- File System – the host OS directories where the script reads and writes

- User → CLI: “python3 DuplicateFolder.py -i MyAssets”
- CLI → Argument Parser: parse input
- Argument Parser → Folder Copier: provide source folder path
- Folder Copier → File System: read assets, write folder copy
- Folder Copier → File Scanner: hand off new folder for processing
- File Scanner → GUID Updater: pass list of .meta files, asset references
- GUID Updater → File Writer: updated content
- File Writer → File System: write updated files back
- File Writer → Logger: success/failure logs
- Logger → User: prints progress

c. Architectural patterns/principles
- Pipeline pattern: data (folder contents) flows through discrete stages (copy → scan → update → write)
- Single Responsibility Principle: each component has one clear job (parsing, copying, scanning, updating, writing)
- CLI utility pattern: no long-lived processes; single invocation, then exit

d. Key technologies
- Python 3.5+ standard library (argparse, os, shutil, uuid, yaml or custom parsing)
- OS File System on macOS
- Unity .meta file format (YAML GUID field)

##### Elements
- Clear labels for each component/module
– Rectangles for script modules (argument parser, copier, scanner, updater, writer)
- Annotations for key operations (e.g., “generate new GUID,” “replace YAML references,” “write to disk”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User (CLI)"]:::external
    Runtime["Python Runtime & OS"]:::external
    FileSystem(["File System"]):::external
    README["Usage Documentation"]:::external

    subgraph "Unity-AssetDuplicator Pipeline"
        ArgParser["Argument Parser"]:::internal
        FolderCopier["Folder Copier"]:::internal
        FileScanner["File Scanner"]:::internal
        GUIDUpdater["GUID Updater"]:::internal
        FileWriter["File Writer"]:::internal
        Logger["Logger/Console Output"]:::internal
    end

    User -->|"runs script: python3 DuplicateFolder.py -i MyAssets"| Runtime
    Runtime -->|"invokes"| ArgParser
    ArgParser -->|"provides source folder path"| FolderCopier
    FolderCopier -->|"reads/writes"| FileSystem
    FolderCopier -->|"hands off new folder"| FileScanner
    FileScanner -->|"passes .meta files list"| GUIDUpdater
    GUIDUpdater -->|"sends updated content"| FileWriter
    FileWriter -->|"writes files"| FileSystem
    FileWriter -->|"logs status"| Logger
    Logger -->|"prints progress"| User
    User -->|"views docs"| README

    click ArgParser "https://github.com/fani-kiran/unity-assetduplicator/blob/main/DuplicateFolder.py"
    click FolderCopier "https://github.com/fani-kiran/unity-assetduplicator/blob/main/DuplicateFolder.py"
    click FileScanner "https://github.com/fani-kiran/unity-assetduplicator/blob/main/DuplicateFolder.py"
    click GUIDUpdater "https://github.com/fani-kiran/unity-assetduplicator/blob/main/DuplicateFolder.py"
    click FileWriter "https://github.com/fani-kiran/unity-assetduplicator/blob/main/DuplicateFolder.py"
    click Logger "https://github.com/fani-kiran/unity-assetduplicator/blob/main/DuplicateFolder.py"
    click README "https://github.com/fani-kiran/unity-assetduplicator/blob/main/README.md"

    classDef internal fill:#bbf,stroke:#333,stroke-width:1px
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
```
