# snowhaze/snowhaze-ios architecture

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

- Interactive diagram: https://gitdiagram.com/snowhaze/snowhaze-ios
- Repository: https://github.com/snowhaze/snowhaze-ios

## Overview

1. **What this repo is**
   - SnowHaze is an iOS privacy browser with extra network/privacy subsystems: content blocking, safe browsing, VPN, Tor support, bookmarks/history/downloads, and a Today/extension target.
   - The codebase is organized as a main iOS app plus a smaller “SnowHaze VPN” target and shared submodules/assets.

2. **Top-level app composition**
   - `SnowHaze/` contains the primary browser app.
   - `SnowHaze VPN/` contains a Today view / extension-style component (`TodayViewController.swift`) with its own storyboard, localized strings, entitlements, and assets.
   - `shared/` contains reusable lower-level components, including code-scanner UI, regex helpers, and SQLCipher wrappers.

3. **Main UI and navigation shell**
   - The browser UI is driven by `MainViewController`, `TabViewController`, `TabController`, `URLBar`, `SearchBar`, and related popover/view classes.
   - The app appears to be a tabbed browser shell with separate views for settings, downloads, bookmarks/history, page info, tutorial/onboarding, and security details.
   - Storyboards are used for launch and main UI, with many custom Swift view/controller classes layered on top.

4. **Web content execution and page transformation**
   - Web content is primarily handled through `WebViewManager` and `WorkerWebViewManager`, with additional logic around `BrowserPageGenerator`, `HTMLParser`, and `PagePrintRenderer`.
   - Several bundled JavaScript files are injected into pages to modify behavior at runtime: ad blocking, referrer stripping, canvas protection, fingerprinting protection, reader mode, login filling, search initialization/selection, night mode, and Tor/url rewriting helpers.
   - This indicates a pipeline where the app intercepts page loads, rewrites or augments page content, then renders through WebKit.

5. **Privacy and security enforcement layer**
   - The core privacy boundary is centered on `PolicyManager`, `PolicyAssessor`, `ContentBlockerManager`, `TrackingSettingsManager`, `HTTPSSettingsManager`, `JavaScriptSettingsManager`, `CookieBlockingPolicy`, and `PopoverBlockingPolicy`.
   - These managers determine what is allowed per site and globally: script execution, third-party trackers, cookies, popovers, media playback, mixed content, HTTPS upgrades, and website data handling.
   - `URLInjectionDetection`, `URLParamStripRule`, `Redirector`, and `MaskingRule` suggest request/URL sanitization before navigation proceeds.

6. **Threat intelligence and classification data**
   - The app ships with a bundled data layer under `shared/large-data/lists.db` plus geo-IP files (`geoip`, `geoip6`).
   - The README confirms categories such as HTTPS-capable sites, ad networks, tracker hosts, private/dangerous sites, URL parameter rules, popular sites, and content blockers.
   - This data feeds the browser policy decisions, safe browsing, search suggestions, country/flag display, and likely routing/UI hints.

7. **Persistent storage and encrypted local state**
   - Local browser state is persisted through `DataStore`, `History`, `Bookmark`, download models, subscription/settings managers, and encrypted database helpers.
   - The presence of `shared/sqlcipher/` and `EncryptedDBHelpers` shows that sensitive persisted data is stored in an encrypted SQLite/SQLCipher layer rather than plain local storage.
   - This storage boundary likely covers history, bookmarks, subscriptions, cached intelligence, and settings that need durability.

8. **Network stack and remote services**
   - Network access is abstracted through fetchers and session wrappers like `DataFetcher`, `JSONFetcher`, `SnowHazeURLSession`, `Pinger`, and `V3APIConnection`.
   - `ServerTrust`, `SecPolicyEvaluator`, and `Cert` indicate custom TLS/certificate validation and trust evaluation.
   - External network communication exists for browsing, safe browsing updates, subscription-related features, search suggestions, and possibly VPN/Tor control, but the app is designed to avoid unsolicited connections.

9. **VPN and Tor subsystems**
   - `VPNManager`, `VPNSettingsManager`, `TorServer`, `TorSchemeHandler`, `TorHelpers`, `TorSettingsManager`, and `TorInfoView` form distinct privacy-routing pathways.
   - Architecturally, these are optional transport layers beneath or beside the browser’s normal WebKit networking path.
   - The browser can surface status/UI for Tor/VPN and likely route selected traffic through those systems depending on settings and user choice.

10. **Browser features built around web state**
   - Bookmarks, history, suggestions, and “home/popular sites” are first-class subsystems with dedicated sources and UI cells/views.
   - Downloads are handled separately via `DownloadManager`, `DownloadActivity`, `DownloadProgressIndicator`, `FileDownload`, and `DownloadsList`.
   - Other browser features include find-on-page, page previews, page info/security indicators, print rendering, and tab selection/layout controls.

11. **Authentication, passcodes, and user settings**
   - Local protection is implemented via `PasscodeManager`, `PasscodeController`, `PasswordValidator`, and `LockController`.
   - Settings are highly modular: there are many dedicated managers for appearance, defaults, content blocking, external bookmarks, search engine, media playback, safe browsing, VPN, Tor, warnings, website data, and more.
   - This suggests a settings architecture built from feature-specific managers rather than one monolithic settings store.

12. **Shared utilities and platform glue**
   - The repo contains a lot of supporting code for strings, URL handling, dispatch helpers, randomization, hex/encoding, punycode/IDNA, JSON/path parsing, templating, and text utilities.
   - There is Objective-C/C bridging for WebKit and lower-level pieces (`WebKitFixes.m/.h`, `SimplePing.m/.h`, `bridging.c`, `SnowHaze-Bridging-Header.h`), showing a mixed Swift + native interop boundary.
   - CocoaPods and Xcode workspaces are the build/tooling layer; the app is iOS-native, localization-heavy, and asset-driven.

13. **Non-browser side utilities**
   - `shared/code-scanner` is a self-contained camera/code scanning component, likely reused by the browser for QR/code workflows.
   - `shared/large-data` also contains many localized icons and tutorial assets, showing that much of the user-facing product surface is bundled and offline-capable.
   - The overall architecture is therefore an offline-first local app core with selective network dependencies and several privacy-preserving transport/content layers.

Main entry points: [`SnowHaze/MainViewController.swift`](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/MainViewController.swift) (Main View), [`SnowHaze/DataFetcher.swift`](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/DataFetcher.swift) (Network Stack), [`SnowHaze/WebViewManager.swift`](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/WebViewManager.swift) (Web Runtime), [`SnowHaze/Safebrowsing.swift`](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/Safebrowsing.swift) (Safe Browsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_main_app["Main App"]
  node_app_shell["App Shell<br/>entrypoint<br/>[AppDelegate.swift]"]
  node_main_ui["Main View<br/>browser-ui"]
  node_tabs["Tab System<br/>tabs"]
  node_url_bar["URL Bar<br/>input-ui<br/>[URLBar.swift]"]
  node_web_runtime["Web Runtime<br/>webkit-core"]
  node_page_transform["Page Transform<br/>rewrite-pipeline"]
  node_policy_core["Policy Core<br/>privacy-policy"]
  node_content_blocking["Blocking"]
  node_safe_browsing["Safe Browsing<br/>threat-intel<br/>[Safebrowsing.swift]"]
  node_storage[("Local Store<br/>persistent-storage<br/>[DataStore.swift]")]
  node_browser_features["Browser Features<br/>feature-suite"]
  node_settings["Settings"]
  node_security["Security UI<br/>security-ui<br/>[TLSInfoView.swift]"]
  node_network_stack["Network Stack<br/>networking<br/>[DataFetcher.swift]"]
  node_vpn["VPN Layer<br/>transport<br/>[VPNManager.swift]"]
  node_tor["Tor Layer<br/>transport<br/>[TorServer.swift]"]
end

subgraph group_vpn_extension["VPN Extension"]
  node_vpn_widget["VPN Widget<br/>extension-ui"]
end

subgraph group_shared["Shared"]
  node_code_scanner["Code Scanner<br/>camera-module"]
  node_sqlcipher[("SQLCipher<br/>encrypted-sqlite")]
end

subgraph group_data["Data & Assets"]
  node_shared_assets[("Shared Assets<br/>bundled-data<br/>[lists.db]")]
end

node_app_shell -->|"launches"| node_main_ui
node_main_ui -->|"coordinates"| node_tabs
node_main_ui -->|"hosts"| node_url_bar
node_main_ui -->|"drives"| node_web_runtime
node_web_runtime -->|"builds pages"| node_page_transform
node_page_transform -->|"applies rules"| node_content_blocking
node_policy_core -->|"configures"| node_content_blocking
node_policy_core -->|"governs"| node_web_runtime
node_content_blocking -->|"reads lists"| node_shared_assets
node_safe_browsing -->|"uses intel"| node_shared_assets
node_safe_browsing -->|"updates"| node_network_stack
node_storage -->|"encrypts"| node_sqlcipher
node_browser_features -->|"persists"| node_storage
node_settings -->|"reads/writes"| node_storage
node_security -->|"validates"| node_network_stack
node_network_stack -->|"supports"| node_safe_browsing
node_network_stack -->|"routes via"| node_vpn
node_network_stack -->|"routes via"| node_tor
node_vpn -->|"surfaces"| node_vpn_widget
node_tor -->|"intercepts"| node_web_runtime
node_code_scanner -->|"embedded in"| node_main_ui

click node_app_shell "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/AppDelegate.swift"
click node_main_ui "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/MainViewController.swift"
click node_tabs "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/TabViewController.swift"
click node_url_bar "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/URLBar.swift"
click node_web_runtime "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/WebViewManager.swift"
click node_page_transform "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/BrowserPageGenerator.swift"
click node_policy_core "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/PolicyManager.swift"
click node_content_blocking "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/ContentBlockerManager.swift"
click node_safe_browsing "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/Safebrowsing.swift"
click node_storage "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/DataStore.swift"
click node_browser_features "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/DownloadsList.swift"
click node_settings "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/SettingsViewController.swift"
click node_security "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/TLSInfoView.swift"
click node_network_stack "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/DataFetcher.swift"
click node_vpn "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/VPNManager.swift"
click node_tor "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/TorServer.swift"
click node_code_scanner "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/shared/code-scanner/ScanCodeViewController.swift"
click node_sqlcipher "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/shared/sqlcipher/SQLiteManager.swift"
click node_shared_assets "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/shared/large-data/lists.db"
click node_vpn_widget "https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze VPN/TodayViewController.swift"

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_app_shell,node_main_ui,node_tabs,node_url_bar,node_web_runtime,node_page_transform,node_policy_core,node_content_blocking,node_safe_browsing,node_storage,node_browser_features,node_settings,node_security,node_network_stack,node_vpn,node_tor toneBlue
class node_vpn_widget toneAmber
class node_code_scanner,node_sqlcipher toneMint
class node_shared_assets toneRose
```

## Components

### Main App

Primary iOS browser target and its core runtime.

- [App Shell](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/AppDelegate.swift): entrypoint · Application lifecycle and top-level setup for the browser target. · `SnowHaze/AppDelegate.swift`
- [Main View](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/MainViewController.swift): browser-ui · Primary browser container coordinating tabs, bars, and page state. · `SnowHaze/MainViewController.swift`
- [Tab System](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/TabViewController.swift): tabs · Tab models and selection/navigation controls for multiple pages. · `SnowHaze/TabViewController.swift`
- [URL Bar](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/URLBar.swift): input-ui · Address/search entry and suggestion-driven navigation. · `SnowHaze/URLBar.swift`
- [Web Runtime](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/WebViewManager.swift): webkit-core · WebKit page loading, worker views, and page generation pipeline. · `SnowHaze/WebViewManager.swift`
- [Page Transform](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/BrowserPageGenerator.swift): rewrite-pipeline · HTML parsing and injected JavaScript used to modify page behavior. · `SnowHaze/BrowserPageGenerator.swift`
- [Policy Core](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/PolicyManager.swift): privacy-policy · Per-site and global privacy enforcement decisions. · `SnowHaze/PolicyManager.swift`
- [Blocking](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/ContentBlockerManager.swift): content-blocking · Content blocker rules, tracker lists, cookie and popover restrictions. · `SnowHaze/ContentBlockerManager.swift`
- [Safe Browsing](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/Safebrowsing.swift): threat-intel · Malicious site checks, caching, networking, and storage for reputation data. · `SnowHaze/Safebrowsing.swift`
- [Local Store](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/DataStore.swift): persistent-storage · Browser state persistence including history, bookmarks, downloads, and settings wrappers. · `SnowHaze/DataStore.swift`
- [Browser Features](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/DownloadsList.swift): feature-suite · Bookmarks, history, downloads, find-on-page, page info, and print/page preview flows. · `SnowHaze/DownloadsList.swift`
- [Settings](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/SettingsViewController.swift): settings-suite · Modular settings managers for appearance, search, VPN/Tor, warnings, and data policies. · `SnowHaze/SettingsViewController.swift`
- [Security UI](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/TLSInfoView.swift): security-ui · Passcode, lock, TLS/certificate details, and security status presentation. · `SnowHaze/TLSInfoView.swift`
- [Network Stack](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/DataFetcher.swift): networking · Fetchers, URL sessions, pings, API connections, and trust evaluation. · `SnowHaze/DataFetcher.swift`
- [VPN Layer](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/VPNManager.swift): transport · VPN manager and VPN-specific settings controlling optional routed traffic. · `SnowHaze/VPNManager.swift`
- [Tor Layer](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/TorServer.swift): transport · Tor server, scheme handler, helpers, and Tor-specific settings/status UI. · `SnowHaze/TorServer.swift`

### VPN Extension

Today/extension-style VPN status and control surface.

- [VPN Widget](https://github.com/snowhaze/snowhaze-ios/blob/HEAD/SnowHaze%20VPN/TodayViewController.swift): extension-ui · Today view controller and storyboard for the VPN extension surface. · `SnowHaze VPN/TodayViewController.swift`

### Shared

Reusable scanners, storage, and low-level helpers.

- [Code Scanner](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/shared/code-scanner/ScanCodeViewController.swift): camera-module · Reusable camera-based code scanning component. · `SnowHaze/shared/code-scanner/ScanCodeViewController.swift`
- [SQLCipher](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/shared/sqlcipher/SQLiteManager.swift): encrypted-sqlite · Encrypted SQLite wrapper used for sensitive local persistence. · `SnowHaze/shared/sqlcipher/SQLiteManager.swift`

### Data & Assets

Bundled lists, geodata, and privacy/page assets.

- [Shared Assets](https://github.com/snowhaze/snowhaze-ios/blob/master/SnowHaze/shared/large-data/lists.db): bundled-data · Large bundled lists, icons, tutorials, and geodata used by the app. · `SnowHaze/shared/large-data/lists.db`

## Connections

- App Shell → Main View: launches · Creates and hands off to the main browser interface.
- Main View → Tab System: coordinates · Manages the active tab set and selection flows.
- Main View → URL Bar: hosts · Integrates URL/search entry with browser navigation.
- Main View → Web Runtime: drives · Requests page loads and receives web state updates.
- Web Runtime → Page Transform: builds pages · Transforms content before WebKit renders it.
- Page Transform → Blocking: applies rules · Uses injected scripts and blocking logic to alter page behavior.
- Policy Core → Blocking: configures · Feeds site/global privacy policy into blockers.
- Policy Core → Web Runtime: governs · Controls what the web runtime may execute or load.
- Blocking → Shared Assets: reads lists · Consumes bundled classification and blocker data.
- Safe Browsing → Shared Assets: uses intel · Relies on packaged reputation and geo data.
- Safe Browsing → Network Stack: updates · Fetches remote threat data and related metadata.
- Local Store → SQLCipher: encrypts · Persists sensitive local state through encrypted SQLite.
- Browser Features → Local Store: persists · Stores history, bookmarks, downloads, and page state.
- Settings → Local Store: reads/writes · Manages durable configuration and feature preferences.
- Security UI → Network Stack: validates · Uses trust and certificate evaluation for connections.
- Network Stack → Safe Browsing: supports · Provides remote connectivity for reputation lookups and updates.
- Network Stack → VPN Layer: routes via · Can operate through VPN-controlled transport.
- Network Stack → Tor Layer: routes via · Can operate through Tor-controlled transport.
- VPN Layer → VPN Widget: surfaces · Exposes VPN status and controls in the extension UI.
- Tor Layer → Web Runtime: intercepts · Provides alternate web request handling for Tor traffic.
- Code Scanner → Main View: embedded in · Reusable scanner UI can be invoked from the browser.
