# al1-gif/blockart architecture

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

- Interactive diagram: https://gitdiagram.com/al1-gif/blockart
- Repository: https://github.com/al1-gif/blockart

## Overview

This browser-based CubeArt Generator turns uploaded face textures into a Minecraft block cube, previews it, and exports either a datapack or Litematica schematic. The main workflow is managed in script.js: texture input and palette settings feed grid construction and preview; export actions generate their respective files. The excerpts show preview rendering and export formats, but not all input, command-generation, or page wiring, so those links are limited to what the source demonstrates.

Main entry points: [`script.js`](https://github.com/al1-gif/blockart/blob/master/script.js) (Voxel grid), [`cubearedownload.js`](https://github.com/al1-gif/blockart/blob/master/cubearedownload.js) (Datapack export), [`palette.js`](https://github.com/al1-gif/blockart/blob/master/palette.js) (Block palette), [`index.html`](https://github.com/al1-gif/blockart/blob/master/index.html) (Generator interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Texture and palette"]
  node_ui["Generator interface<br/>[index.html]"]
  node_texture["Texture loading<br/>[script.js]"]
  node_palette["Block palette<br/>[palette.js]"]
  node_selection["Block selection<br/>[script.js]"]
end

subgraph group_build["Cube construction"]
  node_grid["Voxel grid<br/>[script.js]"]
  node_matching["Block matching<br/>[script.js]"]
end

subgraph group_view["Preview"]
  node_preview["Face preview<br/>[script.js]"]
  node_viewer["3D cube viewer<br/>[preview.js]"]
end

subgraph group_export["Minecraft exports"]
  node_commands["Command generation<br/>[script.js]"]
  node_datapack["Datapack export<br/>[cubearedownload.js]"]
  node_schematic["Litematica export<br/>[cubearedownload.js]"]
end

node_user(("User"))
node_zip["JSZip"]
node_icons["Block textures"]
node_download["Downloaded file"]

node_user -->|"operates"| node_ui
node_ui -->|"accepts uploads"| node_texture
node_texture -->|"provides face pixels"| node_grid
node_palette -->|"provides block data"| node_selection
node_selection -->|"filters candidates"| node_matching
node_matching -->|"assigns blocks"| node_grid
node_grid -->|"renders grid"| node_preview
node_preview -->|"renders cube"| node_viewer
node_palette -->|"supplies face colors"| node_preview
node_preview -->|"loads block icons"| node_icons
node_user -->|"requests datapack"| node_commands
node_commands -->|"provides commands"| node_datapack
node_user -->|"requests schematic"| node_schematic
node_grid -->|"serializes blocks"| node_schematic
node_datapack -->|"packages files"| node_zip
node_datapack -->|"offers ZIP"| node_download
node_schematic -->|"offers schematic"| node_download

click node_ui "https://github.com/al1-gif/blockart/blob/master/index.html"
click node_texture "https://github.com/al1-gif/blockart/blob/master/script.js"
click node_palette "https://github.com/al1-gif/blockart/blob/master/palette.js"
click node_selection "https://github.com/al1-gif/blockart/blob/master/script.js"
click node_grid "https://github.com/al1-gif/blockart/blob/master/script.js"
click node_matching "https://github.com/al1-gif/blockart/blob/master/script.js"
click node_preview "https://github.com/al1-gif/blockart/blob/master/script.js"
click node_viewer "https://github.com/al1-gif/blockart/blob/master/preview.js"
click node_commands "https://github.com/al1-gif/blockart/blob/master/script.js"
click node_datapack "https://github.com/al1-gif/blockart/blob/master/cubearedownload.js"
click node_schematic "https://github.com/al1-gif/blockart/blob/master/cubearedownload.js"
click node_icons "https://github.com/al1-gif/blockart/tree/master/icons"

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_texture,node_palette,node_selection,node_user toneBlue
class node_grid,node_matching toneAmber
class node_preview,node_viewer toneMint
class node_commands,node_datapack,node_schematic toneRose
class node_zip,node_download toneIndigo
class node_icons toneTeal
```

## Components

### Texture and palette

- [Generator interface](https://github.com/al1-gif/blockart/blob/master/index.html): `index.html`
- [Texture loading](https://github.com/al1-gif/blockart/blob/master/script.js): `script.js`
- [Block palette](https://github.com/al1-gif/blockart/blob/master/palette.js): `palette.js`
- [Block selection](https://github.com/al1-gif/blockart/blob/master/script.js): `script.js`

### Cube construction

- [Voxel grid](https://github.com/al1-gif/blockart/blob/master/script.js): `script.js`
- [Block matching](https://github.com/al1-gif/blockart/blob/master/script.js): `script.js`

### Preview

- [Face preview](https://github.com/al1-gif/blockart/blob/master/script.js): `script.js`
- [3D cube viewer](https://github.com/al1-gif/blockart/blob/master/preview.js): `preview.js`

### Minecraft exports

- [Command generation](https://github.com/al1-gif/blockart/blob/master/script.js): `script.js`
- [Datapack export](https://github.com/al1-gif/blockart/blob/master/cubearedownload.js): `cubearedownload.js`
- [Litematica export](https://github.com/al1-gif/blockart/blob/master/cubearedownload.js): `cubearedownload.js`

### Other components

- **User**
- **JSZip**
- [Block textures](https://github.com/al1-gif/blockart/tree/master/icons): `icons`
- **Downloaded file**

## Connections

- User → Generator interface: operates
- Generator interface → Texture loading: accepts uploads (evidence: `script.js`)
- Texture loading → Voxel grid: provides face pixels (evidence: `script.js`)
- Block palette → Block selection: provides block data (evidence: `script.js`)
- Block selection → Block matching: filters candidates (evidence: `script.js`)
- Block matching → Voxel grid: assigns blocks (evidence: `script.js`)
- Voxel grid → Face preview: renders grid (evidence: `script.js`)
- Face preview → 3D cube viewer: renders cube (evidence: `preview.js`)
- Block palette → Face preview: supplies face colors (evidence: `script.js`)
- Face preview → Block textures: loads block icons (evidence: `script.js`)
- User → Command generation: requests datapack
- Command generation → Datapack export: provides commands (evidence: `cubearedownload.js`)
- User → Litematica export: requests schematic (evidence: `cubearedownload.js`)
- Voxel grid → Litematica export: serializes blocks (evidence: `cubearedownload.js`)
- Datapack export → JSZip: packages files (evidence: `cubearedownload.js`)
- Datapack export → Downloaded file: offers ZIP (evidence: `cubearedownload.js`)
- Litematica export → Downloaded file: offers schematic (evidence: `cubearedownload.js`)
