# raphire/win11debloat architecture

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

- Interactive diagram: https://gitdiagram.com/raphire/win11debloat
- Repository: https://github.com/raphire/win11debloat

## Overview

1. **Repository purpose**
   - This is a Windows 11 “debloat/customization” tool implemented as a PowerShell application, not a service or web app.
   - Its job is to apply a curated set of OS changes: remove apps, change registry-backed UI/system settings, disable features, and optionally reverse those changes.

2. **Entry points and runtime boundary**
   - `Win11Debloat.ps1` is the primary script entry point.
   - `Run.bat` is a convenience launcher for users who double-click the repo on Windows.
   - The whole system runs locally on Windows and relies on PowerShell plus Windows administrative privileges for most operations.

3. **Top-level orchestration flow**
   - The main script coordinates startup, option parsing, UI/CLI selection, loading saved settings, and then dispatches to either GUI-driven or CLI-driven execution paths.
   - The architecture is centered around “collect user choices → resolve changes → execute changes → persist/update state”.

4. **User interaction layer**
   - `Scripts/GUI` contains the WPF UI logic and window controllers.
   - `Schemas/*.xaml` defines the actual windows and shared styles: main window, config window, app selection, apply modal, about dialog, message box, and bubble hint.
   - `Scripts/CLI` contains the text-mode menu and status output for non-GUI usage.
   - These are separate front ends over the same underlying change-execution engine.

5. **Configuration and state**
   - `Config/DefaultSettings.json` provides the default preset.
   - `Config/Apps.json` and `Scripts/FileIO/LoadAppsDetailsFromJson.ps1` describe app metadata and removal candidates.
   - `Config/Features.json` appears to define feature toggles and mapping data.
   - `Scripts/FileIO` handles reading/writing settings, app lists, custom app presets, and validation.
   - This is the main persistence boundary: user choices are stored outside the code in JSON/files so the same engine can be reused across UI, CLI, and sysprep modes.

6. **Registry-based system changes**
   - `Regfiles/` is the primary payload for Windows configuration changes.
   - These `.reg` files are the actual implementation for many tweaks such as telemetry, taskbar, Explorer, search, start menu, AI features, update behavior, and privacy settings.
   - `Scripts/Features/ImportRegistryFile.ps1` is the bridge from PowerShell into the registry payloads.
   - The presence of `Undo/` and `Sysprep/` variants shows three important state sets: current-user normal mode, rollback mode, and default-user/profile-prep mode.

7. **Execution engine for feature changes**
   - `Scripts/Features/ExecuteChanges.ps1` is the likely central executor that applies the selected settings.
   - Supporting scripts handle system-level side effects such as creating restore points, restarting Explorer, enabling Windows features, disabling Store search suggestions, and replacing the Start menu.
   - This layer is the boundary between selection and mutation: it turns abstract feature flags into concrete OS changes.

8. **App removal subsystem**
   - `Scripts/AppRemoval` isolates uninstall logic from registry tweaks.
   - `GetInstalledAppsViaWinget.ps1` suggests detection uses Windows Package Manager metadata where available.
   - `RemoveApps.ps1` performs removals, and `ForceRemoveEdge.ps1` handles a special-case browser removal path.
   - App removal is therefore a separate subsystem from “feature toggles,” because it deals with package inventory and uninstall behavior instead of registry state.

9. **Operating-context helpers**
   - `Scripts/Helpers` contains environment and identity logic: determining the target user, checking whether a user exists or is logged in, resolving user directories, and generating app lists.
   - This is important because the tool supports applying changes to:
     - the current logged-in user,
     - another user profile,
     - Windows Audit/Sysprep scenarios.
   - These helpers form the boundary that adapts the tool to different Windows user/profile contexts.

10. **Threading and responsiveness**
    - `Scripts/Threading` contains `DoEvents.ps1` and `Invoke-NonBlocking.ps1`, which indicate the GUI path is designed to stay responsive while long-running changes are applied.
    - This suggests long operations are executed asynchronously or cooperatively so the UI can show progress/modals without freezing.

11. **Assets and UX support**
    - `Assets/Images` and `Assets/Start` provide bundled images and startup artifacts used by the UI/launcher experience.
    - These are presentation-only assets; they do not affect the OS-tweak logic but support branding and the initial loading experience.

12. **Packaging of reversible and specialized presets**
    - The duplicated `.reg` files under `Regfiles/Sysprep` and `Regfiles/Undo` show that the repo intentionally models multiple operation modes:
      - standard apply,
      - rollback/undo,
      - default-profile preparation for new users.
    - That structure is a major architecture clue: the tool is not a one-way cleaner, but a reversible policy application system.

13. **External dependencies and system integration**
    - The main external dependency is the Windows OS itself: registry, Explorer, system features, optional Windows components, and installed app inventory.
    - `winget` is used where available for app discovery/removal.
    - The repo does not appear to rely on cloud services at runtime; the only networked path described in the README is the optional script download URL for bootstrap convenience.

14. **How the pieces fit together**
    - Startup begins in the launcher/script entry point.
    - Settings and app definitions are loaded from JSON.
    - The user chooses options through GUI or CLI.
    - The tool resolves the target user/context and translates selections into registry imports, package removals, and feature toggles.
    - Supporting actions like restore-point creation and Explorer restart are executed as needed.
    - Final settings/state may be saved for later reuse or reapplication.

Main entry points: [`Win11Debloat.ps1`](https://github.com/raphire/win11debloat/blob/master/Win11Debloat.ps1) (Win11Debloat.ps1), [`Schemas/MainWindow.xaml`](https://github.com/raphire/win11debloat/blob/master/Schemas/MainWindow.xaml) (Main window), [`Scripts/FileIO/LoadSettings.ps1`](https://github.com/raphire/win11debloat/blob/master/Scripts/FileIO/LoadSettings.ps1) (File I/O), [`Scripts/Features/ExecuteChanges.ps1`](https://github.com/raphire/win11debloat/blob/master/Scripts/Features/ExecuteChanges.ps1) (Execute changes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry & runtime"]
  node_win11debloat["Win11Debloat.ps1<br/>ps entrypoint<br/>[Win11Debloat.ps1]"]
  node_runbat["Run.bat<br/>launcher<br/>[Run.bat]"]
end

subgraph group_ui["User interface"]
  node_mainwindow["Main window<br/>wpf shell<br/>[MainWindow.xaml]"]
  node_configwindow["Config window<br/>wpf config ui"]
  node_appwindow["App picker<br/>wpf app ui"]
  node_applymodal["Apply modal<br/>wpf progress ui"]
  node_cli["CLI menus<br/>text ui"]
end

subgraph group_config["Config & state"]
  node_settingsjson["Default settings<br/>preset json"]
  node_appsjson["Apps catalog<br/>catalog json<br/>[Apps.json]"]
  node_featuresjson["Features map<br/>mapping json<br/>[Features.json]"]
  node_fileio["File I/O<br/>persistence layer<br/>[LoadSettings.ps1]"]
end

subgraph group_features["Feature engine"]
  node_featuresexec["Execute changes<br/>mutation engine<br/>[ExecuteChanges.ps1]"]
  node_regbridge["Registry bridge<br/>registry importer"]
  node_regpayloads[("Regfiles<br/>reg payloads")]
  node_systemside["System actions<br/>os helpers"]
end

subgraph group_apps["App removal"]
  node_appremoval["App removal<br/>uninstall pipeline<br/>[RemoveApps.ps1]"]
  node_wingetdetect["Winget detect<br/>inventory probe"]
  node_edgeforce["Edge removal<br/>special case"]
end

subgraph group_helpers["Context helpers"]
  node_helpers["Context helpers<br/>env helpers"]
end

subgraph group_threading["Threading"]
  node_threading["Non-blocking<br/>ui threading"]
end

subgraph group_assets["Assets"]
  node_assets["UI assets<br/>presentation assets"]
end

node_runbat -->|"launches"| node_win11debloat
node_win11debloat -->|"loads/saves"| node_fileio
node_win11debloat -->|"resolves context"| node_helpers
node_win11debloat -->|"opens GUI"| node_mainwindow
node_win11debloat -->|"opens CLI"| node_cli
node_mainwindow -->|"configures"| node_configwindow
node_mainwindow -->|"selects apps"| node_appwindow
node_mainwindow -->|"applies"| node_applymodal
node_mainwindow -->|"keeps responsive"| node_threading
node_cli -->|"drives"| node_appremoval
node_cli -->|"drives"| node_featuresexec
node_fileio -->|"reads/writes"| node_settingsjson
node_fileio -->|"reads"| node_appsjson
node_fileio -->|"reads"| node_featuresjson
node_fileio -->|"validates context"| node_helpers
node_featuresexec -->|"imports tweaks"| node_regbridge
node_regbridge -->|"applies"| node_regpayloads
node_featuresexec -->|"runs side effects"| node_systemside
node_featuresexec -->|"can invoke"| node_appremoval
node_appremoval -->|"discovers"| node_wingetdetect
node_appremoval -->|"special-cases"| node_edgeforce
node_appremoval -->|"targets user"| node_helpers
node_featuresexec -->|"targets user"| node_helpers
node_win11debloat -->|"uses"| node_assets

click node_win11debloat "https://github.com/raphire/win11debloat/blob/master/Win11Debloat.ps1"
click node_runbat "https://github.com/raphire/win11debloat/blob/master/Run.bat"
click node_mainwindow "https://github.com/raphire/win11debloat/blob/master/Schemas/MainWindow.xaml"
click node_configwindow "https://github.com/raphire/win11debloat/blob/master/Schemas/ImportExportConfigWindow.xaml"
click node_appwindow "https://github.com/raphire/win11debloat/blob/master/Schemas/AppSelectionWindow.xaml"
click node_applymodal "https://github.com/raphire/win11debloat/blob/master/Schemas/ApplyChangesWindow.xaml"
click node_cli "https://github.com/raphire/win11debloat/blob/master/Scripts/CLI/ShowCLIMenuOptions.ps1"
click node_settingsjson "https://github.com/raphire/win11debloat/blob/master/Config/DefaultSettings.json"
click node_appsjson "https://github.com/raphire/win11debloat/blob/master/Config/Apps.json"
click node_featuresjson "https://github.com/raphire/win11debloat/blob/master/Config/Features.json"
click node_fileio "https://github.com/raphire/win11debloat/blob/master/Scripts/FileIO/LoadSettings.ps1"
click node_helpers "https://github.com/raphire/win11debloat/blob/master/Scripts/Helpers/GetTargetUserForAppRemoval.ps1"
click node_featuresexec "https://github.com/raphire/win11debloat/blob/master/Scripts/Features/ExecuteChanges.ps1"
click node_regbridge "https://github.com/raphire/win11debloat/blob/master/Scripts/Features/ImportRegistryFile.ps1"
click node_regpayloads "https://github.com/raphire/win11debloat/tree/master/Regfiles"
click node_systemside "https://github.com/raphire/win11debloat/blob/master/Scripts/Features/CreateSystemRestorePoint.ps1"
click node_appremoval "https://github.com/raphire/win11debloat/blob/master/Scripts/AppRemoval/RemoveApps.ps1"
click node_wingetdetect "https://github.com/raphire/win11debloat/blob/master/Scripts/AppRemoval/GetInstalledAppsViaWinget.ps1"
click node_edgeforce "https://github.com/raphire/win11debloat/blob/master/Scripts/AppRemoval/ForceRemoveEdge.ps1"
click node_threading "https://github.com/raphire/win11debloat/blob/master/Scripts/Threading/Invoke-NonBlocking.ps1"
click node_assets "https://github.com/raphire/win11debloat/tree/master/Assets/Images"

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_win11debloat,node_runbat,node_threading toneBlue
class node_mainwindow,node_configwindow,node_appwindow,node_applymodal,node_cli,node_assets toneAmber
class node_settingsjson,node_appsjson,node_featuresjson,node_fileio toneMint
class node_featuresexec,node_regbridge,node_regpayloads,node_systemside toneRose
class node_appremoval,node_wingetdetect,node_edgeforce toneIndigo
class node_helpers toneTeal
```

## Components

### Entry & runtime

Launch points and top-level orchestration

- [Win11Debloat.ps1](https://github.com/raphire/win11debloat/blob/master/Win11Debloat.ps1): ps entrypoint · Primary PowerShell entry script that orchestrates mode selection and execution · `Win11Debloat.ps1`
- [Run.bat](https://github.com/raphire/win11debloat/blob/master/Run.bat): launcher · Windows batch launcher for double-click startup · `Run.bat`

### User interface

GUI and CLI front ends

- [Main window](https://github.com/raphire/win11debloat/blob/master/Schemas/MainWindow.xaml): wpf shell · Primary GUI window and overall application shell · `Schemas/MainWindow.xaml`
- [Config window](https://github.com/raphire/win11debloat/blob/master/Schemas/ImportExportConfigWindow.xaml): wpf config ui · Window for editing and importing/exporting settings · `Schemas/ImportExportConfigWindow.xaml`
- [App picker](https://github.com/raphire/win11debloat/blob/master/Schemas/AppSelectionWindow.xaml): wpf app ui · GUI for selecting apps and app-removal options · `Schemas/AppSelectionWindow.xaml`
- [Apply modal](https://github.com/raphire/win11debloat/blob/master/Schemas/ApplyChangesWindow.xaml): wpf progress ui · Modal used while settings are being applied · `Schemas/ApplyChangesWindow.xaml`
- [CLI menus](https://github.com/raphire/win11debloat/blob/master/Scripts/CLI/ShowCLIMenuOptions.ps1): text ui · Console menus, headers, and status output for non-GUI usage · `Scripts/CLI/ShowCLIMenuOptions.ps1`

### Config & state

JSON presets, persistence, and import/export

- [Default settings](https://github.com/raphire/win11debloat/blob/master/Config/DefaultSettings.json): preset json · Default preset and baseline configuration data · `Config/DefaultSettings.json`
- [Apps catalog](https://github.com/raphire/win11debloat/blob/master/Config/Apps.json): catalog json · App metadata and removal candidates · `Config/Apps.json`
- [Features map](https://github.com/raphire/win11debloat/blob/master/Config/Features.json): mapping json · Feature toggle definitions and mapping data · `Config/Features.json`
- [File I/O](https://github.com/raphire/win11debloat/blob/master/Scripts/FileIO/LoadSettings.ps1): persistence layer · Loads, saves, validates, and imports settings and app lists · `Scripts/FileIO/LoadSettings.ps1`

### Feature engine

Registry tweaks and system mutation pipeline

- [Execute changes](https://github.com/raphire/win11debloat/blob/master/Scripts/Features/ExecuteChanges.ps1): mutation engine · Central executor that turns selected options into OS changes · `Scripts/Features/ExecuteChanges.ps1`
- [Registry bridge](https://github.com/raphire/win11debloat/blob/master/Scripts/Features/ImportRegistryFile.ps1): registry importer · Imports .reg payloads into the appropriate Windows context · `Scripts/Features/ImportRegistryFile.ps1`
- [Regfiles](https://github.com/raphire/win11debloat/tree/master/Regfiles): reg payloads · Curated registry tweaks, undo files, and sysprep variants · `Regfiles`
- [System actions](https://github.com/raphire/win11debloat/blob/master/Scripts/Features/CreateSystemRestorePoint.ps1): os helpers · Restore points, Explorer restart, feature enablement, and related side effects · `Scripts/Features/CreateSystemRestorePoint.ps1`

### App removal

App inventory and uninstall workflow

- [App removal](https://github.com/raphire/win11debloat/blob/master/Scripts/AppRemoval/RemoveApps.ps1): uninstall pipeline · Discovers installed apps and performs removals · `Scripts/AppRemoval/RemoveApps.ps1`
- [Winget detect](https://github.com/raphire/win11debloat/blob/master/Scripts/AppRemoval/GetInstalledAppsViaWinget.ps1): inventory probe · Uses Winget metadata when available to find installed apps · `Scripts/AppRemoval/GetInstalledAppsViaWinget.ps1`
- [Edge removal](https://github.com/raphire/win11debloat/blob/master/Scripts/AppRemoval/ForceRemoveEdge.ps1): special case · Special removal path for Microsoft Edge · `Scripts/AppRemoval/ForceRemoveEdge.ps1`

### Context helpers

User, profile, and environment resolution

- [Context helpers](https://github.com/raphire/win11debloat/blob/master/Scripts/Helpers/GetTargetUserForAppRemoval.ps1): env helpers · Resolves target user, profile paths, and runtime context · `Scripts/Helpers/GetTargetUserForAppRemoval.ps1`

### Threading

Non-blocking execution helpers

- [Non-blocking](https://github.com/raphire/win11debloat/blob/master/Scripts/Threading/Invoke-NonBlocking.ps1): ui threading · Helpers that keep the GUI responsive during long operations · `Scripts/Threading/Invoke-NonBlocking.ps1`

### Assets

Bundled images and startup artifacts

- [UI assets](https://github.com/raphire/win11debloat/tree/master/Assets/Images): presentation assets · Images and startup artifacts used by the launcher and UI · `Assets/Images`

## Connections

- Run.bat → Win11Debloat.ps1: launches · Batch launcher starts the PowerShell entry script
- Win11Debloat.ps1 → File I/O: loads/saves · Entry point reads default, saved, and imported settings
- Win11Debloat.ps1 → Context helpers: resolves context · Determines target user and execution context
- Win11Debloat.ps1 → Main window: opens GUI · Selects the GUI path when interactive mode is used
- Win11Debloat.ps1 → CLI menus: opens CLI · Selects the console path when non-GUI mode is used
- Main window → Config window: configures · Main GUI opens config/import-export views
- Main window → App picker: selects apps · Main GUI opens app selection UI
- Main window → Apply modal: applies · Shows progress modal while changes are executed
- Main window → Non-blocking: keeps responsive · GUI uses background/non-blocking helpers during long tasks
- CLI menus → App removal: drives · Console menus can trigger the app-removal workflow
- CLI menus → Execute changes: drives · Console menus can trigger feature application
- File I/O → Default settings: reads/writes · Settings persistence uses the default preset and saved state
- File I/O → Apps catalog: reads · Loads app definitions from JSON
- File I/O → Features map: reads · Loads feature mapping data from JSON
- File I/O → Context helpers: validates context · File I/O and config handling depend on user/profile resolution
- Execute changes → Registry bridge: imports tweaks · Executor applies selected registry-backed changes through the bridge
- Registry bridge → Regfiles: applies · Registry bridge selects standard, undo, or sysprep payloads
- Execute changes → System actions: runs side effects · Executor triggers restore points, Explorer restarts, and feature operations
- Execute changes → App removal: can invoke · Feature execution can hand off to app removal when selected
- App removal → Winget detect: discovers · Removal workflow probes installed apps via Winget when available
- App removal → Edge removal: special-cases · Dedicated path handles Edge removal separately
- App removal → Context helpers: targets user · App removal needs target-user and profile context
- Execute changes → Context helpers: targets user · Mutation engine resolves the correct user/profile boundary
- Win11Debloat.ps1 → UI assets: uses · Startup and UI presentation use bundled assets
