# mrfrazer25/enhanced-hibp-checker architecture

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

- Interactive diagram: https://gitdiagram.com/mrfrazer25/enhanced-hibp-checker
- Repository: https://github.com/mrfrazer25/enhanced-hibp-checker

## Overview

##### Project Type and Purpose
- Enhanced HIBP Checker is a Python-based desktop application (not a web app or microservice).
- It bundles a user interface (PyQt6 + embedded HTML/JS) with a core logic module that (a) checks “Have I Been Pwned” via HTTP, (b) stores the HIBP API key securely in the OS keyring, and (c) forwards prompts/data to a local Ollama AI instance for cybersecurity advice.

##### File‐Structure Analysis
- Top-level files:
– main.py (application entry point)
– requirements.txt (dependencies)
– core/ (business logic)
- hibp_client.py (HTTP client for the HIBP API)
- secure_storage.py (wraps OS keyring for API key)
- __init__.py
– ui/ (presentation layer)
- main_window.py (PyQt6 window, tab management)
- styles.py (GUI styling)
- html/ (embedded web chat view)
– chat_template.html
– chat_logic.js
- __init__.py

##### README Insights
- Describes three main user flows: (1) settings (store/retrieve API key + Ollama endpoint & model), (2) HIBP breach checks, (3) AI-powered advisor via local Ollama.
- Emphasizes local processing, secure key storage, and no external data collection beyond HIBP and local Ollama.

a. Main Components (highest level):
1. User (actor)
2. Desktop Application Container
– UI Module (PyQt6 + embedded HTML/JS)
– Core Module (HIBP client + secure key storage + Ollama client)
3. External Services
– Have I Been Pwned REST API
– Local Ollama HTTP API (running on localhost)
– OS Keyring (Windows Credential Manager / macOS Keychain / Linux Secret Service)
b. Relationships & Data Flow:
- UI ←→ Core: method calls in Python
- Core → OS Keyring: store/retrieve HIBP API key
- Core → HIBP API: HTTP GET/POST for breach checks
- Core → Local Ollama: HTTP POST to /api/generate with user queries or breach details
c. Architectural Patterns:
- Separation of concerns (UI vs. business logic) akin to MVC
- Client‐side HTTP clients for third‐party services
- Local first / offline AI invocation
d. Key Technologies:
- Python 3.7+ with PyQt6 (UI)
- Requests (HTTP)
- Keyring (secure storage)
- Ollama local API (AI)
- Embedded HTML + JS for chat view

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::actor
    subgraph "Desktop Application"
        subgraph "UI Module"
            UIInit["__init__.py"]:::internal
            MainWindow["main_window.py"]:::internal
            Styles["styles.py"]:::internal
            ChatHTML["chat_template.html"]:::internal
            ChatJS["chat_logic.js"]:::internal
        end
        subgraph "Core Module"
            CoreInit["__init__.py"]:::internal
            HIBPClient["hibp_client.py"]:::internal
            SecureStorage["secure_storage.py"]:::internal
            OllamaClient["Ollama Client"]:::internal
        end
        Dependencies["requirements.txt"]:::internal
        Docs["README.md"]:::internal
    end
    ExternalServicesKeyring["OS Keyring"]:::external
    ExternalServicesHIBP["Have I Been Pwned API"]:::external
    ExternalServicesOllama["Local Ollama API"]:::external

    User --> MainWindow
    MainWindow --> HIBPClient
    MainWindow --> SecureStorage
    MainWindow --> OllamaClient
    HIBPClient --> ExternalServicesHIBP
    SecureStorage --> ExternalServicesKeyring
    OllamaClient --> ExternalServicesOllama

    click MainWindow "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/ui/main_window.py"
    click Styles "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/ui/styles.py"
    click ChatHTML "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/ui/html/chat_template.html"
    click ChatJS "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/ui/html/chat_logic.js"
    click UIInit "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/ui/__init__.py"
    click HIBPClient "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/core/hibp_client.py"
    click SecureStorage "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/core/secure_storage.py"
    click CoreInit "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/core/__init__.py"
    click Dependencies "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/requirements.txt"
    click Docs "https://github.com/mrfrazer25/enhanced-hibp-checker/blob/main/README.md"

    classDef internal fill:#ADD8E6,stroke:#000
    classDef external fill:#90EE90,stroke:#000
    classDef actor fill:#FFD700,stroke:#000,stroke-width:2px
```
