# dev57668/python-programms architecture

> Architecture diagram of the GitHub repository dev57668/python-programms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dev57668/python-programms
- Repository: https://github.com/dev57668/python-programms

## Overview

Code Lifejacket is a local, real-time shadow-backup and accidental-deletion recovery tool. A developer starts the CLI watcher, which scans existing files and handles filesystem events; eligible changes are debounced, deduplicated, and saved as timestamped snapshots with metadata. CLI recovery commands inspect history or status and can restore a selected snapshot after confirmation. The README also documents snapshot listing and cleanup. Wiring for those commands is represented at the CLI-to-recovery boundary; details beyond the sampled recovery excerpts are not inferred.

Main entry points: [`watcher.py`](https://github.com/dev57668/python-programms/blob/main/watcher.py) (Watcher and debounce), [`backup.py`](https://github.com/dev57668/python-programms/blob/main/backup.py) (Backup engine), [`recovery.py`](https://github.com/dev57668/python-programms/blob/main/recovery.py) (Recovery engine), [`main.py`](https://github.com/dev57668/python-programms/blob/main/main.py) (CLI dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and recovery"]
  node_main["CLI dispatcher<br/>[main.py]"]
  node_recovery["Recovery engine<br/>[recovery.py]"]
end

subgraph group_monitor["File monitoring"]
  node_watcher["Watcher and debounce<br/>[watcher.py]"]
  node_config["Settings and filters<br/>[config.py]"]
  node_config_file["User settings<br/>[config.json]"]
end

subgraph group_backup["Snapshot engine"]
  node_backup["Backup engine<br/>[backup.py]"]
  node_utils["Hash and path utilities<br/>[utils.py]"]
end

subgraph group_storage["Local storage"]
  node_database["Metadata database<br/>[database.py]"]
  node_metadata[("Metadata JSON<br/>[metadata.json]")]
  node_snapshots["Snapshot files<br/>[snapshots]"]
end

node_developer(("Developer"))
node_watchdog["Watchdog observer"]
node_project_files["Project files"]

node_developer -->|"runs commands"| node_main
node_main -->|"loads settings"| node_config
node_config_file -->|"supplies settings"| node_config
node_main -->|"starts watch"| node_watcher
node_watcher -->|"schedules observer"| node_watchdog
node_watchdog -->|"dispatches events"| node_watcher
node_project_files -->|"emits file events"| node_watcher
node_watcher -->|"checks filters"| node_config
node_watcher -->|"requests snapshots"| node_backup
node_watcher -->|"reports deletion"| node_backup
node_backup -->|"checks rules"| node_config
node_backup -->|"hashes and resolves paths"| node_utils
node_backup -->|"checks and records versions"| node_database
node_backup -->|"writes copies"| node_snapshots
node_database -->|"reads and writes"| node_metadata
node_main -->|"dispatches recovery commands"| node_recovery
node_recovery -->|"initializes engine"| node_backup
node_recovery -->|"queries and updates history"| node_database
node_recovery -->|"reads selected version"| node_snapshots
node_recovery -->|"restores file"| node_project_files

click node_main "https://github.com/dev57668/python-programms/blob/main/main.py"
click node_recovery "https://github.com/dev57668/python-programms/blob/main/recovery.py"
click node_watcher "https://github.com/dev57668/python-programms/blob/main/watcher.py"
click node_config "https://github.com/dev57668/python-programms/blob/main/config.py"
click node_config_file "https://github.com/dev57668/python-programms/blob/main/config.json"
click node_backup "https://github.com/dev57668/python-programms/blob/main/backup.py"
click node_utils "https://github.com/dev57668/python-programms/blob/main/utils.py"
click node_database "https://github.com/dev57668/python-programms/blob/main/database.py"
click node_metadata "https://github.com/dev57668/python-programms/blob/main/.lifejacket/metadata.json"
click node_snapshots "https://github.com/dev57668/python-programms/tree/main/.lifejacket/snapshots"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_recovery toneBlue
class node_watcher,node_config,node_config_file toneAmber
class node_backup,node_utils,node_watchdog toneMint
class node_database,node_metadata,node_snapshots toneRose
class node_developer,node_project_files toneIndigo
```

## Components

### CLI and recovery

- [CLI dispatcher](https://github.com/dev57668/python-programms/blob/main/main.py): `main.py`
- [Recovery engine](https://github.com/dev57668/python-programms/blob/main/recovery.py): `recovery.py`

### File monitoring

- [Watcher and debounce](https://github.com/dev57668/python-programms/blob/main/watcher.py): `watcher.py`
- [Settings and filters](https://github.com/dev57668/python-programms/blob/main/config.py): `config.py`
- [User settings](https://github.com/dev57668/python-programms/blob/main/config.json): `config.json`

### Snapshot engine

- [Backup engine](https://github.com/dev57668/python-programms/blob/main/backup.py): `backup.py`
- [Hash and path utilities](https://github.com/dev57668/python-programms/blob/main/utils.py): `utils.py`

### Local storage

- [Metadata database](https://github.com/dev57668/python-programms/blob/main/database.py): `database.py`
- [Metadata JSON](https://github.com/dev57668/python-programms/blob/main/.lifejacket/metadata.json): `.lifejacket/metadata.json`
- [Snapshot files](https://github.com/dev57668/python-programms/tree/main/.lifejacket/snapshots): `.lifejacket/snapshots`

### Other components

- **Developer**
- **Watchdog observer**
- **Project files**

## Connections

- Developer → CLI dispatcher: runs commands
- CLI dispatcher → Settings and filters: loads settings
- User settings → Settings and filters: supplies settings
- CLI dispatcher → Watcher and debounce: starts watch
- Watcher and debounce → Watchdog observer: schedules observer
- Watchdog observer → Watcher and debounce: dispatches events
- Project files → Watcher and debounce: emits file events
- Watcher and debounce → Settings and filters: checks filters
- Watcher and debounce → Backup engine: requests snapshots
- Watcher and debounce → Backup engine: reports deletion
- Backup engine → Settings and filters: checks rules
- Backup engine → Hash and path utilities: hashes and resolves paths
- Backup engine → Metadata database: checks and records versions
- Backup engine → Snapshot files: writes copies
- Metadata database → Metadata JSON: reads and writes
- CLI dispatcher → Recovery engine: dispatches recovery commands
- Recovery engine → Backup engine: initializes engine
- Recovery engine → Metadata database: queries and updates history
- Recovery engine → Snapshot files: reads selected version
- Recovery engine → Project files: restores file
