# medveed/autopyuic architecture

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

- Interactive diagram: https://gitdiagram.com/medveed/autopyuic
- Repository: https://github.com/medveed/autopyuic

## Overview

##### Project type and purpose
- From the file tree and README, AutoPyUIC is a small open‑source CLI utility that monitors a directory for Qt Designer `.ui` files and automatically converts them to Python modules using `pyuic5`.

##### File structure
- There are no nested directories:
- `main.py`: the entry point and orchestrator
- `requirements.txt`: declares `watchdog` as the only dependency
- `README.md`: describes usage and purpose
- No explicit config files or build scripts beyond `requirements.txt`.

##### README for additional insights
- Usage is purely via a command‑line interface: `python main.py [directory] [-r]`
- Supports optional recursive mode (`-r`) for sub‑folder monitoring
- Relies on two external libraries/components:
- `watchdog` for file‑system event monitoring
- `pyuic5` (external tool shipped with PyQt5) for conversion

##### Main components and their responsibilities
a. CLI Interface (main.py startup)
- Parses arguments (target directory, recursive flag)
- Initializes the watcher
b. File-System Watcher (using watchdog)
- Observes create/modify events for `.ui` files
- Passes events to the conversion handler
c. Conversion Handler
- Receives file‑change events
- Spawns a subprocess call to `pyuic5 input.ui -o output.py`
- Handles success/failure reporting
d. External Dependencies
- `watchdog` library (Python) for event listening
- `pyuic5` command‑line tool (PyQt5) for UI compilation
e. File-System (monitored target directory)
- Source of incoming `.ui` files and destination for generated `.py` files

##### Relationships and data flow
- User invokes CLI → main.py
- main.py → initializes Watchdog Observer → monitors File System
- Watchdog Observer → on event → Conversion Handler
- Conversion Handler → calls `pyuic5` subprocess → writes `.py` to File System

##### Architectural patterns & design principles
- Single‑responsibility: each module (CLI parsing, watching, conversion) has a clear purpose
- Event-driven: the watcher triggers conversion only on file events
- Extensibility point: you could swap out the Conversion Handler to target different UI frameworks or output formats

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Internal Modules"
        CLI["main.py (CLI Parser)"]:::internal
        OBS["Watchdog Observer\n(recursive flag -r)"]:::internal
        HANDLER["Conversion Handler"]:::internal
    end

    subgraph "External Dependencies"
        WD["watchdog library"]:::external
        PYU["pyuic5 subprocess"]:::external
    end

    FS[("Monitored Directory")]:::filesystem
    DOC["README.md (Project Documentation)"]:::doc

    CLI -->|"initialize"| OBS
    OBS -->|"file-created event"| HANDLER
    HANDLER -->|"pyuic5 -o output.py"| PYU
    PYU -->|"writes .py files"| FS
    WD -->|"provides Observer"| OBS
    CLI -->|"usage info"| DOC

    click CLI "https://github.com/medveed/autopyuic/blob/main/main.py"
    click OBS "https://github.com/medveed/autopyuic/blob/main/main.py"
    click HANDLER "https://github.com/medveed/autopyuic/blob/main/main.py"
    click WD "https://github.com/medveed/autopyuic/blob/main/requirements.txt"
    click DOC "https://github.com/medveed/autopyuic/blob/main/README.md"

    classDef internal fill:#D5E8D4,stroke:#82B366,color:#000
    classDef external fill:#FFF2CC,stroke:#D6B656,color:#000
    classDef filesystem fill:#DAE8FC,stroke:#6C8EBF,color:#000
    classDef doc fill:#E1D5E7,stroke:#9673A6,color:#000
```
