# crash-predictor1/aviator-predictor architecture

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

- Interactive diagram: https://gitdiagram.com/crash-predictor1/aviator-predictor
- Repository: https://github.com/crash-predictor1/aviator-predictor

## Overview

#### Purpose and Scope
Despite the README’s predictor branding, the repository contents implement a TypeScript SHA hashing library and its distributable JavaScript bundles. It provides incremental and one-shot hashing for SHA-1, SHA-256, SHA-512, and SHA-3 families; no predictor application, AI service, seed-analysis workflow, backend, or mobile runtime is present in the tree.

#### Public Entry Points and Distribution
The source-level API is organized around algorithm modules, with the shared hash abstraction in `src/sha.ts` and individual exports in `src/sha1.ts`, `src/sha256.ts`, `src/sha3.ts`, and `src/sha512.ts`. Built outputs are committed under `dist/`, including browser/CommonJS-style JavaScript, ESM bundles, and TypeScript declarations such as `dist/sha.js`, `dist/sha.mjs`, and `dist/sha.d.ts`.

#### Hash Engine Core
`src/sha.ts` defines the common streaming hash lifecycle: initialize state, accept updates, finalize padding, and emit digests. `src/common.ts` supplies shared internal mechanics used across algorithms. The engine is designed around local, deterministic computation: input enters via update methods, is processed in blocks, then finalized into an encoded digest. There are no network, persistence, user-account, or external API boundaries.

#### Algorithm Families
Algorithm-specific implementations own compression rounds, initial state, block size, and digest behavior:
- SHA-1: `src/sha1.ts`
- SHA-2 256-bit family: `src/sha256.ts`
- SHA-2 512-bit family: `src/sha512.ts`
- SHA-3/Keccak family: `src/sha3.ts`

These modules sit above the common hash interface and select the word arithmetic appropriate to their algorithm.

#### Numeric and Encoding Boundaries
JavaScript bitwise operations are insufficient for full 64-bit SHA-512 state, so the code separates arithmetic primitives by word width: `src/primitives_32.ts` supports 32-bit algorithms, while `src/primitives_64.ts` supports paired/high-low 64-bit operations. Input/output representation conversion is centralized in `src/converters.ts`; internal type contracts are in `src/custom_types.ts`. This is the main correctness boundary between caller-provided strings/bytes and algorithm word state.

#### Build and Runtime Targets
The project is a Node.js/TypeScript package built with Rollup. `rollup.config.mjs` produces the committed `dist/` JavaScript and module artifacts, while `tsconfig.json` governs source compilation. The package supports browser consumption as indicated by `index.html` and Karma configuration in `karma.conf.js`, alongside package consumers using ESM, JavaScript bundles, or declaration files. No server infrastructure or hosted service is defined.

#### Architectural Flow
A consumer imports an algorithm bundle from `dist/` (or source module during development), creates or invokes a hash implementation, supplies data through the common update path, and receives a digest converted into the requested representation. The algorithm module delegates block operations to 32- or 64-bit primitives and shared conversion logic. Release artifacts preserve this API for JavaScript, ESM, and TypeScript consumers.

Main entry points: [`src/sha.ts`](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha.ts) (Streaming hash lifecycle), [`rollup.config.mjs`](https://github.com/crash-predictor1/aviator-predictor/blob/main/rollup.config.mjs) (Rollup build), [`src/primitives_32.ts`](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/primitives_32.ts) (32-bit primitives), [`dist/sha.js`](https://github.com/crash-predictor1/aviator-predictor/blob/main/dist/sha.js) (JavaScript bundle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_source["TypeScript hash engine"]
  node_sha_base["Streaming hash lifecycle<br/>shared abstraction<br/>[sha.ts]"]
  node_common["Shared hash mechanics<br/>internal core<br/>[common.ts]"]
  node_sha1["SHA-1<br/>algorithm module<br/>[sha1.ts]"]
  node_sha256["SHA-2 256-bit<br/>algorithm module<br/>[sha256.ts]"]
  node_sha512["SHA-2 512-bit<br/>algorithm module<br/>[sha512.ts]"]
  node_sha3["SHA-3 / Keccak<br/>algorithm module<br/>[sha3.ts]"]
end

subgraph group_numeric["Numeric and encoding"]
  node_primitives32["32-bit primitives<br/>word arithmetic<br/>[primitives_32.ts]"]
  node_primitives64["64-bit primitives<br/>paired-word arithmetic<br/>[primitives_64.ts]"]
  node_converters["Input/output conversion<br/>encoding boundary<br/>[converters.ts]"]
  node_types["Internal type contracts<br/>TypeScript types<br/>[custom_types.ts]"]
end

subgraph group_distribution["Build and distribution"]
  node_rollup["Rollup build<br/>bundler<br/>[rollup.config.mjs]"]
  node_tsconfig["TypeScript compilation<br/>compiler settings<br/>[tsconfig.json]"]
  node_dist_js["JavaScript bundle<br/>distribution artifact<br/>[sha.js]"]
  node_dist_esm["ESM bundle<br/>distribution artifact<br/>[sha.mjs]"]
  node_dist_types["Type declarations<br/>distribution artifact<br/>[sha.d.ts]"]
end

node_consumer(("Package consumer<br/>caller"))
node_browser["Browser consumer<br/>runtime target<br/>[index.html]"]

node_consumer -->|"imports"| node_dist_js
node_consumer -->|"imports"| node_dist_esm
node_consumer -.->|"types"| node_dist_types
node_browser -->|"loads"| node_dist_js
node_sha1 -->|"uses lifecycle"| node_sha_base
node_sha256 -->|"uses lifecycle"| node_sha_base
node_sha512 -->|"uses lifecycle"| node_sha_base
node_sha3 -->|"uses lifecycle"| node_sha_base
node_sha_base -->|"shared block mechanics"| node_common
node_sha_base -->|"input and digest encoding"| node_converters
node_sha1 -->|"32-bit rounds"| node_primitives32
node_sha256 -->|"32-bit rounds"| node_primitives32
node_sha512 -->|"64-bit rounds"| node_primitives64
node_sha3 -->|"word operations"| node_primitives32
node_sha_base -.->|"contracts"| node_types
node_rollup -->|"builds"| node_dist_js
node_rollup -->|"builds"| node_dist_esm
node_rollup -->|"emits"| node_dist_types
node_tsconfig -.->|"governs source compilation"| node_rollup

click node_sha_base "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha.ts"
click node_common "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/common.ts"
click node_sha1 "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha1.ts"
click node_sha256 "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha256.ts"
click node_sha512 "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha512.ts"
click node_sha3 "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha3.ts"
click node_primitives32 "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/primitives_32.ts"
click node_primitives64 "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/primitives_64.ts"
click node_converters "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/converters.ts"
click node_types "https://github.com/crash-predictor1/aviator-predictor/blob/main/src/custom_types.ts"
click node_rollup "https://github.com/crash-predictor1/aviator-predictor/blob/main/rollup.config.mjs"
click node_tsconfig "https://github.com/crash-predictor1/aviator-predictor/blob/main/tsconfig.json"
click node_dist_js "https://github.com/crash-predictor1/aviator-predictor/blob/main/dist/sha.js"
click node_dist_esm "https://github.com/crash-predictor1/aviator-predictor/blob/main/dist/sha.mjs"
click node_dist_types "https://github.com/crash-predictor1/aviator-predictor/blob/main/dist/sha.d.ts"
click node_browser "https://github.com/crash-predictor1/aviator-predictor/blob/main/index.html"

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_sha_base,node_common,node_sha1,node_sha256,node_sha512,node_sha3 toneBlue
class node_primitives32,node_primitives64,node_converters,node_types toneAmber
class node_rollup,node_tsconfig,node_dist_js,node_dist_esm,node_dist_types toneMint
class node_consumer,node_browser toneNeutral
```

## Components

### TypeScript hash engine

- [Streaming hash lifecycle](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha.ts): shared abstraction · Initializes, updates, pads, and emits digests. · `src/sha.ts`
- [Shared hash mechanics](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/common.ts): internal core · `src/common.ts`
- [SHA-1](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha1.ts): algorithm module · `src/sha1.ts`
- [SHA-2 256-bit](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha256.ts): algorithm module · `src/sha256.ts`
- [SHA-2 512-bit](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha512.ts): algorithm module · `src/sha512.ts`
- [SHA-3 / Keccak](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/sha3.ts): algorithm module · `src/sha3.ts`

### Numeric and encoding

- [32-bit primitives](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/primitives_32.ts): word arithmetic · `src/primitives_32.ts`
- [64-bit primitives](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/primitives_64.ts): paired-word arithmetic · Supports SHA-512 high/low word operations. · `src/primitives_64.ts`
- [Input/output conversion](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/converters.ts): encoding boundary · Converts caller strings and bytes to and from internal words. · `src/converters.ts`
- [Internal type contracts](https://github.com/crash-predictor1/aviator-predictor/blob/main/src/custom_types.ts): TypeScript types · `src/custom_types.ts`

### Build and distribution

- [Rollup build](https://github.com/crash-predictor1/aviator-predictor/blob/main/rollup.config.mjs): bundler · Produces committed package artifacts. · `rollup.config.mjs`
- [TypeScript compilation](https://github.com/crash-predictor1/aviator-predictor/blob/main/tsconfig.json): compiler settings · `tsconfig.json`
- [JavaScript bundle](https://github.com/crash-predictor1/aviator-predictor/blob/main/dist/sha.js): distribution artifact · `dist/sha.js`
- [ESM bundle](https://github.com/crash-predictor1/aviator-predictor/blob/main/dist/sha.mjs): distribution artifact · `dist/sha.mjs`
- [Type declarations](https://github.com/crash-predictor1/aviator-predictor/blob/main/dist/sha.d.ts): distribution artifact · `dist/sha.d.ts`

### Other components

- **Package consumer**: caller · Uses one-shot or incremental hash APIs.
- [Browser consumer](https://github.com/crash-predictor1/aviator-predictor/blob/main/index.html): runtime target · `index.html`

## Connections

- Package consumer → JavaScript bundle: imports
- Package consumer → ESM bundle: imports
- Package consumer → Type declarations: types
- Browser consumer → JavaScript bundle: loads
- SHA-1 → Streaming hash lifecycle: uses lifecycle
- SHA-2 256-bit → Streaming hash lifecycle: uses lifecycle
- SHA-2 512-bit → Streaming hash lifecycle: uses lifecycle
- SHA-3 / Keccak → Streaming hash lifecycle: uses lifecycle
- Streaming hash lifecycle → Shared hash mechanics: shared block mechanics
- Streaming hash lifecycle → Input/output conversion: input and digest encoding
- SHA-1 → 32-bit primitives: 32-bit rounds
- SHA-2 256-bit → 32-bit primitives: 32-bit rounds
- SHA-2 512-bit → 64-bit primitives: 64-bit rounds
- SHA-3 / Keccak → 32-bit primitives: word operations
- Streaming hash lifecycle → Internal type contracts: contracts
- Rollup build → JavaScript bundle: builds
- Rollup build → ESM bundle: builds
- Rollup build → Type declarations: emits
- TypeScript compilation → Rollup build: governs source compilation
