# naposky/slack-plexautoupdate architecture

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

- Interactive diagram: https://gitdiagram.com/naposky/slack-plexautoupdate
- Repository: https://github.com/naposky/slack-plexautoupdate

## Overview

##### Project type and purpose
- This is a small, CLI‐based automation tool (shell + Python) to automatically fetch, build, upgrade, and restart Plex Media Server on a Slackware system. It is neither a full‐stack web app nor a microservice; rather, it’s a scheduled automation utility that ties together:
- Cron for scheduling
- Shell and Python scripts for control flow
- SlackBuild packaging for building .deb → Slackware package
- Slackware’s upgradepkg for installation
- Optional Pushbullet for notifications

##### File structure
- Top-level files:
- autoCatch.sh — main shell driver, intended to be cron’d
- autoUpgrade.py — core logic for fetching latest version, enforcing retention policy
- plexmediaserver.SlackBuild — SlackBuild script for building the package
- rc.plexmediaserver — init/script to start & stop the Plex service
- doinst.sh — (standard SlackBuild “do install” script fragment)
- README.md — project overview & instructions
- plexmediaserver.SlackBuild, doinst.sh, rc.plexmediaserver follow Slackware packaging conventions

##### Key behaviors from README
- autoCatch.sh performs:
a) Call autoUpgrade.py
b) Download .deb from Plex repository (with optional PlexPass token)
c) Invoke plexmediaserver.SlackBuild to convert .deb → Slackware package
d) Call upgradepkg to install
e) Restart Plex via rc.plexmediaserver
f) Optionally send a Pushbullet notification
g) Prune old versions, keep N (default 5)

##### Components to put
a. Cron scheduler (external trigger)
b. autoCatch.sh (Shell orchestrator)
c. autoUpgrade.py (Python logic module)
d. Plex repository API (external service)
e. Local file system / working directory (holding downloaded .deb, built packages, version directories)
f. SlackBuild tooling (plexmediaserver.SlackBuild + doinst.sh)
g. Slackware package manager (upgradepkg)
h. init script (rc.plexmediaserver)
i. Optional Pushbullet API (external notification service)

##### Relationships & data flow
1. Cron → triggers autoCatch.sh
2. autoCatch.sh → invokes autoUpgrade.py
3. autoUpgrade.py → HTTP GET to Plex repo API → receives .deb
4. autoUpgrade.py → writes .deb to local FS
5. autoCatch.sh → calls plexmediaserver.SlackBuild → builds Slackware package
6. autoCatch.sh → calls upgradepkg → installs new Plex package
7. autoCatch.sh → calls rc.plexmediaserver restart → Plex service cycles
8. autoCatch.sh → optionally calls sendNotification → Pushbullet API
9. autoUpgrade.py → also performs cleanup on local FS (prune old builds)

##### Architectural patterns & design principles
- Modular separation: Shell script for orchestration, Python script for version logic
- Single-responsibility: SlackBuild script solely handles packaging, rc script solely handles service management
- External integration points: HTTP APIs (Plex repo, Pushbullet), OS package manager
- Idempotency & scheduling: Designed to run unattended via cron
- Retention policy implemented in code rather than external system

##### Final advice
- Be **very detailed**: include every script and its role
- Optional paths (e.g., Pushbullet branch)
- Boundaries: external vs. host
- Don’t overcomplicate: this is a linear, cron‐based automation

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Services
    Cron["Cron Scheduler"]:::external
    PlexRepo["Plex Repository API"]:::external
    PushNotif["Pushbullet API"]:::external
    README["README.md"]:::doc

    %% Slackware Server Boundary
    subgraph "Slackware Server"
        direction TB
        Orchestrator["autoCatch.sh"]:::orchestration
        Python["autoUpgrade.py"]:::orchestration
        SlackBuildScript["plexmediaserver.SlackBuild"]:::packaging
        DoInst["doinst.sh"]:::packaging
        Upgradepkg["upgradepkg"]:::packaging
        InitScript["rc.plexmediaserver"]:::service
        Storage["Local File System\n(.deb & build artifacts)"]:::storage
    end

    %% Flow
    Cron -->|"triggers"| Orchestrator
    Orchestrator -->|"invokes"| Python
    Python -->|"HTTP GET .deb"| PlexRepo
    PlexRepo -->|"returns .deb"| Python
    Python -->|"writes .deb"| Storage
    Orchestrator -->|"calls build"| SlackBuildScript
    SlackBuildScript -->|"uses install fragment"| DoInst
    SlackBuildScript -->|"outputs package"| Storage
    Orchestrator -->|"calls install"| Upgradepkg
    Upgradepkg -->|"installs package"| Storage
    Orchestrator -->|"restarts service"| InitScript
    Orchestrator -->|"optional notify"| PushNotif
    Python -->|"cleanup prune"| Storage

    %% Documentation Reference
    Orchestrator -.->|uses instructions| README

    %% Click Events
    click Orchestrator "https://github.com/naposky/slack-plexautoupdate/blob/master/autoCatch.sh"
    click Python "https://github.com/naposky/slack-plexautoupdate/blob/master/autoUpgrade.py"
    click SlackBuildScript "https://github.com/naposky/slack-plexautoupdate/blob/master/plexmediaserver.SlackBuild"
    click DoInst "https://github.com/naposky/slack-plexautoupdate/blob/master/doinst.sh"
    click InitScript "https://github.com/naposky/slack-plexautoupdate/blob/master/rc.plexmediaserver"
    click README "https://github.com/naposky/slack-plexautoupdate/blob/master/README.md"

    %% Styles
    classDef orchestration fill:#AED6F1,stroke:#1B4F72,color:#17202A
    classDef packaging fill:#ABEBC6,stroke:#145A32,color:#17202A
    classDef external fill:#E5E7E9,stroke:#566573,color:#17202A
    classDef storage fill:#FAD7A0,stroke:#7D6608,color:#17202A
    classDef service fill:#F9E79F,stroke:#935116,color:#17202A
    classDef doc fill:#D2B4DE,stroke:#4A235A,color:#17202A
```
