# smpurkis/libre-linkup-py architecture

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

- Interactive diagram: https://gitdiagram.com/smpurkis/libre-linkup-py
- Repository: https://github.com/smpurkis/libre-linkup-py

## Overview

##### Main Components

a. Client Layer:
- This is the main interface class located in src/libre_link_up/client.py

b. External Service Layer:
- Different regional API endpoints as mentioned in the README

c. Data Models Layer:
- Custom types (from custom_types.py)
- Glucose reading data structure

##### Component Relationships

- Client → Authentication Flow (login())
- Client → Data Retrieval Flow (get_latest_reading())
- Data Models ← API Responses
- Environment Configuration → Client

##### Specific Implementation Details

a. Configuration Layer:
- Environment Variables
- Username
- Password
- API URL
- Version

b. Client Operations:
- Authentication
- Glucose Data Retrieval

c. Data Models:
- Glucose Reading
- value
- unix_timestamp
- value_in_mg_per_dl
- high_at_the_time
- low_at_the_time

##### Testing Layer
- A section showing the test coverage (tests/test_client.py)
- Relationship between the client and its test suite

Remember to:
- Use consistent styling
- Version information
- Clear data flow directions

This will provide a comprehensive view of how the library interfaces with the LibreLinkUp API while maintaining its simplicity as a client library.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Client Component]:::client
        L2([External Service]):::external
        L3[(Data Store)]:::data
        L4[Configuration]:::config
        L5[Testing]:::test
    end

    subgraph "Configuration Layer"
        Config[Config Settings]:::config
        EnvVars[Environment Variables]:::config
        click Config "https://github.com/smpurkis/libre-linkup-py/blob/main/pyproject.toml"
    end

    subgraph "Client Layer"
        Client[LibreLinkUpClient]:::client
        CoreInit[Package Initialization]:::client
        click Client "https://github.com/smpurkis/libre-linkup-py/blob/main/src/libre_link_up/client.py"
        click CoreInit "https://github.com/smpurkis/libre-linkup-py/blob/main/src/libre_link_up/__init__.py"
    end

    subgraph "External Services"
        API([LibreLinkUp API]):::external
        EU([EU Endpoint]):::external
        US([US Endpoint]):::external
    end

    subgraph "Data Models Layer"
        DataTypes[Custom Types]:::data
        GlucoseReading[Glucose Reading Model]:::data
        click DataTypes "https://github.com/smpurkis/libre-linkup-py/blob/main/src/libre_link_up/custom_types.py"
    end

    subgraph "Testing Layer"
        TestSuite[Client Tests]:::test
        click TestSuite "https://github.com/smpurkis/libre-linkup-py/blob/main/tests/test_client.py"
    end

    subgraph "Examples Layer"
        BasicUsage[Basic Usage Example]:::example
        GraphExample1[Interactive Glucose Graph]:::example
        GraphExample2[Interactive Logbook Graph]:::example
        click BasicUsage "https://github.com/smpurkis/libre-linkup-py/blob/main/examples/latest_glucose_reading.py"
        click GraphExample1 "https://github.com/smpurkis/libre-linkup-py/blob/main/examples/generate_interactive_glucose_graph.py"
        click GraphExample2 "https://github.com/smpurkis/libre-linkup-py/blob/main/examples/generate_interactive_logbook_graph.py"
    end

    subgraph "CI/CD"
        Format[Code Formatting]:::cicd
        Lint[Code Linting]:::cicd
        TypeCheck[Type Checking]:::cicd
        click Format "https://github.com/smpurkis/libre-linkup-py/blob/main/.github/workflows/format.yml"
        click Lint "https://github.com/smpurkis/libre-linkup-py/blob/main/.github/workflows/lint.yml"
        click TypeCheck "https://github.com/smpurkis/libre-linkup-py/blob/main/.github/workflows/mypy.yml"
    end

    Config --> Client
    EnvVars --> Client
    Client --> API
    API --> EU
    API --> US
    Client --> DataTypes
    DataTypes --> GlucoseReading
    TestSuite --> Client
    Client --> BasicUsage
    Client --> GraphExample1
    Client --> GraphExample2
    CoreInit --> Client
    Format --> Client
    Lint --> Client
    TypeCheck --> Client

    classDef client fill:#a8d1ff,stroke:#333
    classDef external fill:#90EE90,stroke:#333
    classDef data fill:#FFE5B4,stroke:#333
    classDef config fill:#E6E6E6,stroke:#333
    classDef test fill:#FFB6C1,stroke:#333
    classDef example fill:#DDA0DD,stroke:#333
    classDef cicd fill:#98FB98,stroke:#333
```
