# sub-limal/ncas architecture

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

- Interactive diagram: https://gitdiagram.com/sub-limal/ncas
- Repository: https://github.com/sub-limal/ncas

## Overview

1. **Repository shape**
   This is a very small, script-centric Python project. The runtime logic appears to live primarily in a single module, `ncas.py`, with packaging metadata in `setup.py`, `pyproject.toml`, and `requirements.txt`. There are no separate app/server/data directories, which suggests a monolithic CLI utility rather than a layered service.

2. **Primary purpose**
   NCAS is a Windows-only Wi-Fi profile automation tool built as a wrapper over the native `netsh` command. Its job is to query, export, import, delete, and present saved WLAN profiles and passwords that already exist on the local machine.

3. **Core execution model**
   The application supports two entry paths:
   - **Direct CLI invocation** for one-off commands and automation
   - **Interactive menu mode** when run without arguments
   There is also a “continue” mode that executes supplied arguments and then drops into the interactive interface, so the CLI and menu are both front doors into the same underlying operations.

4. **Main functional subsystems**
   The README implies these internal feature clusters:
   - **Profile enumeration and password retrieval**: list saved SSIDs and reveal clear-text passwords
   - **Profile export/import**: back up and restore Wi-Fi profiles, especially via Windows XML profile format
   - **Profile deletion**: remove saved WLAN profiles from the system
   - **Reporting and diagnostics**: generate WLAN reports and inspect wireless interfaces
   - **Presentation utilities**: table output, colored terminal output, banner, simple UI mode
   - **Sharing helpers**: QR code generation and SVG saving
   - **Signal monitoring**: display signal strength/intensity in real time

5. **Data flow around netsh**
   The central data source is the local Windows WLAN subsystem accessed through `netsh`. Most commands likely follow a pattern of:
   1. Invoke `netsh` for profile/interface/report information
   2. Parse the command output
   3. Transform it into displayable records or exportable files
   4. Optionally call a second `netsh` command for export/import/delete operations
   This makes `netsh` the main external dependency and the architectural boundary between the script and the operating system.

6. **Persistence and file outputs**
   NCAS writes results to files in several formats:
   - **XML** for native Windows profile export/import
   - **TXT, CSV, JSON** for broader sharing/reporting
   - **SVG** for saved QR codes
   The repository also mentions an output directory that can be cleared, so the script likely maintains a local workspace for generated artifacts rather than a database or service-backed store.

7. **Presentation layer**
   The tool’s user-facing layer is terminal-based. It includes:
   - colored console output
   - a tabular display mode
   - an ASCII/banner startup mode
   - a simplified interface option
   - optional console clearing between prompts
   This indicates that formatting and UX are handled inside the same script, not delegated to a separate frontend.

8. **Command dispatch architecture**
   The command-line flags in the README map to discrete actions, so `ncas.py` likely contains an argument parser plus a dispatcher that routes each flag to a specific handler. The handlers appear to be organized by operation type rather than by object model, consistent with a utility tool optimized for command coverage.

9. **Platform boundary**
   The project is explicitly Windows-specific. The functionality depends on Windows networking behavior and the `netsh` WLAN command set, so the architecture is tightly coupled to the host OS. The README’s compatibility note for Windows 10/11 is an architectural constraint, not just a test result.

10. **Packaging and distribution**
   The presence of `setup.py`, `pyproject.toml`, and release instructions indicates the repo is packaged both for:
   - installation as a Python package via pip
   - distribution as a standalone executable
   The compiled executable is a packaging artifact, not a separate codebase.

11. **Dependencies and tooling**
   `requirements.txt` defines runtime dependencies, while `pyproject.toml` and `setup.py` support packaging/build metadata. The README mentions `auto-py-to-exe` for executable creation, which matters to the architecture only as a distribution/build-time tool, not as a runtime dependency.

12. **Likely architectural diagram boundaries**
   If you were drawing this system, the key boxes would be:
   - **User / CLI terminal**
   - **NCAS script (`ncas.py`)**
   - **Windows `netsh` / WLAN subsystem**
   - **Local output files** for exports, QR codes, and reports
   The main arrows are from user input into `ncas.py`, from `ncas.py` to `netsh`, and from `ncas.py` to generated files or formatted terminal output.

Main entry points: [`ncas.py`](https://github.com/sub-limal/ncas/blob/master/ncas.py) (Command router), [`pyproject.toml`](https://github.com/sub-limal/ncas/blob/master/pyproject.toml) (Package metadata), [`setup.py`](https://github.com/sub-limal/ncas/blob/master/setup.py) (Setup script), [`requirements.txt`](https://github.com/sub-limal/ncas/blob/master/requirements.txt) (Requirements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_user(("User<br/>operator"))
  node_cli["CLI entry<br/>input layer<br/>[ncas.py]"]
  node_menu["Menu mode<br/>ui layer<br/>[ncas.py]"]
  node_dispatch{{"Command router<br/>arg parser<br/>[ncas.py]"}}
  node_profiles["Profile ops<br/>wlan actions<br/>[ncas.py]"]
  node_reports["Reports<br/>diagnostics<br/>[ncas.py]"]
  node_signal["Signal monitor<br/>live status<br/>[ncas.py]"]
  node_share["Sharing tools<br/>export helper<br/>[ncas.py]"]
  node_present["Presentation<br/>terminal UI<br/>[ncas.py]"]
  node_outputs[("Output files<br/>artifacts")]
  node_netsh{{"netsh<br/>windows wlan"}}
  node_workspace[("Local workspace<br/>filesystem")]
end

subgraph group_distribution["Distribution"]
  node_packaging["Package metadata<br/>build config<br/>[pyproject.toml]"]
  node_setup["Setup script<br/>build config<br/>[setup.py]"]
  node_deps["Requirements<br/>dependency list<br/>[requirements.txt]"]
end

node_user -->|"invokes"| node_cli
node_user -->|"opens"| node_menu
node_cli -->|"parses"| node_dispatch
node_menu -->|"reuses"| node_dispatch
node_dispatch -->|"routes"| node_profiles
node_dispatch -->|"routes"| node_reports
node_dispatch -->|"routes"| node_signal
node_dispatch -->|"routes"| node_share
node_dispatch -->|"formats"| node_present
node_profiles -->|"queries"| node_netsh
node_profiles -->|"writes"| node_outputs
node_reports -->|"queries"| node_netsh
node_reports -->|"writes"| node_outputs
node_signal -->|"reads"| node_netsh
node_share -->|"writes"| node_outputs
node_present -->|"clears"| node_workspace
node_outputs -->|"stored in"| node_workspace
node_packaging -->|"supports"| node_setup
node_packaging -->|"declares"| node_deps
node_setup -->|"packages"| node_cli

click node_cli "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_menu "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_dispatch "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_profiles "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_reports "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_signal "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_share "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_present "https://github.com/sub-limal/ncas/blob/master/ncas.py"
click node_packaging "https://github.com/sub-limal/ncas/blob/master/pyproject.toml"
click node_setup "https://github.com/sub-limal/ncas/blob/master/setup.py"
click node_deps "https://github.com/sub-limal/ncas/blob/master/requirements.txt"

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_user,node_cli,node_menu,node_dispatch,node_profiles,node_reports,node_signal,node_share,node_present,node_outputs,node_netsh,node_workspace toneBlue
class node_packaging,node_setup,node_deps toneAmber
```

## Components

### Runtime

Interactive and command-driven Wi-Fi profile automation

- **User**: operator · Runs commands or uses the interactive menu
- [CLI entry](https://github.com/sub-limal/ncas/blob/master/ncas.py): input layer · Direct command-line invocation and continue mode · `ncas.py`
- [Menu mode](https://github.com/sub-limal/ncas/blob/master/ncas.py): ui layer · Interactive prompt flow when started without arguments · `ncas.py`
- [Command router](https://github.com/sub-limal/ncas/blob/master/ncas.py): arg parser · Parses flags and routes to the matching action handler · `ncas.py`
- [Profile ops](https://github.com/sub-limal/ncas/blob/master/ncas.py): wlan actions · Enumerates, reveals, exports, imports, and deletes saved WLAN profiles · `ncas.py`
- [Reports](https://github.com/sub-limal/ncas/blob/master/ncas.py): diagnostics · Generates WLAN reports and inspects wireless interfaces · `ncas.py`
- [Signal monitor](https://github.com/sub-limal/ncas/blob/master/ncas.py): live status · Displays signal strength and wireless status in real time · `ncas.py`
- [Sharing tools](https://github.com/sub-limal/ncas/blob/master/ncas.py): export helper · Creates QR codes and saves shareable artifacts · `ncas.py`
- [Presentation](https://github.com/sub-limal/ncas/blob/master/ncas.py): terminal UI · Banner, colors, tables, and simplified console formatting · `ncas.py`
- **Output files**: artifacts · Writes XML, TXT, CSV, JSON, and SVG artifacts to local storage
- **netsh**: windows wlan · Windows WLAN command boundary used for query and profile operations
- **Local workspace**: filesystem · Generated files and cleanup target for exported artifacts

### Distribution

Packaging and build metadata for installation and executable release

- [Package metadata](https://github.com/sub-limal/ncas/blob/master/pyproject.toml): build config · Project metadata for pip installation and release builds · `pyproject.toml`
- [Setup script](https://github.com/sub-limal/ncas/blob/master/setup.py): build config · Packaging entry used for installation and distribution · `setup.py`
- [Requirements](https://github.com/sub-limal/ncas/blob/master/requirements.txt): dependency list · Runtime dependency specification · `requirements.txt`

## Connections

- User → CLI entry: invokes · Direct command-line use starts the script
- User → Menu mode: opens · Running without arguments enters the interactive interface
- CLI entry → Command router: parses · CLI arguments are routed to handlers
- Menu mode → Command router: reuses · Menu actions call the same underlying dispatcher
- Command router → Profile ops: routes · Profile listing, export, import, delete, and password retrieval
- Command router → Reports: routes · Report generation and interface inspection
- Command router → Signal monitor: routes · Real-time signal display
- Command router → Sharing tools: routes · QR code and sharing helpers
- Command router → Presentation: formats · Common output formatting and console UX
- Profile ops → netsh: queries · Reads WLAN profiles and passwords from Windows
- Profile ops → Output files: writes · Exports profiles and serialized results
- Reports → netsh: queries · Collects WLAN reports and interface data
- Reports → Output files: writes · Persists report artifacts
- Signal monitor → netsh: reads · Polls wireless status and signal strength
- Sharing tools → Output files: writes · Saves QR/SVG sharing artifacts
- Presentation → Local workspace: clears · Console cleanup and output directory cleanup behavior
- Output files → Local workspace: stored in · Generated files land in the local workspace
- Package metadata → Setup script: supports · Build metadata complements the setup script
- Package metadata → Requirements: declares · Project dependencies are declared separately
- Setup script → CLI entry: packages · The script is packaged as the installable entry point
