# tousef-refuge/minecraft-backup-management architecture

> Architecture diagram of the GitHub repository tousef-refuge/minecraft-backup-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tousef-refuge/minecraft-backup-management
- Repository: https://github.com/tousef-refuge/minecraft-backup-management

## Overview

This is a **Python desktop GUI utility** for managing **Minecraft saves/backups** on a local machine. It is not a client/server system; its “backend” is primarily **local filesystem orchestration** (reading/writing directories, extracting zip backups, tracking world numbers/history) driven by GUI “windows” (dialogs).

- **GUI window flow** (what screens exist and how they invoke operations)
- **Core domain logic modules** (zip extraction, cleanup, history tracking)
- **Key filesystem resources** (Minecraft directories, backup zips, history/config state)
- **Packaging/entrypoint** (how it’s launched: `python -m app`)

##### Entrypoints / App bootstrap
- `app/__main__.py` → module entrypoint for `python -m app`
- `app/main.py` → likely initializes GUI root, app lifecycle, loads settings, constructs main window
- `app/__init__.py` → package init (may define version/exports)
- `pyproject.toml` → packaging/build metadata (editable install `pip install -e .`)

##### Domain / Core logic layer
- `app/logic/zip_extractor.py` → extraction and restore workflows (zip→world folder), likely the “speedrun fixed seed restore” loop
- `app/logic/world_history.py` → tracking world numbers/history (persistence mechanism to be shown as a data store)
- `app/logic/dir_check.py` → validation of directory structure/paths (Minecraft folder, backups folder)
- `app/logic/regex_funcs.py` → parsing world names/numbers, matching backup naming patterns

##### Settings / Configuration
- `app/settings/settings_list.py` → central definition of settings keys/defaults
- `app/settings/__init__.py` → settings package entry
- Window-specific config modules:
- `backup_extract/config.py`
- `backup_cleanup/config.py`
These are important because they imply **per-feature configuration** (paths, toggles like “do not permanently delete”).

##### Paths / environment integration
- `app/paths.py` → canonical path resolution (project dir, `.minecraft` path, saves, backups, config files)

##### Application/Domain Logic: `zip_extractor`, `world_history`, `dir_check`, `regex_funcs`
3. **Infrastructure**: `paths`, “Settings store”, “History store”, filesystem adapters (even if implicit via stdlib)

Key dependencies to show:
- GUI windows → call logic modules
- Logic modules → use `paths.py` + filesystem
- Feature config modules → read/write settings store
- `world_history.py` → reads/writes history store
- `regex_funcs.py` → used by `zip_extractor` and/or `world_history`

##### Automatic backup extraction
- User → `backup_extract/dialog.py` (select backup/world/options)
- Dialog → `backup_extract/config.py` (load config)
- Dialog → `dir_check.py` (validate dirs)
- Dialog → `zip_extractor.py` (extract)
- `zip_extractor.py` → filesystem (read zip, write world folder)
- `zip_extractor.py` → `world_history.py` (update world number/history)
- `zip_extractor.py` → audio (`confirm.wav`)
- Dialog → `backup_extract/status.py` (progress/complete)

##### Backup folder cleanup
- User → `backup_cleanup/dialog.py`
- Dialog → `backup_cleanup/config.py` (load “permanent delete” toggle, target folder)
- Dialog → `dir_check.py`
- Dialog → cleanup logic (if implemented in dialog or separate; from tree it’s likely in dialog/status)
- Cleanup → filesystem (delete/move redundant backups)
- Dialog → `backup_cleanup/status.py`

##### Clear history
- User → `clear_history/dialog.py`
- Dialog → `world_history.py` (clear persisted history)
- `world_history.py` → history store (delete/reset file)

##### Relationships & interactions to explicitly capture
Because this is a local tool, accuracy comes from documenting **which modules own which responsibilities** and **what state is persisted**.

- **World history store** (used by `world_history.py`)
- **Minecraft directories**:
- `.minecraft/saves/<world>` (extraction target)
- backups directory containing `.zip` files

Cross-cutting concerns:
- **Validation**: `dir_check.py` gates operations before destructive actions
- **Parsing/naming**: `regex_funcs.py` drives detection of “world number” and redundant backups

- `app/windows/*`
- `app/logic/*`
- `app/settings/*`
- `app/paths.py`
- persisted stores + Minecraft folders

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% Context (System Overview)
%% =========================
subgraph "System Context (Local Desktop Utility)"
direction TB
User["User"]:::external

subgraph "Minecraft Backup Management (Desktop App)"
direction TB
AppPkg["Python Package: app"]:::container
end

subgraph "Local Machine Resources"
direction TB

FS["Local Filesystem"]:::external

subgraph "Minecraft Directories"
direction TB
MCFolder[".minecraft/ (folder)"]:::folder
SavesFolder["saves/ (folder)"]:::folder
WorldFolders["<world> folders"]:::folder
end

BackupsFolder["Backup Zips Directory (folder)"]:::folder

subgraph "Persisted App State (Files)"
direction TB
SettingsFile[("Settings Store (file)")]:::store
HistoryFile[("World History Store (file)")]:::store
end

Textures["UI Textures (assets folder)"]:::asset
end

OSShell["OS Shell / File Explorer"]:::sideeffect
AudioDevice["Audio Playback"]:::sideeffect
ConfirmWav["confirm.wav"]:::asset

User -->|"clicks/buttons"| AppPkg
AppPkg <-->|"read/write"| FS
AppPkg -->|"open_folder"| OSShell
AppPkg -->|"play_confirm"| AudioDevice
AudioDevice -->|"plays"| ConfirmWav

MCFolder --> SavesFolder
SavesFolder --> WorldFolders
end

AppPkg -.->|"reads/writes"| SettingsFile
AppPkg -.->|"reads/writes"| HistoryFile
AppPkg <-->|"extract_to"| WorldFolders
AppPkg <-->|"read_zips"| BackupsFolder
AppPkg -->|"load_assets"| Textures

%% =========================
%% Module / Component Diagram
%% =========================
subgraph "Module Architecture (Repo-aligned)"
direction TB

subgraph "Entrypoint & Bootstrap"
direction TB
PyProject["pyproject.toml"]:::meta
AppInit["app/__init__.py"]:::module
MainMod["app/main.py"]:::module
MainEntry["app/__main__.py"]:::module
end

subgraph "Presentation (GUI Windows)"
direction TB
MainWindow["windows/main_window.py"]:::gui
WindowBuild["windows/window_build.py"]:::gui

subgraph "Backup Extract (Feature Windows)"
direction TB
ExtractDialog["backup_extract/dialog.py"]:::gui
ExtractConfig["backup_extract/config.py"]:::config
ExtractStatus["backup_extract/status.py"]:::gui
end

subgraph "Backup Cleanup (Feature Windows)"
direction TB
CleanupDialog["backup_cleanup/dialog.py"]:::gui
CleanupConfig["backup_cleanup/config.py"]:::config
CleanupStatus["backup_cleanup/status.py"]:::gui
end

subgraph "Clear History (Feature Window)"
direction TB
ClearHistoryDialog["clear_history/dialog.py"]:::gui
end
end

subgraph "Domain / Core Logic"
direction TB
ZipExtractor["logic/zip_extractor.py"]:::module
WorldHistory["logic/world_history.py"]:::module
DirCheck["logic/dir_check.py"]:::module
RegexFuncs["logic/regex_funcs.py"]:::module
end

subgraph "Infrastructure"
direction TB
Paths["app/paths.py"]:::infra
SettingsList["settings/settings_list.py"]:::module
SettingsInit["settings/__init__.py"]:::module
end

%% Bootstrap wiring
MainEntry -->|"python -m app"| MainMod
MainMod -->|"init_GUI"| MainWindow
MainMod -->|"load_settings_defaults"| SettingsList
AppInit -->|"package_exports"| MainMod
PyProject -->|"packaging_metadata"| MainEntry

%% GUI composition
MainWindow -->|"build_widgets"| WindowBuild
ExtractDialog -->|"shared_widgets"| WindowBuild
CleanupDialog -->|"shared_widgets"| WindowBuild
ClearHistoryDialog -->|"shared_widgets"| WindowBuild

%% GUI -> logic calls
ExtractDialog -->|"validate_dirs"| DirCheck
ExtractDialog -->|"extract_backup"| ZipExtractor
ExtractDialog -->|"show_progress"| ExtractStatus
ExtractDialog -->|"load/save_config"| ExtractConfig

CleanupDialog -->|"validate_dirs"| DirCheck
CleanupDialog -->|"cleanup_backups"| RegexFuncs
CleanupDialog -->|"show_progress"| CleanupStatus
CleanupDialog -->|"load/save_config"| CleanupConfig

ClearHistoryDialog -->|"clear_history"| WorldHistory

%% Logic collaboration
ZipExtractor -->|"parse_world_names"| RegexFuncs
ZipExtractor -->|"update_history"| WorldHistory
WorldHistory -->|"parse_world_numbers"| RegexFuncs

%% Infra dependencies
ExtractDialog -->|"resolve_paths"| Paths
CleanupDialog -->|"resolve_paths"| Paths
ZipExtractor -->|"resolve_paths"| Paths
WorldHistory -->|"resolve_paths"| Paths
DirCheck -->|"resolve_paths"| Paths

ExtractConfig -->|"settings_keys/defaults"| SettingsList
CleanupConfig -->|"settings_keys/defaults"| SettingsList
SettingsInit -->|"exports"| SettingsList

%% Persistence & filesystem (dashed = read/write state)
ExtractConfig -.->|"read/write"| SettingsFile
CleanupConfig -.->|"read/write"| SettingsFile
WorldHistory -.->|"read/write"| HistoryFile

ZipExtractor -.->|"read_zip"| BackupsFolder
ZipExtractor -.->|"write_world_folder"| WorldFolders
CleanupDialog -.->|"delete/move_backups"| BackupsFolder
DirCheck -.->|"check_exists"| MCFolder
DirCheck -.->|"check_exists"| BackupsFolder

%% Side effects/assets
ZipExtractor -->|"play_confirm"| ConfirmWav
MainWindow -->|"open_in_explorer"| OSShell
MainWindow -->|"load_assets"| Textures
end

%% =========================
%% Sequence: Backup Extraction
%% =========================
subgraph "Sequence: Automatic Backup Extraction"
direction TB
U1["User"]:::external
S1["backup_extract/dialog.py"]:::gui
S2["backup_extract/config.py"]:::config
S3["logic/dir_check.py"]:::module
S4["logic/zip_extractor.py"]:::module
S5["logic/world_history.py"]:::module
S6["backup_extract/status.py"]:::gui

U1 -->|"select_backup/options"| S1
S1 -->|"load_config"| S2
S1 -->|"validate_dirs"| S3
S1 -->|"start_extract"| S4
S4 -.->|"read_zip"| BackupsFolder
S4 -.->|"write_world"| WorldFolders
S4 -->|"update_history"| S5
S5 -.->|"persist"| HistoryFile
S4 -->|"play_sound"| ConfirmWav
S1 -->|"update_progress"| S6
end

%% =========================
%% Sequence: Backup Cleanup
%% =========================
subgraph "Sequence: Backup Folder Cleanup"
direction TB
U2["User"]:::external
C1["backup_cleanup/dialog.py"]:::gui
C2["backup_cleanup/config.py"]:::config
C3["logic/dir_check.py"]:::module
C4["logic/regex_funcs.py"]:::module
C5["backup_cleanup/status.py"]:::gui

U2 -->|"choose_cleanup"| C1
C1 -->|"load_config"| C2
C1 -->|"validate_dirs"| C3
C1 -->|"detect_redundant"| C4
C1 -.->|"delete/move"| BackupsFolder
C1 -->|"update_progress"| C5
end

%% =========================
%% Click Events (from mapping)
%% =========================
click MainEntry "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/__main__.py"
click MainMod "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/main.py"
click AppInit "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/__init__.py"
click PyProject "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/pyproject.toml"

click MainWindow "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/main_window.py"
click WindowBuild "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/window_build.py"

click ExtractDialog "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/backup_extract/dialog.py"
click ExtractConfig "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/backup_extract/config.py"
click ExtractStatus "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/backup_extract/status.py"
click CleanupDialog "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/backup_cleanup/dialog.py"
click CleanupConfig "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/backup_cleanup/config.py"
click CleanupStatus "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/backup_cleanup/status.py"
click ClearHistoryDialog "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/windows/clear_history/dialog.py"

click ZipExtractor "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/logic/zip_extractor.py"
click WorldHistory "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/logic/world_history.py"
click DirCheck "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/logic/dir_check.py"
click RegexFuncs "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/logic/regex_funcs.py"

click SettingsList "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/settings/settings_list.py"
click SettingsInit "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/settings/__init__.py"

click Paths "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/app/paths.py"

click ConfirmWav "https://github.com/tousef-refuge/minecraft-backup-management/blob/master/audio/confirm.wav"
click Textures "https://github.com/tousef-refuge/minecraft-backup-management/tree/master/textures/"

%% =========================
%% Styles (color is critical)
%% =========================
classDef external fill:#FFE6CC,stroke:#B85C00,color:#3A2200,stroke-width:1px;
classDef container fill:#D6EAF8,stroke:#1B4F72,color:#0B2B3A,stroke-width:1px;
classDef gui fill:#CFE2FF,stroke:#1D4ED8,color:#0B1B3A,stroke-width:1px;
classDef module fill:#DBEAFE,stroke:#2563EB,color:#0B1B3A,stroke-width:1px;
classDef infra fill:#E0F2FE,stroke:#0284C7,color:#083344,stroke-width:1px;
classDef config fill:#EDE9FE,stroke:#6D28D9,color:#2E1065,stroke-width:1px;
classDef store fill:#D1FAE5,stroke:#047857,color:#064E3B,stroke-width:1px;
classDef folder fill:#E5E7EB,stroke:#6B7280,color:#111827,stroke-width:1px;
classDef sideeffect fill:#FED7AA,stroke:#C2410C,color:#431407,stroke-width:1px;
classDef asset fill:#FDE68A,stroke:#B45309,color:#3B2F00,stroke-width:1px;
classDef meta fill:#F3F4F6,stroke:#374151,color:#111827,stroke-width:1px;
```
