# softdevdanial/splity-tab architecture

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

- Interactive diagram: https://gitdiagram.com/softdevdanial/splity-tab
- Repository: https://github.com/softdevdanial/splity-tab

## Overview

Danial’s Splity Tab is a browser-based Malaysian bill-splitting app. A user enters people, a subtotal and charges, then chooses an even split or assigns item prices to diners; the app computes sen-exact shares, allocates rounding leftovers, and displays a receipt that can be copied. The main shell owns bill state, persistence and UI wiring; core modules own bill rules and calculations, while UI modules render and report user actions. The README documents local-only saving and responsive Splits/Spare sen interfaces. Unsampled UI wiring is represented only where the index or README supports it.

Main entry points: [`src/main.js`](https://github.com/softdevdanial/splity-tab/blob/main/src/main.js) (App coordinator), [`src/ui/items.js`](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/items.js) (Item editor), [`src/core/result.js`](https://github.com/softdevdanial/splity-tab/blob/main/src/core/result.js) (Split calculation), [`src/core/summary.js`](https://github.com/softdevdanial/splity-tab/blob/main/src/core/summary.js) (Summary text)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_main["App coordinator<br/>[main.js]"]
  node_draft["Draft persistence<br/>[draft.js]"]
end

subgraph group_domain["Bill and calculations"]
  node_bill["Bill state rules<br/>[bill.js]"]
  node_money["Money parsing<br/>[money.js]"]
  node_allocate["Weighted allocation<br/>[allocate.js]"]
  node_result["Split calculation<br/>[result.js]"]
  node_spare["Spare sen rules<br/>[spare.js]"]
  node_summary["Summary text<br/>[summary.js]"]
end

subgraph group_inputs["Bill entry UI"]
  node_people["People editor<br/>[people.js]"]
  node_subtotal["Subtotal field<br/>[subtotal.js]"]
  node_items["Item editor<br/>[items.js]"]
  node_charges["Charge fields<br/>[charges.js]"]
  node_sections["Input sections<br/>[sections.js]"]
end

subgraph group_results["Receipt and choices"]
  node_receipt["Receipt renderer<br/>[receipt.js]"]
  node_sparechoice["Spare sen picker<br/>[spare-choice.js]"]
  node_sheet["Splits sheet<br/>[sheet.js]"]
  node_strip["Mobile total strip<br/>[strip.js]"]
  node_copy["Copy status<br/>[copy-status.js]"]
end

subgraph group_presentation["Shared UI support"]
  node_dom["DOM utilities<br/>[dom.js]"]
  node_fieldleave["Field leave handling<br/>[field-leave.js]"]
  node_fielderr["Field errors<br/>[field-error.js]"]
  node_icons["Runtime icons<br/>[icons.js]"]
  node_media["Responsive breakpoint<br/>[media.js]"]
end

node_user(("Bill splitter"))
node_localstorage[("Browser localStorage")]

node_user -->|"edits bill"| node_main
node_main -->|"updates state"| node_bill
node_main -->|"computes split"| node_result
node_main -->|"chooses leftovers"| node_spare
node_main -->|"loads and saves"| node_draft
node_draft -->|"reads and writes"| node_localstorage
node_main -->|"builds copy text"| node_summary
node_result -->|"parses amounts"| node_money
node_result -->|"allocates shares"| node_allocate
node_result -->|"reads bill rules"| node_bill
node_spare -->|"reads spare people"| node_bill
node_summary -->|"formats amounts"| node_money
node_summary -->|"formats result"| node_result
node_main -->|"wires editor"| node_people
node_main -->|"wires field"| node_subtotal
node_main -->|"wires editor"| node_items
node_main -->|"wires fields"| node_charges
node_main -->|"renders sections"| node_sections
node_main -->|"renders result"| node_receipt
node_main -->|"updates picker"| node_sparechoice
node_main -->|"wires sheet"| node_sheet
node_main -->|"wires strip"| node_strip
node_receipt -->|"shows copy status"| node_copy
node_items -->|"handles field blur"| node_fieldleave
node_items -->|"creates price errors"| node_fielderr
node_sparechoice -->|"tracks breakpoint"| node_media
node_receipt -->|"builds elements"| node_dom
node_items -->|"builds controls"| node_dom
node_items -->|"renders icons"| node_icons

click node_main "https://github.com/softdevdanial/splity-tab/blob/main/src/main.js"
click node_draft "https://github.com/softdevdanial/splity-tab/blob/main/src/draft.js"
click node_bill "https://github.com/softdevdanial/splity-tab/blob/main/src/core/bill.js"
click node_money "https://github.com/softdevdanial/splity-tab/blob/main/src/core/money.js"
click node_allocate "https://github.com/softdevdanial/splity-tab/blob/main/src/core/allocate.js"
click node_result "https://github.com/softdevdanial/splity-tab/blob/main/src/core/result.js"
click node_spare "https://github.com/softdevdanial/splity-tab/blob/main/src/core/spare.js"
click node_summary "https://github.com/softdevdanial/splity-tab/blob/main/src/core/summary.js"
click node_people "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/people.js"
click node_subtotal "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/subtotal.js"
click node_items "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/items.js"
click node_charges "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/charges.js"
click node_sections "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/sections.js"
click node_receipt "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/receipt.js"
click node_sparechoice "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/spare-choice.js"
click node_sheet "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/sheet.js"
click node_strip "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/strip.js"
click node_copy "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/copy-status.js"
click node_dom "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/dom.js"
click node_fieldleave "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/field-leave.js"
click node_fielderr "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/field-error.js"
click node_icons "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/icons.js"
click node_media "https://github.com/softdevdanial/splity-tab/blob/main/src/ui/media.js"

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_main,node_draft toneBlue
class node_bill,node_money,node_allocate,node_result,node_spare,node_summary,node_localstorage toneAmber
class node_people,node_subtotal,node_items,node_charges,node_sections toneMint
class node_receipt,node_sparechoice,node_sheet,node_strip,node_copy toneRose
class node_dom,node_fieldleave,node_fielderr,node_icons,node_media,node_user toneIndigo
```

## Components

### App shell

- [App coordinator](https://github.com/softdevdanial/splity-tab/blob/main/src/main.js): `src/main.js`
- [Draft persistence](https://github.com/softdevdanial/splity-tab/blob/main/src/draft.js): `src/draft.js`

### Bill and calculations

- [Bill state rules](https://github.com/softdevdanial/splity-tab/blob/main/src/core/bill.js): `src/core/bill.js`
- [Money parsing](https://github.com/softdevdanial/splity-tab/blob/main/src/core/money.js): `src/core/money.js`
- [Weighted allocation](https://github.com/softdevdanial/splity-tab/blob/main/src/core/allocate.js): `src/core/allocate.js`
- [Split calculation](https://github.com/softdevdanial/splity-tab/blob/main/src/core/result.js): `src/core/result.js`
- [Spare sen rules](https://github.com/softdevdanial/splity-tab/blob/main/src/core/spare.js): `src/core/spare.js`
- [Summary text](https://github.com/softdevdanial/splity-tab/blob/main/src/core/summary.js): `src/core/summary.js`

### Bill entry UI

- [People editor](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/people.js): `src/ui/people.js`
- [Subtotal field](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/subtotal.js): `src/ui/subtotal.js`
- [Item editor](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/items.js): `src/ui/items.js`
- [Charge fields](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/charges.js): `src/ui/charges.js`
- [Input sections](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/sections.js): `src/ui/sections.js`

### Receipt and choices

- [Receipt renderer](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/receipt.js): `src/ui/receipt.js`
- [Spare sen picker](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/spare-choice.js): `src/ui/spare-choice.js`
- [Splits sheet](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/sheet.js): `src/ui/sheet.js`
- [Mobile total strip](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/strip.js): `src/ui/strip.js`
- [Copy status](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/copy-status.js): `src/ui/copy-status.js`

### Shared UI support

- [DOM utilities](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/dom.js): `src/ui/dom.js`
- [Field leave handling](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/field-leave.js): `src/ui/field-leave.js`
- [Field errors](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/field-error.js): `src/ui/field-error.js`
- [Runtime icons](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/icons.js): `src/ui/icons.js`
- [Responsive breakpoint](https://github.com/softdevdanial/splity-tab/blob/main/src/ui/media.js): `src/ui/media.js`

### Other components

- **Bill splitter**
- **Browser localStorage**

## Connections

- Bill splitter → App coordinator: edits bill (evidence: `README.md`)
- App coordinator → Bill state rules: updates state (evidence: `src/main.js`)
- App coordinator → Split calculation: computes split (evidence: `src/main.js`)
- App coordinator → Spare sen rules: chooses leftovers (evidence: `src/main.js`)
- App coordinator → Draft persistence: loads and saves (evidence: `src/main.js`)
- Draft persistence → Browser localStorage: reads and writes (evidence: `README.md`)
- App coordinator → Summary text: builds copy text (evidence: `src/main.js`)
- Split calculation → Money parsing: parses amounts (evidence: `src/core/result.js`)
- Split calculation → Weighted allocation: allocates shares (evidence: `src/core/result.js`)
- Split calculation → Bill state rules: reads bill rules (evidence: `src/core/result.js`)
- Spare sen rules → Bill state rules: reads spare people (evidence: `src/core/spare.js`)
- Summary text → Money parsing: formats amounts (evidence: `src/core/summary.js`)
- Summary text → Split calculation: formats result (evidence: `src/core/summary.js`)
- App coordinator → People editor: wires editor (evidence: `src/main.js`)
- App coordinator → Subtotal field: wires field (evidence: `src/main.js`)
- App coordinator → Item editor: wires editor (evidence: `src/main.js`)
- App coordinator → Charge fields: wires fields (evidence: `src/main.js`)
- App coordinator → Input sections: renders sections (evidence: `src/main.js`)
- App coordinator → Receipt renderer: renders result (evidence: `src/main.js`)
- App coordinator → Spare sen picker: updates picker (evidence: `src/main.js`)
- App coordinator → Splits sheet: wires sheet (evidence: `src/main.js`)
- App coordinator → Mobile total strip: wires strip (evidence: `src/main.js`)
- Receipt renderer → Copy status: shows copy status (evidence: `src/ui/receipt.js`)
- Item editor → Field leave handling: handles field blur (evidence: `src/ui/items.js`)
- Item editor → Field errors: creates price errors (evidence: `src/ui/items.js`)
- Spare sen picker → Responsive breakpoint: tracks breakpoint (evidence: `src/ui/spare-choice.js`)
- Receipt renderer → DOM utilities: builds elements (evidence: `src/ui/receipt.js`)
- Item editor → DOM utilities: builds controls (evidence: `src/ui/items.js`)
- Item editor → Runtime icons: renders icons (evidence: `src/ui/items.js`)
