# migueloomar/password-generator architecture

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

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

## Overview

##### Project Type and Purpose
- This is a standalone, full-featured desktop application—a secure password generator and manager—with a modern GUI, cryptographic storage, and real-time strength analysis.

##### File Structure
- gui.py: Presentation layer (TtkBootstrap GUI widgets)
- main.py: Application entry point and high-level controller
- generator.py: Core password-generation logic (uses Python’s secrets)
- strength_checker.py: Password-strength analysis (wraps zxcvbn)
- storage.py: AES-256 encrypted vault read/write, key-file management
- requirements.txt: External dependencies (ttkbootstrap, cryptography, zxcvbn, etc.)

##### Extract Key Architectural Insights from README
- CSPRNG password gen
- AES-256 encrypted vault with separate key file
- Clipboard integration, tabular viewer, cross-platform GUI

##### Main Components
A. Presentation Layer (GUI)
- GUI Window & Widgets (gui.py)
- Themed via TtkBootstrap
- User events: “Generate,” “Check Strength,” “Save,” “Load,” “Copy”

B. Controller / Application Layer
- main.py: orchestrates GUI ↔ business modules

C. Business Logic Layer
1. PasswordGenerator (generator.py)
– CSPRNG via secrets module
– Configurable charset & length
2. StrengthChecker (strength_checker.py)
– wraps zxcvbn library
– returns score (0–4) + feedback

D. Data Layer
- StorageManager (storage.py)
– AES-256 encryption (cryptography library)
– Vault file + separate key file
– CRUD operations on stored credentials

E. External Services & OS Integrations
- Clipboard (pyperclip or OS APIs)
- File System (vault/key files)
- Python Standard Library (secrets, os, json, etc.)

##### Component Interactions and Data Flow
1. User clicks “Generate” → GUI calls PasswordGenerator → returns plaintext password → GUI displays in entry
3. On “Save” → GUI calls StorageManager.encrypt_and_store → vault file updated
4. On “Load” → GUI calls StorageManager.read_and_decrypt → populates table view
5. “Copy” action → GUI invokes Clipboard API

##### Architectural Patterns & Design Principles
- Separation of Concerns: distinct modules for GUI, logic, and storage
- Single Responsibility Principle: each .py handles one domain
- Layered Architecture: Presentation → Controller → Business → Data
- Dependency Injection (lightweight): main.py wires GUI to modules
- Security-focused: CSPRNG, AES-256, memory-safe handling

##### Technologies & Frameworks to Annotate
- Python 3.8+
- TtkBootstrap (Journal theme)
- secrets, cryptography (AES-256)
- zxcvbn (Dropbox’s estimator)
- pyperclip/OS clipboard
- JSON or SQLite (if used) for vault structure

##### Essential Elements
- Clear labels for each module (GUI, Generator, StrengthChecker, StorageManager)
- Notes on security (AES-256, CSPRNG) near relevant components
- Optional: show file names inside blocks or in a sidebar

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        GUI["GUI Window & Widgets\ngui.py"]:::presentation
    end

    Main["Main Controller\nmain.py"]:::presentation

    subgraph "Business Logic"
        Gen["PasswordGenerator\ngenerator.py"]:::business
        Strength["StrengthChecker\nstrength_checker.py"]:::business
    end

    subgraph "Data Layer"
        Storage["StorageManager\nstorage.py"]:::data
    end

    subgraph "External Services"
        Clipboard["Clipboard API"]:::external
        FS["File System"]:::external
        Crypto["cryptography (AES-256)"]:::external
        Zxcvbn["zxcvbn"]:::external
        Secrets["secrets"]:::external
    end

    GUI -->|"1.generate()"| Main
    Main -->|"calls generate()"| Gen
    Gen -->|"password"| Main
    Main -->|"returns password"| GUI

    GUI -->|"2.check_strength()"| Main
    Main -->|"calls check()"| Strength
    Strength -->|"score & feedback"| Main
    Main -->|"updates meter"| GUI

    GUI -->|"3.encrypt_and_store()"| Storage
    Storage -->|"reads/writes vault"| FS
    Storage -->|"uses"| Crypto
    Storage -->|"returns status"| GUI

    GUI -->|"4.read_and_decrypt()"| Storage
    Storage -->|"reads vault"| FS
    Storage -->|"uses"| Crypto
    Storage -->|"credentials data"| GUI

    GUI -->|"5.copy()"| Clipboard

    Gen -->|"uses"| Secrets
    Strength -->|"uses"| Zxcvbn

    click GUI "https://github.com/migueloomar/password-generator/blob/main/gui.py"
    click Main "https://github.com/migueloomar/password-generator/blob/main/main.py"
    click Gen "https://github.com/migueloomar/password-generator/blob/main/generator.py"
    click Strength "https://github.com/migueloomar/password-generator/blob/main/strength_checker.py"
    click Storage "https://github.com/migueloomar/password-generator/blob/main/storage.py"

    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef business fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
