# ramonunch/altsnap architecture

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

- Interactive diagram: https://gitdiagram.com/ramonunch/altsnap
- Repository: https://github.com/ramonunch/altsnap

## Overview

AltSnap is a Windows utility for moving and resizing windows with Alt+mouse actions. The principal workflow is user input, action handling, and applying window movement, resizing, or snapping; configurable snap layouts are a distinct branch. The map also includes the tray/configuration and localization surfaces, plus compatibility support. Several internal links are supported by source-index references; broader runtime wiring is described at a high level in the README, since most source excerpts are partial.

Main entry points: [`hooks.c`](https://github.com/ramonunch/altsnap/blob/main/hooks.c) (Input and actions), [`altsnap.c`](https://github.com/ramonunch/altsnap/blob/main/altsnap.c) (Application entry), [`languages.c`](https://github.com/ramonunch/altsnap/blob/main/languages.c) (Localization), [`tray.c`](https://github.com/ramonunch/altsnap/blob/main/tray.c) (Tray controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Window interaction"]
  node_hooks["Input and actions<br/>[hooks.c]"]
  node_hook_contract["Action contracts<br/>[hooks.h]"]
  node_snap_state[("Snap state<br/>[snap.c]")]
end

subgraph group_layouts["Snapping and layouts"]
  node_snap_layouts["Snap layouts<br/>[zones.c]"]
end

subgraph group_controls["User controls"]
  node_app["Application entry<br/>[altsnap.c]"]
  node_tray["Tray controls<br/>[tray.c]"]
  node_configuration["Settings dialogs<br/>[config.c]"]
  node_resources["Dialog resources<br/>[resource.h]"]
  node_localization["Localization<br/>[languages.c]"]
  node_language_catalog["Language strings<br/>[languages.h]"]
  node_translations["Translation files"]
end

subgraph group_support["Runtime support"]
  node_thunks["Call thunks<br/>[thunks.c]"]
  node_compatibility["Windows compatibility<br/>[unfuck.h]"]
  node_c_helpers["C library helpers<br/>[nanolibc.h]"]
end

node_user(("Windows user"))
node_window_system["Windows windows"]

node_user -->|"starts and configures"| node_app
node_user -->|"selects windows"| node_window_system
node_app -.->|"enables interaction"| node_hooks
node_hooks -->|"moves and resizes"| node_window_system
node_hooks -->|"uses restore state"| node_snap_state
node_hooks -->|"dispatches layout actions"| node_snap_layouts
node_hooks -->|"uses thunks"| node_thunks
node_hooks -->|"includes definitions"| node_hook_contract
node_app -->|"updates tray"| node_tray
node_app -->|"loads settings UI"| node_configuration
node_app -->|"uses translations"| node_localization
node_configuration -->|"uses control IDs"| node_resources
node_localization -->|"loads string definitions"| node_language_catalog
node_localization -.->|"reads language files"| node_translations
node_tray -->|"saves layouts"| node_snap_layouts
node_compatibility -->|"includes helpers"| node_c_helpers

click node_app "https://github.com/ramonunch/altsnap/blob/main/altsnap.c"
click node_hooks "https://github.com/ramonunch/altsnap/blob/main/hooks.c"
click node_hook_contract "https://github.com/ramonunch/altsnap/blob/main/hooks.h"
click node_snap_state "https://github.com/ramonunch/altsnap/blob/main/snap.c"
click node_snap_layouts "https://github.com/ramonunch/altsnap/blob/main/zones.c"
click node_thunks "https://github.com/ramonunch/altsnap/blob/main/thunks.c"
click node_tray "https://github.com/ramonunch/altsnap/blob/main/tray.c"
click node_configuration "https://github.com/ramonunch/altsnap/blob/main/config.c"
click node_resources "https://github.com/ramonunch/altsnap/blob/main/resource.h"
click node_localization "https://github.com/ramonunch/altsnap/blob/main/languages.c"
click node_language_catalog "https://github.com/ramonunch/altsnap/blob/main/languages.h"
click node_translations "https://github.com/ramonunch/altsnap/tree/main/Lang"
click node_compatibility "https://github.com/ramonunch/altsnap/blob/main/unfuck.h"
click node_c_helpers "https://github.com/ramonunch/altsnap/blob/main/nanolibc.h"

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_hooks,node_hook_contract,node_snap_state,node_user toneBlue
class node_snap_layouts toneAmber
class node_app,node_tray,node_configuration,node_resources,node_localization,node_language_catalog,node_translations toneMint
class node_thunks,node_compatibility,node_c_helpers toneRose
class node_window_system toneIndigo
```

## Components

### Window interaction

- [Input and actions](https://github.com/ramonunch/altsnap/blob/main/hooks.c): `hooks.c`
- [Action contracts](https://github.com/ramonunch/altsnap/blob/main/hooks.h): `hooks.h`
- [Snap state](https://github.com/ramonunch/altsnap/blob/main/snap.c): `snap.c`

### Snapping and layouts

- [Snap layouts](https://github.com/ramonunch/altsnap/blob/main/zones.c): `zones.c`

### User controls

- [Application entry](https://github.com/ramonunch/altsnap/blob/main/altsnap.c): `altsnap.c`
- [Tray controls](https://github.com/ramonunch/altsnap/blob/main/tray.c): `tray.c`
- [Settings dialogs](https://github.com/ramonunch/altsnap/blob/main/config.c): `config.c`
- [Dialog resources](https://github.com/ramonunch/altsnap/blob/main/resource.h): `resource.h`
- [Localization](https://github.com/ramonunch/altsnap/blob/main/languages.c): `languages.c`
- [Language strings](https://github.com/ramonunch/altsnap/blob/main/languages.h): `languages.h`
- [Translation files](https://github.com/ramonunch/altsnap/tree/main/Lang): `Lang`

### Runtime support

- [Call thunks](https://github.com/ramonunch/altsnap/blob/main/thunks.c): `thunks.c`
- [Windows compatibility](https://github.com/ramonunch/altsnap/blob/main/unfuck.h): `unfuck.h`
- [C library helpers](https://github.com/ramonunch/altsnap/blob/main/nanolibc.h): `nanolibc.h`

### Other components

- **Windows user**
- **Windows windows**

## Connections

- Windows user → Application entry: starts and configures (evidence: `README.md`)
- Windows user → Windows windows: selects windows (evidence: `README.md`)
- Application entry → Input and actions: enables interaction
- Input and actions → Windows windows: moves and resizes (evidence: `README.md`)
- Input and actions → Snap state: uses restore state (evidence: `hooks.c`)
- Input and actions → Snap layouts: dispatches layout actions (evidence: `hooks.c`)
- Input and actions → Call thunks: uses thunks (evidence: `hooks.c`)
- Input and actions → Action contracts: includes definitions (evidence: `hooks.c`)
- Application entry → Tray controls: updates tray (evidence: `altsnap.c`)
- Application entry → Settings dialogs: loads settings UI (evidence: `altsnap.c`)
- Application entry → Localization: uses translations (evidence: `altsnap.c`)
- Settings dialogs → Dialog resources: uses control IDs (evidence: `config.c`)
- Localization → Language strings: loads string definitions (evidence: `languages.c`)
- Localization → Translation files: reads language files
- Tray controls → Snap layouts: saves layouts (evidence: `tray.c`)
- Windows compatibility → C library helpers: includes helpers (evidence: `unfuck.h`)
