# samaliyan/countryipfilter architecture

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

- Interactive diagram: https://gitdiagram.com/samaliyan/countryipfilter
- Repository: https://github.com/samaliyan/countryipfilter

## Overview

Country IP Filter is a Windows desktop firewall manager: users choose countries and TCP/UDP ports or programs, then enable protection so only selected-country IPv4 ranges can connect. The UI delegates actions to application logic, which obtains and aggregates country ranges, applies firewall rules, and checks the resulting firewall state for problems. The README documents scheduled monthly updates and restoration of pre-existing rules. Some subsystem links are documented rather than visible in the sampled excerpts; those are cited to the README.

Main entry points: [`gui_windows.go`](https://github.com/samaliyan/countryipfilter/blob/main/gui_windows.go) (Windows window), [`core.go`](https://github.com/samaliyan/countryipfilter/blob/main/core.go) (Protection and ranges), [`scripts.go`](https://github.com/samaliyan/countryipfilter/blob/main/scripts.go) (Firewall and update scripts), [`app.go`](https://github.com/samaliyan/countryipfilter/blob/main/app.go) (Button actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Desktop interface"]
  node_window["Windows window<br/>[gui_windows.go]"]
  node_layout["Window layout<br/>[layout.go]"]
  node_translations["English and Persian<br/>[i18n.go]"]
  node_countries["Country names<br/>[countries.go]"]
  node_ports["Service ports<br/>[ports.go]"]
end

subgraph group_workflow["Protection workflow"]
  node_app["Button actions<br/>[app.go]"]
  node_core["Protection and ranges<br/>[core.go]"]
  node_view["Status and fixes view<br/>[view.go]"]
end

subgraph group_firewall["Firewall operations"]
  node_status["Firewall state analysis<br/>[status.go]"]
  node_scripts["Firewall and update scripts<br/>[scripts.go]"]
  node_system["Windows execution and permissions<br/>[sys_windows.go]"]
end

subgraph group_support["Supporting features"]
  node_scheduled_task["Monthly scheduled update<br/>[scripts.go]"]
  node_old_rules[("Existing firewall rules<br/>[scripts.go]")]
  node_language_settings["Language settings<br/>[i18n.go]"]
end

node_user(("Server administrator"))
node_registry{{"RIPEstat"}}
node_powershell{{"Windows PowerShell"}}
node_firewall_service[("Windows Firewall")]

node_user -->|"uses"| node_window
node_window -->|"dispatches actions"| node_app
node_window -->|"uses layout"| node_layout
node_window -->|"shows text"| node_translations
node_window -->|"shows countries"| node_countries
node_window -->|"offers services"| node_ports
node_app -->|"requests operations"| node_core
node_app -->|"refreshes view"| node_view
node_core -->|"downloads ranges"| node_registry
node_core -->|"builds scripts"| node_scripts
node_core -->|"parses status"| node_status
node_scripts -->|"runs commands"| node_powershell
node_powershell -->|"changes rules"| node_firewall_service
node_system -->|"executes scripts"| node_powershell
node_status -.->|"informs assessment"| node_view
node_scripts -->|"supports updates"| node_scheduled_task
node_scheduled_task -->|"downloads ranges"| node_registry
node_scripts -->|"restores rules"| node_old_rules
node_core -->|"stores settings"| node_language_settings

click node_window "https://github.com/samaliyan/countryipfilter/blob/main/gui_windows.go"
click node_layout "https://github.com/samaliyan/countryipfilter/blob/main/layout.go"
click node_translations "https://github.com/samaliyan/countryipfilter/blob/main/i18n.go"
click node_countries "https://github.com/samaliyan/countryipfilter/blob/main/countries.go"
click node_ports "https://github.com/samaliyan/countryipfilter/blob/main/ports.go"
click node_app "https://github.com/samaliyan/countryipfilter/blob/main/app.go"
click node_core "https://github.com/samaliyan/countryipfilter/blob/main/core.go"
click node_status "https://github.com/samaliyan/countryipfilter/blob/main/status.go"
click node_view "https://github.com/samaliyan/countryipfilter/blob/main/view.go"
click node_scripts "https://github.com/samaliyan/countryipfilter/blob/main/scripts.go"
click node_system "https://github.com/samaliyan/countryipfilter/blob/main/sys_windows.go"
click node_scheduled_task "https://github.com/samaliyan/countryipfilter/blob/main/scripts.go"
click node_old_rules "https://github.com/samaliyan/countryipfilter/blob/main/scripts.go"
click node_language_settings "https://github.com/samaliyan/countryipfilter/blob/main/i18n.go"

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_window,node_layout,node_translations,node_countries,node_ports toneBlue
class node_app,node_core,node_view,node_firewall_service toneAmber
class node_status,node_scripts,node_system,node_user toneMint
class node_scheduled_task,node_old_rules,node_language_settings toneRose
class node_registry,node_powershell toneIndigo
```

## Components

### Desktop interface

- [Windows window](https://github.com/samaliyan/countryipfilter/blob/main/gui_windows.go): `gui_windows.go`
- [Window layout](https://github.com/samaliyan/countryipfilter/blob/main/layout.go): `layout.go`
- [English and Persian](https://github.com/samaliyan/countryipfilter/blob/main/i18n.go): `i18n.go`
- [Country names](https://github.com/samaliyan/countryipfilter/blob/main/countries.go): `countries.go`
- [Service ports](https://github.com/samaliyan/countryipfilter/blob/main/ports.go): `ports.go`

### Protection workflow

- [Button actions](https://github.com/samaliyan/countryipfilter/blob/main/app.go): `app.go`
- [Protection and ranges](https://github.com/samaliyan/countryipfilter/blob/main/core.go): `core.go`
- [Status and fixes view](https://github.com/samaliyan/countryipfilter/blob/main/view.go): `view.go`

### Firewall operations

- [Firewall state analysis](https://github.com/samaliyan/countryipfilter/blob/main/status.go): `status.go`
- [Firewall and update scripts](https://github.com/samaliyan/countryipfilter/blob/main/scripts.go): `scripts.go`
- [Windows execution and permissions](https://github.com/samaliyan/countryipfilter/blob/main/sys_windows.go): `sys_windows.go`

### Supporting features

- [Monthly scheduled update](https://github.com/samaliyan/countryipfilter/blob/main/scripts.go): `scripts.go`
- [Existing firewall rules](https://github.com/samaliyan/countryipfilter/blob/main/scripts.go): `scripts.go`
- [Language settings](https://github.com/samaliyan/countryipfilter/blob/main/i18n.go): `i18n.go`

### Other components

- **Server administrator**
- **RIPEstat**
- **Windows PowerShell**
- **Windows Firewall**

## Connections

- Server administrator → Windows window: uses (evidence: `README.md`)
- Windows window → Button actions: dispatches actions (evidence: `gui_windows.go`)
- Windows window → Window layout: uses layout (evidence: `README.md`)
- Windows window → English and Persian: shows text (evidence: `gui_windows.go`)
- Windows window → Country names: shows countries (evidence: `README.md`)
- Windows window → Service ports: offers services (evidence: `README.md`)
- Button actions → Protection and ranges: requests operations (evidence: `app.go`)
- Button actions → Status and fixes view: refreshes view (evidence: `app.go`)
- Protection and ranges → RIPEstat: downloads ranges (evidence: `README.md`)
- Protection and ranges → Firewall and update scripts: builds scripts (evidence: `core.go`)
- Protection and ranges → Firewall state analysis: parses status (evidence: `core.go`)
- Firewall and update scripts → Windows PowerShell: runs commands (evidence: `README.md`)
- Windows PowerShell → Windows Firewall: changes rules (evidence: `README.md`)
- Windows execution and permissions → Windows PowerShell: executes scripts (evidence: `sys_windows.go`)
- Firewall state analysis → Status and fixes view: informs assessment
- Firewall and update scripts → Monthly scheduled update: supports updates (evidence: `README.md`)
- Monthly scheduled update → RIPEstat: downloads ranges (evidence: `README.md`)
- Firewall and update scripts → Existing firewall rules: restores rules (evidence: `README.md`)
- Protection and ranges → Language settings: stores settings (evidence: `i18n.go`)
