# dhakshi03/ip_access_manager architecture

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

- Interactive diagram: https://gitdiagram.com/dhakshi03/ip_access_manager
- Repository: https://github.com/dhakshi03/ip_access_manager

## Overview

#### Purpose and Entry Point
IP Access Manager is a local Python 3.8+ security-administration CLI that reconciles an IPv4 allowlist against a blocklist. Its executable entry point is `ip_access_manager.py`; operators supply the JSON state file as a positional argument, optionally with verbose or dry-run flags. The repository’s active policy data is `ip_config.json`.

#### CLI and Orchestration
`ip_access_manager.py` owns argument parsing, exception reporting, execution sequencing, and the final summary. It coordinates load → optional backup → validation/cleanup → persistence → audit reporting. Custom manager/config exceptions separate expected configuration and filesystem failures from generic failures.
- `ip_access_manager.py`
- `Sample_Run_Windows_PowerShell.txt`

#### Configuration Boundary
The JSON document is the system of record and contains two collections: `allowed` and `blocked`. Loading enforces readable, well-formed configuration; saving writes the reconciled lists back to that same source. This creates a clear mutable-state boundary: policy is file-backed rather than served by a database or remote API.
- `ip_config.json`
- `ip_access_manager.py`

#### Validation and Policy Reconciliation
The core processing stage validates each candidate as an IPv4 address using the Python standard library. Invalid entries from either list are excluded and audited. The resulting valid blocked set is then applied to the valid allowlist, ensuring a blocked address cannot remain permitted. The allowlist is rebuilt rather than modified during iteration.
- `ip_access_manager.py`
- `ip_config.json`

#### Mutation Safety: Backup and Dry Run
Before a real configuration update, the tool creates a timestamped copy under a runtime-generated `backups/` directory. Dry-run preserves the full validation and decision flow but suppresses backup and configuration writes, allowing operators to inspect expected effects before committing policy changes.
- `ip_access_manager.py`
- `ip_config.json`

#### Audit and Operator Feedback
Each validation failure and blocked-allowlist removal is recorded with a timestamp in a runtime-generated `log.txt`. Verbose mode emits per-IP decisions; every execution produces aggregate counts and whether files changed. Logs and backups are operational artifacts, not versioned repository inputs.
- `ip_access_manager.py`
- `Sample_Run_Windows_PowerShell.txt`

#### Runtime and Dependencies
This is a single-process, local command-line program with no web service, database, cloud infrastructure, or third-party package dependency. Material integrations are the host filesystem and Python standard-library modules for CLI parsing, JSON, IPv4 parsing, timestamps, copying, and file operations.
- `ip_access_manager.py`
- `README.md`

Main entry points: [`ip_access_manager.py`](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py) (Config load and save), [`ip_config.json`](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_config.json) (Policy JSON), [`Sample_Run_Windows_PowerShell.txt`](https://github.com/dhakshi03/ip_access_manager/blob/main/Sample_Run_Windows_PowerShell.txt) (PowerShell example), [`README.md`](https://github.com/dhakshi03/ip_access_manager/blob/main/README.md) (Runtime documentation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator Interface"]
  node_cli["IP Access Manager CLI<br/>Python entry point"]
  node_flags["Verbose and dry-run flags<br/>CLI options"]
  node_run_example["PowerShell example<br/>operator reference"]
  node_summary["Execution summary<br/>operator output"]
  node_readme["Runtime documentation<br/>[README.md]"]
end

subgraph group_core["Reconciliation Engine"]
  node_load_save["Config load and save<br/>JSON file boundary"]
  node_exceptions["Manager/config errors<br/>exception boundary"]
  node_ipv4_validation["IPv4 validation<br/>standard-library policy stage"]
  node_policy_reconciliation["Allowlist reconciliation<br/>policy stage"]
  node_change_decision{{"Mutation decision<br/>execution gate"}}
end

subgraph group_storage["File-backed State"]
  node_config[("Policy JSON<br/>system of record<br/>[ip_config.json]")]
end

subgraph group_artifacts["Runtime Artifacts"]
  node_backup["Timestamped backup<br/>filesystem copy"]
  node_audit_log["Audit log<br/>runtime log"]
end

node_run_example -.->|"shows invocation"| node_cli
node_readme -.->|"documents"| node_cli
node_flags -->|"controls execution"| node_cli
node_cli -->|"loads state"| node_load_save
node_config -->|"JSON input"| node_load_save
node_load_save -.->|"configuration failures"| node_exceptions
node_load_save -->|"allowed and blocked lists"| node_ipv4_validation
node_ipv4_validation -->|"valid lists"| node_policy_reconciliation
node_ipv4_validation -->|"invalid entries"| node_audit_log
node_policy_reconciliation -->|"removed allowed addresses"| node_audit_log
node_policy_reconciliation -->|"reconciled state"| node_change_decision
node_change_decision -->|"real update only"| node_backup
node_backup -->|"then permit save"| node_load_save
node_change_decision -->|"save unless dry-run"| node_load_save
node_load_save -->|"persist reconciled policy"| node_config
node_cli -->|"reports results"| node_summary
node_change_decision -->|"change status"| node_summary
node_exceptions -->|"reported failure"| node_summary

click node_cli "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_flags "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_run_example "https://github.com/dhakshi03/ip_access_manager/blob/main/Sample_Run_Windows_PowerShell.txt"
click node_config "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_config.json"
click node_load_save "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_exceptions "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_ipv4_validation "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_policy_reconciliation "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_change_decision "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_summary "https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py"
click node_readme "https://github.com/dhakshi03/ip_access_manager/blob/main/README.md"

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_cli,node_flags,node_run_example,node_summary,node_readme toneBlue
class node_load_save,node_exceptions,node_ipv4_validation,node_policy_reconciliation,node_change_decision toneAmber
class node_config toneMint
class node_backup,node_audit_log toneRose
```

## Components

### Operator Interface

- [IP Access Manager CLI](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): Python entry point · Parses arguments, sequences execution, handles errors, and prints the final summary. · `ip_access_manager.py`
- [Verbose and dry-run flags](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): CLI options · Dry-run suppresses mutation; verbose exposes per-IP decisions. · `ip_access_manager.py`
- [PowerShell example](https://github.com/dhakshi03/ip_access_manager/blob/main/Sample_Run_Windows_PowerShell.txt): operator reference · `Sample_Run_Windows_PowerShell.txt`
- [Execution summary](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): operator output · Reports aggregate counts and whether files changed. · `ip_access_manager.py`
- [Runtime documentation](https://github.com/dhakshi03/ip_access_manager/blob/main/README.md): documentation · `README.md`

### Reconciliation Engine

- [Config load and save](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): JSON file boundary · Reads validated JSON state and persists reconciled lists to the same file. · `ip_access_manager.py`
- [Manager/config errors](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): exception boundary · Separates expected configuration and filesystem failures from generic errors. · `ip_access_manager.py`
- [IPv4 validation](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): standard-library policy stage · Excludes malformed addresses from both policy lists. · `ip_access_manager.py`
- [Allowlist reconciliation](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): policy stage · Rebuilds the valid allowlist after removing addresses present in the valid blocklist. · `ip_access_manager.py`
- [Mutation decision](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_access_manager.py): execution gate · Determines whether reconciliation changed state and whether writes are permitted. · `ip_access_manager.py`

### File-backed State

- [Policy JSON](https://github.com/dhakshi03/ip_access_manager/blob/main/ip_config.json): system of record · Contains mutable allowed and blocked IPv4 collections. · `ip_config.json`

### Runtime Artifacts

- **Timestamped backup**: filesystem copy · Created before a real configuration update.
- **Audit log**: runtime log · Records invalid entries and blocked-allowlist removals with timestamps.

## Connections

- PowerShell example → IP Access Manager CLI: shows invocation
- Runtime documentation → IP Access Manager CLI: documents
- Verbose and dry-run flags → IP Access Manager CLI: controls execution
- IP Access Manager CLI → Config load and save: loads state
- Policy JSON → Config load and save: JSON input
- Config load and save → Manager/config errors: configuration failures
- Config load and save → IPv4 validation: allowed and blocked lists
- IPv4 validation → Allowlist reconciliation: valid lists
- IPv4 validation → Audit log: invalid entries
- Allowlist reconciliation → Audit log: removed allowed addresses
- Allowlist reconciliation → Mutation decision: reconciled state
- Mutation decision → Timestamped backup: real update only
- Timestamped backup → Config load and save: then permit save
- Mutation decision → Config load and save: save unless dry-run
- Config load and save → Policy JSON: persist reconciled policy
- IP Access Manager CLI → Execution summary: reports results
- Mutation decision → Execution summary: change status
- Manager/config errors → Execution summary: reported failure
