# macabeus/urnadecomp architecture

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

- Interactive diagram: https://gitdiagram.com/macabeus/urnadecomp
- Repository: https://github.com/macabeus/urnadecomp

## Overview

UrnaDecomp reconstructs the TSE voting simulator’s VOTA C++ and verifies that a rebuild matches the published WebAssembly module byte for byte. The principal workflow uses the asmlift-wasm toolkit to inspect target functions, produce and rank compilable C++ candidates, and verify matches through the splat build; the web playground exposes function inspection and match-progress views. The tree and README support the broad workflow, while some tool and application internals were not sampled, so uncertain connections are omitted.

Main entry points: [`target/vota_web_wasm.js`](https://github.com/macabeus/urnadecomp/blob/main/target/vota_web_wasm.js) (Target module), [`asmlift-wasm/playground/src/App.tsx`](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/App.tsx) (Web app shell), [`asmlift-wasm/playground/src/pages/playground/Playground.tsx`](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/pages/playground/Playground.tsx) (Function playground), [`asmlift-wasm/src/parse.ts`](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/parse.ts) (Module parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web views"]
  node_webapp["Web app shell<br/>[App.tsx]"]
  node_playground["Function playground<br/>[Playground.tsx]"]
  node_progress["Progress meter<br/>[Progress.tsx]"]
  node_emu["Urna simulator view<br/>[UrnaEmu.tsx]"]
  node_urlstate["URL state<br/>[url-state.ts]"]
end

subgraph group_analysis["Wasm analysis"]
  node_parser["Module parser<br/>[parse.ts]"]
  node_leb["LEB decoder<br/>[leb.ts]"]
  node_disasm["Function disassembler<br/>[disasm.ts]"]
  node_normalize["Function normalizer<br/>[normalize.ts]"]
  node_lifter["C++ lifter<br/>[lift.ts]"]
  node_ranking["Candidate ranking<br/>[rank.ts]"]
  node_readout["Function readout<br/>[readout.ts]"]
end

subgraph group_matching["Match verification"]
  node_census["Function census<br/>[census.ts]"]
  node_ledger[("Function ledger<br/>[ledger.ts]")]
  node_symbols["Symbol mapping<br/>[splat-symbols.ts]"]
  node_splat["Splat build<br/>[splat.ts]"]
  node_remap["Body remapping<br/>[splat-remap.ts]"]
  node_substitute["Piece substitution<br/>[splat-sub.ts]"]
  node_review["Match review<br/>[splat-review.ts]"]
end

subgraph group_reconstruction["VOTA reconstruction"]
  node_cpp["Reconstructed C++"]
  node_ecourna["EcoUrna library"]
  node_asn["ASN.1 runtime<br/>[asn1.h]"]
  node_schemas["Election schemas"]
  node_entry["Application entry<br/>[main.cpp]"]
end

node_engineer(("Engineer"))
node_wasm["Target module<br/>[vota_web_wasm.js]"]
node_verified["Verified module"]

node_engineer -->|"opens"| node_webapp
node_webapp -->|"routes to"| node_playground
node_webapp -->|"routes to"| node_progress
node_webapp -->|"routes to"| node_emu
node_playground -->|"reads state"| node_urlstate
node_playground -.->|"inspects functions"| node_wasm
node_progress -->|"shows matches"| node_ledger
node_wasm -->|"parsed by"| node_parser
node_parser -->|"decodes integers"| node_leb
node_parser -->|"supplies module"| node_disasm
node_disasm -->|"normalizes instructions"| node_normalize
node_disasm -->|"lifts functions"| node_lifter
node_lifter -->|"ranks candidates"| node_ranking
node_wasm -->|"read by function"| node_readout
node_wasm -->|"censused"| node_census
node_wasm -->|"records attribution"| node_ledger
node_wasm -->|"mapped against"| node_symbols
node_symbols -->|"provides mappings"| node_remap
node_wasm -->|"split for matching"| node_splat
node_splat -->|"applies matches"| node_substitute
node_substitute -->|"supplies piece bodies"| node_review
node_remap -->|"provides remapped bytes"| node_review
node_review -->|"checks hash"| node_verified
node_cpp -.->|"linked into app"| node_entry
node_ecourna -.->|"linked into app"| node_entry
node_asn -->|"supports schema types"| node_schemas
node_cpp -->|"rebuilt byte for byte"| node_verified
node_ecourna -->|"rebuilt byte for byte"| node_verified
node_entry -->|"included in rebuild"| node_verified

click node_webapp "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/App.tsx"
click node_playground "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/pages/playground/Playground.tsx"
click node_progress "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/pages/progress/Progress.tsx"
click node_emu "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/pages/urnaemu/UrnaEmu.tsx"
click node_urlstate "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/shared/utils/url-state.ts"
click node_wasm "https://github.com/macabeus/urnadecomp/blob/main/target/vota_web_wasm.js"
click node_parser "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/parse.ts"
click node_leb "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/leb.ts"
click node_disasm "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/disasm.ts"
click node_normalize "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/normalize.ts"
click node_lifter "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/lift.ts"
click node_ranking "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/rank.ts"
click node_readout "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/readout.ts"
click node_census "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/census.ts"
click node_ledger "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/ledger.ts"
click node_symbols "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-symbols.ts"
click node_splat "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat.ts"
click node_remap "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-remap.ts"
click node_substitute "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-sub.ts"
click node_review "https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-review.ts"
click node_cpp "https://github.com/macabeus/urnadecomp/tree/main/src/uenux2"
click node_ecourna "https://github.com/macabeus/urnadecomp/tree/main/src/ecourna"
click node_asn "https://github.com/macabeus/urnadecomp/blob/main/src/asn1/asn1.h"
click node_schemas "https://github.com/macabeus/urnadecomp/blob/main/src/asn1/modules/ModuloTiposEleitorais.h"
click node_entry "https://github.com/macabeus/urnadecomp/blob/main/src/app/main.cpp"

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_webapp,node_playground,node_progress,node_emu,node_urlstate toneBlue
class node_parser,node_leb,node_disasm,node_normalize,node_lifter,node_ranking,node_readout toneAmber
class node_census,node_ledger,node_symbols,node_splat,node_remap,node_substitute,node_review toneMint
class node_cpp,node_ecourna,node_asn,node_schemas,node_entry toneRose
class node_engineer,node_verified toneIndigo
class node_wasm toneTeal
```

## Components

### Web views

- [Web app shell](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/App.tsx): `asmlift-wasm/playground/src/App.tsx`
- [Function playground](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/pages/playground/Playground.tsx): `asmlift-wasm/playground/src/pages/playground/Playground.tsx`
- [Progress meter](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/pages/progress/Progress.tsx): `asmlift-wasm/playground/src/pages/progress/Progress.tsx`
- [Urna simulator view](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/pages/urnaemu/UrnaEmu.tsx): `asmlift-wasm/playground/src/pages/urnaemu/UrnaEmu.tsx`
- [URL state](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/playground/src/shared/utils/url-state.ts): `asmlift-wasm/playground/src/shared/utils/url-state.ts`

### Wasm analysis

- [Module parser](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/parse.ts): `asmlift-wasm/src/parse.ts`
- [LEB decoder](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/leb.ts): `asmlift-wasm/src/leb.ts`
- [Function disassembler](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/disasm.ts): `asmlift-wasm/src/disasm.ts`
- [Function normalizer](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/normalize.ts): `asmlift-wasm/src/normalize.ts`
- [C++ lifter](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/lift.ts): `asmlift-wasm/src/lift.ts`
- [Candidate ranking](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/rank.ts): `asmlift-wasm/src/rank.ts`
- [Function readout](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/readout.ts): `asmlift-wasm/src/readout.ts`

### Match verification

- [Function census](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/census.ts): `asmlift-wasm/src/census.ts`
- [Function ledger](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/ledger.ts): `asmlift-wasm/src/ledger.ts`
- [Symbol mapping](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-symbols.ts): `asmlift-wasm/src/splat-symbols.ts`
- [Splat build](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat.ts): `asmlift-wasm/src/splat.ts`
- [Body remapping](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-remap.ts): `asmlift-wasm/src/splat-remap.ts`
- [Piece substitution](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-sub.ts): `asmlift-wasm/src/splat-sub.ts`
- [Match review](https://github.com/macabeus/urnadecomp/blob/main/asmlift-wasm/src/splat-review.ts): `asmlift-wasm/src/splat-review.ts`

### VOTA reconstruction

- [Reconstructed C++](https://github.com/macabeus/urnadecomp/tree/main/src/uenux2): `src/uenux2`
- [EcoUrna library](https://github.com/macabeus/urnadecomp/tree/main/src/ecourna): `src/ecourna`
- [ASN.1 runtime](https://github.com/macabeus/urnadecomp/blob/main/src/asn1/asn1.h): `src/asn1/asn1.h`
- [Election schemas](https://github.com/macabeus/urnadecomp/blob/main/src/asn1/modules/ModuloTiposEleitorais.h): `src/asn1/modules/ModuloTiposEleitorais.h`
- [Application entry](https://github.com/macabeus/urnadecomp/blob/main/src/app/main.cpp): `src/app/main.cpp`

### Other components

- **Engineer**
- [Target module](https://github.com/macabeus/urnadecomp/blob/main/target/vota_web_wasm.js): `target/vota_web_wasm.js`
- **Verified module**

## Connections

- Engineer → Web app shell: opens (evidence: `asmlift-wasm/playground/src/App.tsx`)
- Web app shell → Function playground: routes to (evidence: `asmlift-wasm/playground/src/App.tsx`)
- Web app shell → Progress meter: routes to (evidence: `asmlift-wasm/playground/src/App.tsx`)
- Web app shell → Urna simulator view: routes to (evidence: `asmlift-wasm/playground/src/App.tsx`)
- Function playground → URL state: reads state (evidence: `asmlift-wasm/playground/src/pages/playground/Playground.tsx`)
- Function playground → Target module: inspects functions
- Progress meter → Function ledger: shows matches (evidence: `README.md`)
- Target module → Module parser: parsed by (evidence: `README.md`)
- Module parser → LEB decoder: decodes integers (evidence: `asmlift-wasm/src/parse.ts`)
- Module parser → Function disassembler: supplies module (evidence: `asmlift-wasm/src/lift.ts`)
- Function disassembler → Function normalizer: normalizes instructions (evidence: `asmlift-wasm/src/normalize.ts`)
- Function disassembler → C++ lifter: lifts functions (evidence: `asmlift-wasm/src/lift.ts`)
- C++ lifter → Candidate ranking: ranks candidates (evidence: `README.md`)
- Target module → Function readout: read by function (evidence: `README.md`)
- Target module → Function census: censused (evidence: `README.md`)
- Target module → Function ledger: records attribution (evidence: `README.md`)
- Target module → Symbol mapping: mapped against (evidence: `asmlift-wasm/src/splat-symbols.ts`)
- Symbol mapping → Body remapping: provides mappings (evidence: `asmlift-wasm/src/splat-remap.ts`)
- Target module → Splat build: split for matching (evidence: `README.md`)
- Splat build → Piece substitution: applies matches (evidence: `asmlift-wasm/src/splat-review.ts`)
- Piece substitution → Match review: supplies piece bodies (evidence: `asmlift-wasm/src/splat-review.ts`)
- Body remapping → Match review: provides remapped bytes (evidence: `asmlift-wasm/src/splat-review.ts`)
- Match review → Verified module: checks hash (evidence: `asmlift-wasm/src/splat-review.ts`)
- Reconstructed C++ → Application entry: linked into app
- EcoUrna library → Application entry: linked into app
- ASN.1 runtime → Election schemas: supports schema types (evidence: `src/asn1/modules/ModuloTiposEleitorais.h`)
- Reconstructed C++ → Verified module: rebuilt byte for byte (evidence: `README.md`)
- EcoUrna library → Verified module: rebuilt byte for byte (evidence: `README.md`)
- Application entry → Verified module: included in rebuild (evidence: `src/app/main.cpp`)
