# swsphn/pmhclib architecture

> Architecture diagram of the GitHub repository swsphn/pmhclib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/swsphn/pmhclib
- Repository: https://github.com/swsphn/pmhclib

## Overview

##### Main Components

a) Client Application Layer:
- User's Python application that implements pmhclib
- As the topmost component

b) pmhclib Core:
- Central component showing the main PMHC class (from pmhc.py)
- Authentication handling subsystem
- Environment variables integration

c) External Dependencies:
- Playwright browser automation
- TOTP authentication system
- PMHC MDS Portal API (external system)

##### Component Relationships

- Top-down architecture showing data flow
- Authentication flow separate from main API operations
- Clear distinction between library components and external services

##### Specific Implementation Details

1. User Application (Top)
2. pmhclib Interface Layer
- Context Manager implementation
- Environment variables handler
3. Authentication Layer
- Playwright Browser Automation
- TOTP Generator
- Credentials Manager
4. API Communication Layer
5. PMHC MDS Portal (Bottom)

##### Specific Flows to Highlight

a) Authentication Flow:
- User App → pmhclib → Credentials Manager → Playwright → PMHC Portal
- ↳ TOTP Generator ↗

b) API Operations Flow:
- User App → pmhclib → PMHC Portal API

##### Additional Elements

Annotations for:
- Environment variables (PMHC_USERNAME, PMHC_PASSWORD, PMHC_TOTP_SECRET)
- Context manager boundaries
- Browser automation scope
- API endpoints

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef userApp fill:#FFE5CC,stroke:#FF9933
    classDef core fill:#CCE5FF,stroke:#3399FF
    classDef security fill:#FFB3B3,stroke:#FF6666
    classDef external fill:#D9F2D9,stroke:#5CD65C
    classDef interface fill:#E5CCFF,stroke:#9933FF
    classDef docs fill:#F2F2F2,stroke:#808080

    %% Main Components
    Client["Client Application"]:::userApp
    Interface["Package Interface Layer"]:::interface
    PMHCLib["pmhclib Core"]:::core
    AuthSystem["Authentication Layer"]:::security
    
    %% Authentication Components
    subgraph Auth["Authentication Components"]
        Playwright["Playwright Browser\nAutomation"]:::external
        TOTP["TOTP Generator"]:::security
        CredManager["Credentials Manager"]:::security
    end
    
    %% External Systems
    Portal["PMHC MDS Portal"]:::external
    
    %% Documentation and Config
    subgraph Support["Documentation & Configuration"]
        Docs["System Documentation"]:::docs
        Config["Project Configuration"]:::docs
        DocsBuild["Documentation Build"]:::docs
        CICD["CI/CD Pipeline"]:::docs
    end

    %% Relationships
    Client --> Interface
    Interface --> PMHCLib
    PMHCLib --> AuthSystem
    AuthSystem --> Playwright
    AuthSystem --> TOTP
    AuthSystem --> CredManager
    Playwright --> Portal
    PMHCLib --> Portal
    
    %% Click Events
    click PMHCLib "https://github.com/swsphn/pmhclib/blob/master/src/pmhclib/pmhc.py"
    click Interface "https://github.com/swsphn/pmhclib/blob/master/src/pmhclib/__init__.py"
    click Docs "https://github.com/swsphn/pmhclib/blob/master/docs/index.md"
    click Config "https://github.com/swsphn/pmhclib/blob/master/pyproject.toml"
    click DocsBuild "https://github.com/swsphn/pmhclib/blob/master/docs/conf.py"
    click CICD "https://github.com/swsphn/pmhclib/blob/master/.github/workflows/sphinx-gh-pages.yml"

    %% Legend
    subgraph Legend
        L1["User Components"]:::userApp
        L2["Core Library"]:::core
        L3["Security Components"]:::security
        L4["External Systems"]:::external
        L5["Interface Layer"]:::interface
        L6["Documentation"]:::docs
    end
```
