# mrredshark77/incremental-mass-rewritten architecture

> Architecture diagram of the GitHub repository mrredshark77/incremental-mass-rewritten, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrredshark77/incremental-mass-rewritten
- Repository: https://github.com/mrredshark77/incremental-mass-rewritten

## Overview

1. **Project shape**
   - This is a browser-based incremental game, delivered as a static front end.
   - The app is centered on `index.html`, `style.css`, `tooltip.css`, and a large `js/` codebase. There is no server-side layer in the repository.
   - The GitHub Actions workflow in `.github/workflows/static.yml` suggests it is meant to be built/deployed as a static site.

2. **Entry point and app shell**
   - `index.html` is the main host page that loads the game UI and scripts.
   - `hidden.html` appears to be a secondary/hidden page for secret content or alternate UI states.
   - `js/main.js` is likely the top-level bootstrap and render/update coordinator for the game loop and DOM updates.

3. **Core game loop and state model**
   - `js/temp.js` is an important architectural file: in incremental games this usually holds derived, cached, or “temporary” values recomputed from persistent state each tick.
   - `js/resources.js`, `js/saves.js`, `js/other.js`, and `js/debug.js` are the central support layer around resource tracking, persistence, miscellaneous helpers, and developer tooling.
   - The runtime likely follows a pattern of: load save → reconstruct state → recompute derived values → update UI → persist periodically.

4. **Numerical foundation**
   - `js/break_eternity.js` is the precision math foundation, used to support extremely large numbers typical of incremental progression.
   - `js/md.js` and `js/formats.js` are the number formatting layer, translating large values into readable UI text.
   - `js/scaling.js` likely defines how costs and thresholds escalate across systems.

5. **Progression and unlock systems**
   - The game’s advancement layers are spread across `js/ranks.js`, `js/upgrades.js`, `js/buildings.js`, `js/elements.js`, `js/elemental.js`, `js/atom.js`, `js/stars.js`, and `js/ascensions.js`.
   - These files represent the core gameplay economy: player resources, upgrade purchase logic, unlock thresholds, and prestige-style resets.
   - `js/confirm.js`, `js/tooltip.js`, `js/tooltip_res.js`, and `js/tabs.js` support the UI around those progression systems.

6. **Major late-game branches**
   - The repository is organized into large feature domains under separate folders:
     - `js/infinity/` for infinity-level progression
     - `js/quantum/` for quantum mechanics-style progression layers
     - `js/supernova/` for supernova-related systems
     - `js/darkness/` for darkness/endgame content
   - This structure implies the game has multiple prestige branches or parallel endgame tracks, each with its own mechanics and unlocks.

7. **Infinity subsystem**
   - `js/infinity/core.js`, `js/infinity/inf.js`, and `js/infinity/corrupted_star.js` define the infinity layer and associated mechanics.
   - This layer likely acts as a major reset/progression boundary, introducing new currencies or multipliers that feed back into earlier systems.

8. **Quantum subsystem**
   - `js/quantum/quantum.js` is the main quantum layer, with supporting modules for `big_rip.js`, `chroma.js`, `entropy.js`, `primordium.js`, and `qc.js`.
   - This looks like a distinct late-game ecosystem with multiple subresources and challenge or configuration systems.
   - Quantum content likely consumes outputs from earlier systems and redefines long-term progression.

9. **Supernova subsystem**
   - `js/supernova/supernova.js` is the parent layer, with `bosons.js`, `fermions.js`, `radiation.js`, and `tree.js` as its feature modules.
   - The file naming suggests this layer introduces a technology/tree-style progression model plus particle/physics-inspired submechanics.

10. **Darkness and exotic content**
   - `js/darkness/dark.js`, `dark_run.js`, `matter.js`, `exotic_atoms.js`, and `c16.js` form a separate advanced content branch.
   - This looks like a challenge-heavy or alternate-state system with its own resources, run conditions, and possibly “matter” as a competing economy.
   - `js/secret.js` and `js/hidden.js` indicate easter eggs or intentionally concealed mechanics.

11. **Domain-specific content modules**
   - `js/challenges.js`, `js/atoms.js`, `js/stars.js`, `js/buildings.js`, `js/elements.js`, and `js/upgrades.js` are the game’s main rule modules.
   - These are likely where purchase logic, unlock conditions, effects, and balances are encoded.
   - The architecture is feature-sliced by mechanic rather than by technical layer, which is common in incremental game codebases.

12. **Rendering and interaction**
   - The UI is DOM-driven rather than canvas-driven: styles are split across `style.css`, `tooltip.css`, and `hidden_style.css`.
   - Assets in `images/` and `fonts/` support iconography and display polish.
   - The `js/tabs.js` and tooltip modules suggest the interface is organized into many panel-like screens, each exposing one layer of progression.

13. **Persistence and game lifecycle**
   - `js/saves.js` is the save/load boundary and probably serializes the entire player state.
   - The architecture likely separates persistent player data from transient calculated state, with `temp.js` bridging the two.
   - This is the key data flow to diagram: persistent save state feeds derived computation, which feeds DOM rendering and user actions, which in turn mutate save state.

14. **Overall architecture summary**
   - The repository is a single-page incremental game with one front-end runtime and many mechanic modules.
   - The major architectural boundaries are: core runtime, numeric/formatting foundation, save/state management, UI rendering, and several large progression subsystems (Infinity, Quantum, Supernova, Darkness).
   - For an architecture diagram, the most important relationships are the flow from saved player state into derived values and then into layered gameplay systems that reset, amplify, or unlock one another.

Main entry points: [`js/main.js`](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/main.js) (Main loop), [`js/resources.js`](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/resources.js) (Resources), [`js/temp.js`](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/temp.js) (Temp state), [`js/quantum/quantum.js`](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/quantum/quantum.js) (Quantum)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_index_html["Index<br/>entry page<br/>[index.html]"]
  node_hidden_html["Hidden page<br/>alt page<br/>[hidden.html]"]
end

subgraph group_core["Core runtime"]
  node_main_js["Main loop<br/>bootstrap<br/>[main.js]"]
  node_saves_js[("Saves<br/>persistence<br/>[saves.js]")]
  node_temp_js["Temp state<br/>derived state<br/>[temp.js]"]
  node_resources_js["Resources<br/>state model<br/>[resources.js]"]
  node_break_eternity_js(("Big numbers<br/>math lib<br/>[break_eternity.js]"))
  node_formats_js["Formats<br/>number UI<br/>[formats.js]"]
  node_scaling_js["Scaling<br/>balance rules<br/>[scaling.js]"]
end

subgraph group_progression["Progression layer"]
  node_ranks_js["Ranks<br/>progression<br/>[ranks.js]"]
  node_upgrades_js["Upgrades<br/>progression<br/>[upgrades.js]"]
  node_buildings_js["Buildings<br/>progression<br/>[buildings.js]"]
  node_elements_js["Elements<br/>progression<br/>[elements.js]"]
  node_atom_js["Atoms<br/>resource layer<br/>[atom.js]"]
  node_stars_js["Stars<br/>resource layer<br/>[stars.js]"]
  node_ascensions_js["Ascensions<br/>prestige<br/>[ascensions.js]"]
  node_challenges_js["Challenges<br/>challenge system<br/>[challenges.js]"]
end

subgraph group_endgame["Late-game branches"]
  node_infinity_js["Infinity<br/>prestige branch<br/>[inf.js]"]
  node_quantum_js["Quantum<br/>prestige branch<br/>[quantum.js]"]
  node_supernova_js["Supernova<br/>prestige branch<br/>[supernova.js]"]
  node_dark_js["Darkness<br/>endgame branch<br/>[dark.js]"]
end

subgraph group_ui["Interface"]
  node_tabs_js["Tabs<br/>ui navigation<br/>[tabs.js]"]
  node_tooltip_js["Tooltips<br/>ui hints<br/>[tooltip.js]"]
  node_confirm_js["Confirm<br/>ui dialog<br/>[confirm.js]"]
  node_hidden_js["Hidden UI<br/>secret ui<br/>[hidden.js]"]
end

node_index_html -->|"loads"| node_main_js
node_hidden_html -->|"loads"| node_hidden_js
node_main_js -->|"save cycle"| node_saves_js
node_main_js -->|"tick update"| node_temp_js
node_main_js -->|"state flow"| node_resources_js
node_main_js -->|"render"| node_tabs_js
node_main_js -->|"ui helpers"| node_tooltip_js
node_main_js -->|"actions"| node_confirm_js
node_main_js -->|"numbers"| node_break_eternity_js
node_temp_js -->|"display values"| node_formats_js
node_temp_js -->|"balance"| node_scaling_js
node_saves_js -->|"persist"| node_resources_js
node_resources_js -->|"drives"| node_ranks_js
node_resources_js -->|"drives"| node_upgrades_js
node_resources_js -->|"drives"| node_buildings_js
node_resources_js -->|"unlocks"| node_elements_js
node_resources_js -->|"feeds"| node_atom_js
node_resources_js -->|"feeds"| node_stars_js
node_ranks_js -->|"prestige path"| node_ascensions_js
node_challenges_js -->|"conditions"| node_quantum_js
node_infinity_js -->|"bridges"| node_quantum_js
node_quantum_js -->|"advances to"| node_supernova_js
node_supernova_js -->|"late game"| node_dark_js
node_hidden_js -->|"secret content"| node_dark_js

click node_index_html "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/index.html"
click node_hidden_html "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/hidden.html"
click node_main_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/main.js"
click node_saves_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/saves.js"
click node_temp_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/temp.js"
click node_resources_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/resources.js"
click node_break_eternity_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/break_eternity.js"
click node_formats_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/formats.js"
click node_scaling_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/scaling.js"
click node_ranks_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/ranks.js"
click node_upgrades_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/upgrades.js"
click node_buildings_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/buildings.js"
click node_elements_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/elements.js"
click node_atom_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/atom.js"
click node_stars_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/stars.js"
click node_ascensions_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/ascensions.js"
click node_challenges_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/challenges.js"
click node_infinity_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/infinity/inf.js"
click node_quantum_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/quantum/quantum.js"
click node_supernova_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/supernova/supernova.js"
click node_dark_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/darkness/dark.js"
click node_tabs_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/tabs.js"
click node_tooltip_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/tooltip.js"
click node_confirm_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/confirm.js"
click node_hidden_js "https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/hidden.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_index_html,node_hidden_html toneBlue
class node_main_js,node_saves_js,node_temp_js,node_resources_js,node_break_eternity_js,node_formats_js,node_scaling_js toneAmber
class node_ranks_js,node_upgrades_js,node_buildings_js,node_elements_js,node_atom_js,node_stars_js,node_ascensions_js,node_challenges_js toneMint
class node_infinity_js,node_quantum_js,node_supernova_js,node_dark_js toneRose
class node_tabs_js,node_tooltip_js,node_confirm_js,node_hidden_js toneIndigo
```

## Components

### App shell

Static front-end entry pages and styling.

- [Index](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/index.html): entry page · Main game host page. · `index.html`
- [Hidden page](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/hidden.html): alt page · Secondary page for secret or alternate UI states. · `hidden.html`

### Core runtime

Bootstrap, save lifecycle, derived state, and shared helpers.

- [Main loop](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/main.js): bootstrap · Top-level coordinator for update and render flow. · `js/main.js`
- [Saves](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/saves.js): persistence · Save/load boundary and player serialization. · `js/saves.js`
- [Temp state](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/temp.js): derived state · Recomputed cached values used during gameplay ticks. · `js/temp.js`
- [Resources](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/resources.js): state model · Central resource tracking and shared game data. · `js/resources.js`
- [Big numbers](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/break_eternity.js): math lib · Precision arithmetic foundation for huge values. · `js/break_eternity.js`
- [Formats](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/formats.js): number UI · Readable formatting for large numeric values. · `js/formats.js`
- [Scaling](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/scaling.js): balance rules · Cost and threshold scaling logic. · `js/scaling.js`

### Progression layer

Main early/mid-game mechanics and unlock systems.

- [Ranks](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/ranks.js): progression · Early prestige and rank advancement. · `js/ranks.js`
- [Upgrades](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/upgrades.js): progression · Core upgrade purchase and effect logic. · `js/upgrades.js`
- [Buildings](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/buildings.js): progression · Production and structure-based mechanics. · `js/buildings.js`
- [Elements](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/elements.js): progression · Element collection and unlock layer. · `js/elements.js`
- [Atoms](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/atom.js): resource layer · Atomic resource progression and conversions. · `js/atom.js`
- [Stars](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/stars.js): resource layer · Star-based progression and multipliers. · `js/stars.js`
- [Ascensions](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/ascensions.js): prestige · Higher-tier reset and advancement layer. · `js/ascensions.js`
- [Challenges](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/challenges.js): challenge system · Conditional gameplay modifiers and goals. · `js/challenges.js`

### Late-game branches

Major prestige and endgame content tracks.

- [Infinity](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/infinity/inf.js): prestige branch · Infinity-layer progression and reset mechanics. · `js/infinity/inf.js`
- [Quantum](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/quantum/quantum.js): prestige branch · Quantum-layer progression and subresources. · `js/quantum/quantum.js`
- [Supernova](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/supernova/supernova.js): prestige branch · Supernova-layer progression and tree systems. · `js/supernova/supernova.js`
- [Darkness](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/darkness/dark.js): endgame branch · Darkness and exotic late-game content. · `js/darkness/dark.js`

### Interface

Tabs, tooltips, confirmations, and hidden content hooks.

- [Tabs](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/tabs.js): ui navigation · Screen and panel navigation. · `js/tabs.js`
- [Tooltips](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/tooltip.js): ui hints · Hover help and explanatory popups. · `js/tooltip.js`
- [Confirm](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/confirm.js): ui dialog · Confirmation prompts for risky actions. · `js/confirm.js`
- [Hidden UI](https://github.com/mrredshark77/incremental-mass-rewritten/blob/main/js/hidden.js): secret ui · Secret or hidden-page interaction logic. · `js/hidden.js`

## Connections

- Index → Main loop: loads · Primary page bootstraps the game runtime.
- Hidden page → Hidden UI: loads · Hidden page connects to secret UI logic.
- Main loop → Saves: save cycle · Main loop reads and writes persistent state.
- Main loop → Temp state: tick update · Main loop refreshes derived values each cycle.
- Main loop → Resources: state flow · Runtime coordinates shared game resources.
- Main loop → Tabs: render · Main UI updates tabbed screens and panels.
- Main loop → Tooltips: ui helpers · Main runtime feeds tooltip-driven interactions.
- Main loop → Confirm: actions · Dangerous actions route through confirmation dialogs.
- Main loop → Big numbers: numbers · Game logic relies on precision arithmetic.
- Temp state → Formats: display values · Derived values are turned into readable text.
- Temp state → Scaling: balance · Derived values use scaling rules for costs and thresholds.
- Saves → Resources: persist · Player saves reconstruct the central resource model.
- Resources → Ranks: drives · Core resource state powers rank progression.
- Resources → Upgrades: drives · Resources are spent on upgrades.
- Resources → Buildings: drives · Resources fuel building mechanics.
- Resources → Elements: unlocks · Resource thresholds gate element progression.
- Resources → Atoms: feeds · Resource state flows into atom systems.
- Resources → Stars: feeds · Resource state flows into star systems.
- Ranks → Ascensions: prestige path · Rank progression leads into higher prestige layers.
- Challenges → Quantum: conditions · Challenge logic shapes quantum content and constraints.
- Infinity → Quantum: bridges · Infinity progression feeds later quantum layers.
- Quantum → Supernova: advances to · Quantum content unlocks deeper supernova systems.
- Supernova → Darkness: late game · Supernova systems feed into darkness content.
- Hidden UI → Darkness: secret content · Hidden mechanics connect to darker endgame paths.
