# henrypp/simplewall architecture

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

- Interactive diagram: https://gitdiagram.com/henrypp/simplewall
- Repository: https://github.com/henrypp/simplewall

## Overview

##### Project Type & Purpose
- This is a lightweight network filter configuration utility that uses the WFP APIs. It is a desktop tool that provides a custom UI for both setting up permanent and temporary filtering rules.

##### High-Level Architectural Components
- UI/Presentation Layer:
– Displays the rules editor, notifications, and settings screens.
- Business Logic / Core Engine:
– Includes the main application logic (main.c/main.h) and functions spread across helper.c/h, messages.c/h, and timer.c/h.
– Handles the rule syntax, logging (log.c/h), and profiles (profile.c/h).
- Network & Filtering Integration:
– Modules like network.c/h and wfp.c/h handle the integration with the Windows Filtering Platform.
– Manages installation/uninstallation of filters, as well as the interfacing with low-level Windows APIs.
- Data Management / Logging:
– Modules like db.c/h and log.c/h handle persistence of filter rules and logs.
- Internationalization (i18n):
– The “bin/i18n” folder includes multiple language files which indicate that the UI supports multiple locales.
- Build & Deployment:
– The solution file (simplewall.sln) and accompanying VC++ project files illustrate how the source is compiled.
– Batch files like build.bat and build_locale.bat show the automation for building and localization.

##### Relationships and Data Flow
- The UI layer interacts with the Core Engine to process user input (such as adding, modifying, or deleting filter rules).
- The Core Engine then calls into the Network & Filtering Integration layer to apply these rules through the Windows Filtering Platform.
- Logging and notifications are managed by dedicated modules that capture network events and user actions, then relay them back to the UI and write to log files.
- Configuration (for portable mode, settings, etc.) and internationalization settings are read from the file system (e.g., simplewall.ini and the “bin/i18n” files).

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate UI, business logic, and integration with external systems (such as Windows APIs).
- Modularity: Each major function (like rule editing, logging, network filtering) lives in its own module for clarity and maintainability.
- Extensibility: The rules editor design allows for both global and application-specific rules, indicating that the system is built to be extended by the end user.
- Separation of Concerns: UI components do not directly handle low-level network filtering—the core engine abstracts these details.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface"
        controls["Controls Module"]:::ui
        editor["Editor Module"]:::ui
        listview["Listview Module"]:::ui
        icons["Icons Module"]:::ui
    end

    %% Core Engine & Business Logic Layer
    subgraph "Core Engine & Business Logic"
        main["Main Application Logic"]:::core
        helper["Helper Functions"]:::core
        messages["Messaging Module"]:::core
        timer["Timer Module"]:::core
        logging["Logging Module"]:::core
        profiles["Profiles Module"]:::core
    end

    %% System Integration Layer
    subgraph "System Integration"
        network["Network Module"]:::integration
        wfp["WFP Integration Module"]:::integration
    end

    %% Data Management / Logging Layer
    subgraph "Data Management"
        db["Database Module"]:::data
    end

    %% Internationalization Module
    subgraph "Internationalization"
        i18n["Internationalization Module"]:::intl
    end

    %% Build & Deployment Infrastructure
    subgraph "Build & Deployment"
        vs["Visual Studio Solution"]:::build
        build["Build Scripts"]:::build
    end

    %% External dependency
    WFP_API["Windows Filtering Platform API"]:::external

    %% Connections and Data Flows
    editor -->|"processInput"| main
    controls -->|"trigger"| main
    main -->|"applyRules"| network
    main -->|"logEvent"| db
    messages -->|"notify"| controls
    timer -->|"refreshUI"| listview
    wfp -->|"interface"| WFP_API
    i18n -->|"loadLocale"| controls

    %% Styles
    classDef ui fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef core fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef integration fill:#ffff99,stroke:#000,stroke-width:2px;
    classDef data fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef intl fill:#e6ccff,stroke:#000,stroke-width:2px;
    classDef build fill:#cce5ff,stroke:#000,stroke-width:2px;
    classDef external fill:#ff9999,stroke:#000,stroke-width:2px;

    %% Click Events
    click controls "https://github.com/henrypp/simplewall/blob/master/src/controls.c"
    click editor "https://github.com/henrypp/simplewall/blob/master/src/editor.c"
    click listview "https://github.com/henrypp/simplewall/blob/master/src/listview.c"
    click icons "https://github.com/henrypp/simplewall/blob/master/src/icons.c"
    click main "https://github.com/henrypp/simplewall/blob/master/src/main.c"
    click helper "https://github.com/henrypp/simplewall/blob/master/src/helper.c"
    click messages "https://github.com/henrypp/simplewall/blob/master/src/messages.c"
    click timer "https://github.com/henrypp/simplewall/blob/master/src/timer.c"
    click logging "https://github.com/henrypp/simplewall/blob/master/src/log.c"
    click profiles "https://github.com/henrypp/simplewall/blob/master/src/profile.c"
    click network "https://github.com/henrypp/simplewall/blob/master/src/network.c"
    click wfp "https://github.com/henrypp/simplewall/blob/master/src/wfp.c"
    click db "https://github.com/henrypp/simplewall/blob/master/src/db.c"
    click i18n "https://github.com/henrypp/simplewall/tree/master/bin/i18n/"
    click vs "https://github.com/henrypp/simplewall/blob/master/simplewall.sln"
    click build "https://github.com/henrypp/simplewall/blob/master/build.bat"
```
