# tanvirtian/password-generator architecture

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

- Interactive diagram: https://gitdiagram.com/tanvirtian/password-generator
- Repository: https://github.com/tanvirtian/password-generator

## Overview

##### Project Type and Purpose
- This is a standalone desktop GUI application written in Python3, using PyQt5 for the interface (with optional Tkinter references) that generates secure passwords.
- Core use cases: random password generation, real-time strength evaluation, copy to clipboard, password history management, QR-code generation, and theme selection.

##### File Structure
- main.py: entry point, glues together UI, business logic, and data management.
- styles/*.qss: Qt style sheets defining multiple themes.
- README.md: describes features, dependencies (qrcode, pyperclip), installation, and usage.

##### Architectural Patterns
- Model-View-Controller (MVC) style separation:
- View: PyQt5 widgets defined/instantiated in main.py
- Controller: event handlers in main.py that react to user actions
- Model/Service: password engine, strength evaluator, history manager, QR-code generator abstractions
- No external server or database—history likely stored in memory or a local file.

##### Main Components to Capture
A. User (end-user sitting at desktop)
B. Presentation Layer (PyQt5 GUI)
- View components (windows, buttons, text fields)
- Style loader (.qss files)
C. Controller Layer (event handlers in main.py)
- Routes UI events to services
D. Core Services
1. Password Generator Service
- Uses Python’s random/secrets to build string
2. Strength Evaluator
- Applies rules to rate strength in real time
3. History Manager
- Maintains list (in-memory or simple local file storage)
4. QR-Code Generator
- Wraps ‘qrcode’ library to produce QR images
5. Clipboard Adapter
- Wraps ‘pyperclip’ for copy/paste
E. Assets & Configuration
- Style sheet files (.qss)
F. External Dependencies
- PyQt5
- qrcode
- pyperclip

##### Interactions and Data Flow
1. User clicks “Generate”
2. Controller calls Password Generator → returns string
3. Controller passes string to Strength Evaluator → returns metric
4. Controller pushes string into History Manager
5. UI updates view: displays password + strength bar + history list
6. User clicks “Copy” → Controller invokes Clipboard Adapter
7. User clicks “QR Code” → Controller invokes QR-Code Generator → UI displays image

##### Architectural Patterns & Principles
- MVC / separation of concerns:
- Keep pure logic (generation, evaluation, storage) decoupled from UI code
- Single-responsibility per module:
- One service per feature (e.g., QR service only handles QR)
- Assets/configuration externalized:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User(["End User"]):::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        GUI["PyQt5 GUI Views"]:::presentation
        Controller["Controller (Event Handlers)"]:::presentation
    end

    %% Core Services
    subgraph "Core Services"
        PasswordGenerator["Password Generator Service"]:::service
        StrengthEvaluator["Strength Evaluator"]:::service
        HistoryManager["History Manager"]:::service
        QRCodeGenerator["QR-Code Generator"]:::service
        ClipboardAdapter["Clipboard Adapter"]:::service
    end

    %% Assets & Configuration
    subgraph "Assets & Configuration"
        Themes["Themes (.qss files)"]:::assets
        Icons["Icons"]:::assets
    end

    %% External Dependencies
    subgraph "External Libraries"
        PyQt5["PyQt5"]:::external
        QRLib["qrcode"]:::external
        Pyperclip["pyperclip"]:::external
    end

    %% Data Flow
    User --> GUI
    GUI -->|"generate_password()"| PasswordGenerator
    PasswordGenerator -->|"password: str"| StrengthEvaluator
    StrengthEvaluator -->|"strength metric"| GUI
    PasswordGenerator -->|"new entry"| HistoryManager
    HistoryManager -->|"history data"| GUI
    GUI -->|"copy()"| ClipboardAdapter
    GUI -->|"generate_qr()"| QRCodeGenerator
    QRCodeGenerator -->|"QR image"| GUI

    %% Asset Loading
    Themes --- GUI
    Icons --- GUI

    %% Dependency Links
    GUI --- PyQt5
    QRCodeGenerator --- QRLib
    ClipboardAdapter --- Pyperclip

    %% Click Events
    click GUI "https://github.com/tanvirtian/password-generator/blob/main/main.py"
    click Controller "https://github.com/tanvirtian/password-generator/blob/main/main.py"
    click PasswordGenerator "https://github.com/tanvirtian/password-generator/blob/main/main.py"
    click StrengthEvaluator "https://github.com/tanvirtian/password-generator/blob/main/main.py"
    click HistoryManager "https://github.com/tanvirtian/password-generator/blob/main/main.py"
    click QRCodeGenerator "https://github.com/tanvirtian/password-generator/blob/main/main.py"
    click ClipboardAdapter "https://github.com/tanvirtian/password-generator/blob/main/main.py"
    click Themes "https://github.com/tanvirtian/password-generator/tree/main/styles/"
    click Icons "https://github.com/tanvirtian/password-generator/tree/main/icons/"
    click README "https://github.com/tanvirtian/password-generator/blob/main/README.md"

    %% Styles
    classDef presentation fill:#D6EAF8,stroke:#1B4F72
    classDef service fill:#D5F5E3,stroke:#196F3D
    classDef assets fill:#E5E7E9,stroke:#424949
    classDef external fill:#FCF3CF,stroke:#B7950B
```
