# ah74n/saltbae architecture

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

- Interactive diagram: https://gitdiagram.com/ah74n/saltbae
- Repository: https://github.com/ah74n/saltbae

## Overview

#### Purpose and runtime
SaltBae is a local Flask application for authorized security assessments. It accepts contextual terms, generates targeted password candidates in memory, and returns a deduplicated, length-filtered dictionary. Python 3.10+ and Flask are the primary runtime dependencies; the bundled NCSC password corpus is its local data source.

Core entry point: `app.py`  
Generation engine: `logic.py`  
Dependency declaration: `requirements.txt`

#### Web application boundary
`app.py` hosts the Flask server and forms the boundary between browser requests and password-generation logic. It renders the single-page interface and handles generation requests, passing submitted user context into the engine and returning results to the client.

Relevant paths:
- `app.py`
- `templates/index.html`
- `logic.py`

#### Browser interface and request flow
The browser UI collects personal/contextual fields such as names, dates, organizations, hobbies, and custom keywords. Client-side behavior submits data to Flask and displays or enables retrieval of the generated dictionary. No separate frontend framework or external API is indicated.

Relevant paths:
- `templates/index.html`
- `static/js/main.js`
- `static/css/style.css`

#### Input normalization and tokenization
The generation pipeline begins by converting submitted fields into usable base tokens. This stage is responsible for splitting or normalizing contextual input—README identifies camel-case tokenization—and establishing the seed word set for downstream transformations.

Relevant path:
- `logic.py`

#### Heuristic mutation engine
The main engine derives candidate variants from each base token: case variants, reversed strings, leetspeak substitutions, numeric prefixes/suffixes, and symbol-bearing forms. This is the principal probability-focused generation stage, intended to favor common human password construction patterns over exhaustive brute force.

Relevant path:
- `logic.py`

#### Combination and pattern expansion
The engine combines multiple contextual words and numbers into compound candidates, including joined, underscore-separated, and symbol-separated patterns. Dates and common suffixes are incorporated into word-plus-number and multi-word forms. Candidate production is likely combinatorial, so this is the key scale/performance boundary.

Relevant path:
- `logic.py`

#### Corpus merge, filtering, and output
Generated candidates are merged with the bundled top-password dataset, deduplicated, and filtered by password length before response delivery. The corpus remains repository-local; user input and generated output are described as request-lifecycle/in-memory data rather than persisted records.

Relevant paths:
- `logic.py`
- `100k-most-used-passwords-NCSC.txt`
- `app.py`

#### Deployment and external dependencies
The system is self-contained aside from Flask and standard browser assets. The README references a PythonAnywhere demo deployment, but the repository exposes no database, queue, authentication provider, cloud storage, or third-party generation service. Operationally, deployment needs access to the application files and the NCSC corpus at runtime.

Relevant paths:
- `app.py`
- `requirements.txt`
- `100k-most-used-passwords-NCSC.txt`

Main entry points: [`app.py`](https://github.com/ah74n/saltbae/blob/main/app.py) (Flask server), [`templates/index.html`](https://github.com/ah74n/saltbae/blob/main/templates/index.html) (Single-page interface), [`logic.py`](https://github.com/ah74n/saltbae/blob/main/logic.py) (Merge, filter & dedupe), [`static/js/main.js`](https://github.com/ah74n/saltbae/blob/main/static/js/main.js) (Client behavior)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser UI"]
  node_ui["Single-page interface<br/>HTML UI<br/>[index.html]"]
  node_client_js["Client behavior<br/>JavaScript<br/>[main.js]"]
  node_styles["Interface styling<br/>CSS<br/>[style.css]"]
end

subgraph group_flask["Flask application"]
  node_flask_app{{"Flask server<br/>Python entry point<br/>[app.py]"}}
end

subgraph group_engine["Generation pipeline"]
  node_normalization["Input normalization<br/>tokenization stage<br/>[logic.py]"]
  node_mutation["Heuristic mutations<br/>candidate stage<br/>[logic.py]"]
  node_expansion["Combination expansion<br/>candidate stage<br/>[logic.py]"]
  node_output["Merge, filter &amp; dedupe<br/>output stage<br/>[logic.py]"]
  node_engine_module["Generation engine<br/>Python module<br/>[logic.py]"]
end

subgraph group_data["Local data &amp; dependencies"]
  node_corpus[("NCSC password corpus<br/>local dataset")]
  node_requirements["Runtime dependencies<br/>dependency manifest<br/>[requirements.txt]"]
end

node_styles -->|"styles"| node_ui
node_ui -->|"drives"| node_client_js
node_client_js -->|"submits context"| node_flask_app
node_flask_app -->|"renders / returns results"| node_ui
node_flask_app -->|"invokes"| node_engine_module
node_engine_module -->|"starts pipeline"| node_normalization
node_normalization -->|"base tokens"| node_mutation
node_mutation -->|"variants"| node_expansion
node_expansion -->|"candidates"| node_output
node_corpus -->|"merged with"| node_output
node_output -->|"in-memory dictionary"| node_flask_app
node_requirements -.->|"provides Flask"| node_flask_app

click node_ui "https://github.com/ah74n/saltbae/blob/main/templates/index.html"
click node_client_js "https://github.com/ah74n/saltbae/blob/main/static/js/main.js"
click node_styles "https://github.com/ah74n/saltbae/blob/main/static/css/style.css"
click node_flask_app "https://github.com/ah74n/saltbae/blob/main/app.py"
click node_normalization "https://github.com/ah74n/saltbae/blob/main/logic.py"
click node_mutation "https://github.com/ah74n/saltbae/blob/main/logic.py"
click node_expansion "https://github.com/ah74n/saltbae/blob/main/logic.py"
click node_output "https://github.com/ah74n/saltbae/blob/main/logic.py"
click node_engine_module "https://github.com/ah74n/saltbae/blob/main/logic.py"
click node_corpus "https://github.com/ah74n/saltbae/blob/main/100k-most-used-passwords-NCSC.txt"
click node_requirements "https://github.com/ah74n/saltbae/blob/main/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_ui,node_client_js,node_styles toneBlue
class node_flask_app toneAmber
class node_normalization,node_mutation,node_expansion,node_output,node_engine_module toneMint
class node_corpus,node_requirements toneRose
```

## Components

### Browser UI

- [Single-page interface](https://github.com/ah74n/saltbae/blob/main/templates/index.html): HTML UI · Collects contextual fields and presents generated dictionaries. · `templates/index.html`
- [Client behavior](https://github.com/ah74n/saltbae/blob/main/static/js/main.js): JavaScript · Submits form data and displays or retrieves results. · `static/js/main.js`
- [Interface styling](https://github.com/ah74n/saltbae/blob/main/static/css/style.css): CSS · `static/css/style.css`

### Flask application

- [Flask server](https://github.com/ah74n/saltbae/blob/main/app.py): Python entry point · Renders the UI, accepts generation requests, and returns results. · `app.py`

### Generation pipeline

- [Input normalization](https://github.com/ah74n/saltbae/blob/main/logic.py): tokenization stage · Builds base tokens from submitted context, including camel-case splitting. · `logic.py`
- [Heuristic mutations](https://github.com/ah74n/saltbae/blob/main/logic.py): candidate stage · Creates case, reverse, leetspeak, numeric, and symbol variants. · `logic.py`
- [Combination expansion](https://github.com/ah74n/saltbae/blob/main/logic.py): candidate stage · Builds multi-word, separator, date, and suffix patterns. · `logic.py`
- [Merge, filter & dedupe](https://github.com/ah74n/saltbae/blob/main/logic.py): output stage · Merges candidates, removes duplicates, and applies password-length filtering. · `logic.py`
- [Generation engine](https://github.com/ah74n/saltbae/blob/main/logic.py): Python module · In-memory password candidate generation pipeline. · `logic.py`

### Local data & dependencies

- [NCSC password corpus](https://github.com/ah74n/saltbae/blob/main/100k-most-used-passwords-NCSC.txt): local dataset · Bundled top-password source merged into output. · `100k-most-used-passwords-NCSC.txt`
- [Runtime dependencies](https://github.com/ah74n/saltbae/blob/main/requirements.txt): dependency manifest · Declares Flask and Python dependencies. · `requirements.txt`

## Connections

- Interface styling → Single-page interface: styles
- Single-page interface → Client behavior: drives
- Client behavior → Flask server: submits context
- Flask server → Single-page interface: renders / returns results
- Flask server → Generation engine: invokes
- Generation engine → Input normalization: starts pipeline
- Input normalization → Heuristic mutations: base tokens
- Heuristic mutations → Combination expansion: variants
- Combination expansion → Merge, filter & dedupe: candidates
- NCSC password corpus → Merge, filter & dedupe: merged with
- Merge, filter & dedupe → Flask server: in-memory dictionary
- Runtime dependencies → Flask server: provides Flask
