# ramkumareinstein/aid architecture

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

- Interactive diagram: https://gitdiagram.com/ramkumareinstein/aid
- Repository: https://github.com/ramkumareinstein/aid

## Overview

1. **Repo shape**
   - This is a very small, single-purpose CLI repository.
   - The core application lives in one executable script, `aid`, with only supporting docs and license files.
   - There are no separate packages, services, or client/server boundaries; the architecture is a local filesystem scanner plus report generator.

2. **Primary runtime**
   - The tool is a Python 3.6+ command-line program.
   - It is intended to be run directly as `./aid`, which makes the script itself the main entrypoint and deployment unit.

3. **Top-level flow**
   - The user provides a target path.
   - The tool recursively walks the directory tree.
   - Each file is checked for binary-ness and excluded-directory membership before analysis.
   - Text files are scanned for invisible or suspicious Unicode code points.
   - Findings are aggregated into a per-file summary and written to a report.

4. **Filesystem boundary**
   - The main input boundary is the target directory on disk.
   - The main output boundary is a generated report file on disk, defaulting to `aid-report.csv`.
   - The scanner also consults a configurable exclusion list, with `.git` excluded by default.

5. **Scanning subsystem**
   - The scanner is focused on high-signal Unicode characters associated with smuggling and obfuscation.
   - Default detection covers Unicode tags, zero-width characters, directional/bidi marks, variation selectors, invisible operators, and deprecated format controls.
   - Optional modes widen the scan to classic control characters, suspicious/confusable spaces, and broader Unicode space separators.

6. **Binary and noise reduction**
   - Before Unicode inspection, files are filtered to avoid binary content.
   - The readme indicates MIME/null-byte based binary skipping, which is important because the tool is designed for source/text repositories rather than arbitrary blobs.
   - This keeps the signal-to-noise ratio high and avoids expensive or misleading analysis.

7. **Analysis and grouping**
   - The tool does more than count code points: it groups consecutive invisible characters into runs.
   - It separately tracks the longest general run and the longest pure Unicode-tag run.
   - It also counts unique code points and tallies character names, which makes the output useful for both security triage and forensic review.

8. **Suspicion classification**
   - Each file is assigned a suspicion level based on run length and total invisible-character volume.
   - The severity model is hierarchical: critical is driven by very long runs, while high/medium/info are determined by shorter runs and totals.
   - This makes the output suitable for prioritizing review rather than just listing raw detections.

9. **Unicode tag decoding path**
   - Unicode tag sequences are treated specially because they can encode hidden ASCII payloads.
   - The scanner decodes those sequences into readable notes in the report.
   - That creates an important data path from raw code points to human-readable hidden text.

10. **Report generation subsystem**
   - The final aggregation is rendered in one of three formats: CSV, JSON, or plain text.
   - CSV is the default and is structured for easy filtering by downstream tooling.
   - JSON supports programmatic consumption, while text is optimized for human review and console output.

11. **CLI and operational controls**
   - The command-line interface exposes the target path, output path, format selection, progress display, and optional scan toggles.
   - `--verbose` affects user feedback during traversal, not the analysis itself.
   - The scan-mode flags control how broad the detector is, which is a key architectural boundary between “strict/high-signal” and “broader/noisier” scanning.

12. **Integration style**
   - The repository is self-contained and has no external runtime dependencies or network services mentioned in the docs.
   - The only notable external touchpoints are the local filesystem, the Python runtime, and whatever shell tooling a user applies to the generated report afterward.

13. **How to diagram it**
   - A good architecture diagram would show: user/CLI input → recursive file traversal → exclusion/binary filter → Unicode detection and grouping → severity classification and tag decoding → report writer.
   - The most important boundaries are input directory, analysis pipeline, and report output, with optional scan modes branching off the detection stage.

Main entry points: [`aid`](https://github.com/ramkumareinstein/aid/tree/main/aid) (aid), [`README.md`](https://github.com/ramkumareinstein/aid/blob/main/README.md) (README)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_aid_script["aid<br/>python cli entrypoint"]
  node_cli_args["CLI args<br/>argument parsing"]
  node_target_dir[("Target dir<br/>filesystem input")]
  node_walker["Tree walk<br/>recursive traversal"]
  node_exclude_filter{{"Exclusions<br/>path filter"}}
  node_binary_filter{{"Binary skip<br/>content filter"}}
  node_unicode_scan["Unicode scan<br/>text detector"]
  node_scan_modes["Scan modes<br/>detection scope"]
  node_run_grouping["Run groups<br/>pattern aggregation"]
  node_tag_decode["Tag decode<br/>payload decoding"]
  node_suspicion_score{{"Severity<br/>classification"}}
  node_char_stats["Char stats<br/>forensic summary"]
  node_report_agg["Summary<br/>file aggregation"]
  node_report_writer["Report writer<br/>output renderer"]
  node_csv_out["CSV<br/>report format"]
  node_json_out["JSON<br/>report format"]
  node_text_out["Text<br/>report format"]
  node_report_file[("Report file<br/>filesystem output")]
end

subgraph group_docs["Docs"]
  node_readme["README<br/>documentation<br/>[README.md]"]
  node_license["LICENSE"]
end

node_aid_script -->|"parses"| node_cli_args
node_cli_args -->|"selects"| node_target_dir
node_cli_args -->|"toggles"| node_scan_modes
node_target_dir -->|"walks"| node_walker
node_walker -->|"filters"| node_exclude_filter
node_exclude_filter -->|"passes files"| node_binary_filter
node_binary_filter -->|"text only"| node_unicode_scan
node_scan_modes -.->|"expands scope"| node_unicode_scan
node_unicode_scan -->|"groups"| node_run_grouping
node_unicode_scan -->|"decodes"| node_tag_decode
node_run_grouping -->|"scores"| node_suspicion_score
node_unicode_scan -->|"counts"| node_char_stats
node_suspicion_score -->|"feeds"| node_report_agg
node_char_stats -->|"feeds"| node_report_agg
node_tag_decode -->|"feeds"| node_report_agg
node_report_agg -->|"renders"| node_report_writer
node_report_writer -->|"writes"| node_csv_out
node_report_writer -->|"writes"| node_json_out
node_report_writer -->|"writes"| node_text_out
node_csv_out -->|"persists"| node_report_file
node_json_out -->|"persists"| node_report_file
node_text_out -->|"persists"| node_report_file
node_readme -.->|"documents"| node_aid_script

click node_aid_script "https://github.com/ramkumareinstein/aid/tree/main/aid"
click node_readme "https://github.com/ramkumareinstein/aid/blob/main/README.md"
click node_license "https://github.com/ramkumareinstein/aid/tree/main/LICENSE"

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_aid_script,node_cli_args,node_target_dir,node_walker,node_exclude_filter,node_binary_filter,node_unicode_scan,node_scan_modes,node_run_grouping,node_tag_decode,node_suspicion_score,node_char_stats,node_report_agg,node_report_writer,node_csv_out,node_json_out,node_text_out,node_report_file toneBlue
class node_readme,node_license toneAmber
```

## Components

### Runtime

Executable scanner and its analysis pipeline.

- [aid](https://github.com/ramkumareinstein/aid/tree/main/aid): python cli entrypoint · Main executable script and deployment unit for the scanner. · `aid`
- **CLI args**: argument parsing · Parses target path, output path, format selection, progress, and scan toggles.
- **Target dir**: filesystem input · User-supplied directory tree to inspect.
- **Tree walk**: recursive traversal · Recursively visits files under the target directory.
- **Exclusions**: path filter · Skips excluded directories such as .git before analysis.
- **Binary skip**: content filter · Avoids binary or blob-like files using null-byte or MIME-style checks.
- **Unicode scan**: text detector · Scans text files for invisible and suspicious Unicode code points.
- **Scan modes**: detection scope · Optional switches broaden the detector to control characters, suspicious spaces, and broader separators.
- **Run groups**: pattern aggregation · Groups consecutive invisible characters into runs and tracks the longest general and tag-specific runs.
- **Tag decode**: payload decoding · Decodes Unicode tag sequences into readable hidden-text notes.
- **Severity**: classification · Assigns suspicion levels from info to critical based on run length and total invisible volume.
- **Char stats**: forensic summary · Counts unique code points and tallies character names for review.
- **Summary**: file aggregation · Combines per-file findings into a report-ready result set.
- **Report writer**: output renderer · Writes results as CSV, JSON, or plain text.
- **CSV**: report format · Default machine-friendly report format for filtering and downstream tooling.
- **JSON**: report format · Programmatic report format for structured consumption.
- **Text**: report format · Human-readable report format for console or manual review.
- **Report file**: filesystem output · Generated report on disk, defaulting to aid-report.csv.

### Docs

User-facing repository documentation.

- [README](https://github.com/ramkumareinstein/aid/blob/main/README.md): documentation · Usage and operational notes for the scanner. · `README.md`
- [LICENSE](https://github.com/ramkumareinstein/aid/tree/main/LICENSE): license · Repository license text. · `LICENSE`

## Connections

- aid → CLI args: parses · The executable script interprets command-line options and input paths.
- CLI args → Target dir: selects · CLI provides the root directory to scan.
- CLI args → Scan modes: toggles · Flags widen or narrow the detection scope.
- Target dir → Tree walk: walks · The scanner recursively traverses the chosen directory tree.
- Tree walk → Exclusions: filters · Excluded directories are skipped during traversal.
- Exclusions → Binary skip: passes files · Remaining candidates are checked for binary content before inspection.
- Binary skip → Unicode scan: text only · Only text-like files proceed to Unicode analysis.
- Scan modes → Unicode scan: expands scope · Optional modes broaden which code points are detected.
- Unicode scan → Run groups: groups · Detected invisible characters are clustered into runs.
- Unicode scan → Tag decode: decodes · Unicode tag sequences are converted into readable notes.
- Run groups → Severity: scores · Run lengths and total invisible volume drive severity.
- Unicode scan → Char stats: counts · The scanner tallies unique code points and names.
- Severity → Summary: feeds · Per-file severity contributes to the final summary.
- Char stats → Summary: feeds · Character statistics are included in the aggregate result.
- Tag decode → Summary: feeds · Decoded hidden text is carried into the report.
- Summary → Report writer: renders · Aggregated findings are formatted for output.
- Report writer → CSV: writes · CSV is the default report format.
- Report writer → JSON: writes · JSON is available for programmatic use.
- Report writer → Text: writes · Plain text supports human review.
- CSV → Report file: persists · The generated report is written to disk.
- JSON → Report file: persists · The generated report is written to disk.
- Text → Report file: persists · The generated report is written to disk.
- README → aid: documents · README explains how to run the CLI and interpret outputs.
