# uliprantz/signagedisplayhpi architecture

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

- Interactive diagram: https://gitdiagram.com/uliprantz/signagedisplayhpi
- Repository: https://github.com/uliprantz/signagedisplayhpi

## Overview

- USB Insertion & Storage Monitoring: Represent the USB ports which, when a device is inserted, serve as the trigger for the process.
- PDF File Handler: This component is responsible for scanning the USB’s file system for the PDF, checking its name against the “allowed” list, and preparing it for the next stage.
- Signature Verification Module: Highlight the segment of the script (within SignageDisplay.py) that uses a public key on the Pi to verify the PDF’s signature before display.
- Renderer: Show how the validated PDF is rendered to the screen using direct access to the framebuffer (via tools like “fbi”).
- Service/Startup Management: Indicate how the systemd service (SignageDisplay.service) and startup_script.sh are used to integrate and auto-launch the script on boot.
- Dependency & Environment Setup: Optionally include a block for “Python Dependencies” (from requirements.txt and pip3 command) and OS-level configuration (e.g. mounting USB, frame buffer access, user groups).

##### Relationships and Data Flow
- File handler to the “Signature Verification Module” to show that the PDF is only passed on if verified.
- Overlay a background process managed by the “systemd service” that ensures the SignageDisplay.py script runs automatically at startup.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The key functionalities (USB monitoring, PDF handling, signature verification, and display output) are clearly separated in the code.
- Event-Driven Design: The script reacts to USB insertions, triggering the sequence of operations.
- System Service Integration: Emphasize the use of the systemd service for auto-start functionality and OS-level integration.
- Security: The public key verification step is crucial and should be visually distinct to stress the project’s emphasis on secure file handling.

##### Relevant Technologies and Frameworks
- Python: The project logic is implemented in Python (SignageDisplay.py).
- Systemd: SignageDisplay.service shows how the service is managed.
- fbi: Used to interact with the framebuffer for displaying images/PDF pages.
- Linux (Raspberry Pi OS): The commands and instructions assume usage on Raspbian.
- (Optional) 3D Printing/Case Design: Incorporate references to the RaspberryPiCase STL files to show that hardware casing is part of the overall design.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Startup & Environment Setup
    subgraph "Startup & Environment Setup"
        Dep["Python Dependencies"]:::dependency
        Serv["Systemd Service"]:::service
        Start["Startup Script"]:::service
    end

    %% Application Flow
    subgraph "Application Flow"
        USB["USB Insertion & Storage Monitoring"]:::software
        PDF["PDF File Handler"]:::software
        Verify["Signature Verification Module"]:::software
        Render["Display Renderer"]:::software
    end

    %% Hardware Packaging
    Hardware["Raspberry Pi Case"]:::hardware

    %% Relationships
    Dep --> Serv
    Dep --> Start
    Serv --> USB
    Start --> USB
    USB  --> PDF
    PDF  --> Verify
    Verify --> Render
    Render -->|"renders on"| Hardware

    %% Click Events
    click USB "https://github.com/uliprantz/signagedisplayhpi/blob/main/SignageDisplay.py"
    click PDF "https://github.com/uliprantz/signagedisplayhpi/blob/main/SignageDisplay.py"
    click Verify "https://github.com/uliprantz/signagedisplayhpi/blob/main/SignageDisplay.py"
    click Render "https://github.com/uliprantz/signagedisplayhpi/blob/main/SignageDisplay.py"
    click Serv "https://github.com/uliprantz/signagedisplayhpi/blob/main/SignageDisplay.service"
    click Start "https://github.com/uliprantz/signagedisplayhpi/blob/main/startup_script.sh"
    click Dep "https://github.com/uliprantz/signagedisplayhpi/blob/main/requirements.txt"
    click Hardware "https://github.com/uliprantz/signagedisplayhpi/tree/main/RaspberryPiCase"

    %% Styles
    classDef dependency fill:#f9c74f,stroke:#f9844a,stroke-width:2px;
    classDef software fill:#90be6d,stroke:#43aa8b,stroke-width:2px;
    classDef service fill:#f94144,stroke:#f3722c,stroke-width:2px;
    classDef hardware fill:#577590,stroke:#277da1,stroke-width:2px;
```
