# projeto-final-lei-ipt/planetarysystemv2 architecture

> Architecture diagram of the GitHub repository projeto-final-lei-ipt/planetarysystemv2, 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/projeto-final-lei-ipt/planetarysystemv2
- Repository: https://github.com/projeto-final-lei-ipt/planetarysystemv2

## Overview

This repository contains browser-based planetary-system AR games, with `webview` as the current version and `webview_v3` and `webview_antigo` as earlier implementations. In the current game, a player opens a scenario, the initializer loads its planet data and obtains the player’s location, and the scene-building code creates the AR system. Players can approach planets to answer quizzes, view planet information, and track progress. The excerpts show these runtime features and offline caching; several page and data relationships are documented only by filenames, so uncertain links are omitted.

Main entry points: [`webview/js`](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/js) (Scenario initializers), [`webview_v3/js`](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/js) (Scenario initializers), [`webview_antigo/Old/Old_main.js`](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/Old/Old_main.js) (Worker game entry), [`webview/Pages`](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/Pages) (Game pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_current["Current AR game"]
  node_current_pages["Game pages"]
  node_current_init["Scenario initializers"]
  node_current_data["Planet data"]
  node_current_scene["Scene builder<br/>[script.js]"]
  node_current_components["AR components<br/>[componentsV2.js]"]
  node_current_utils["Utilities<br/>[utils.js]"]
  node_current_info["Instructions and about"]
  node_current_offline["Offline cache<br/>[sw.js]"]
end

subgraph group_v3["V3 AR game"]
  node_v3_pages["Game pages"]
  node_v3_init["Scenario initializers"]
  node_v3_data["Planet data"]
  node_v3_scene["Scene builder<br/>[script.js]"]
  node_v3_components["AR components<br/>[componentsV2.js]"]
  node_v3_utils["Utilities<br/>[utils.js]"]
  node_v3_info["Instructions and about"]
  node_v3_offline["Offline cache<br/>[sw.js]"]
end

subgraph group_legacy["Earlier implementations"]
  node_old_main["Worker game entry<br/>[Old_main.js]"]
  node_old_worker["Planet worker<br/>[planetWorker.js]"]
  node_old_components["Legacy AR components<br/>[components.js]"]
  node_old_components_v2["Legacy AR components v2<br/>[componentsV2.js]"]
  node_old_script["Legacy scene builder<br/>[script.js]"]
  node_old_quiz["Legacy quiz<br/>[quiz.js]"]
end

subgraph group_platform["Browser platform"]
  node_browser_location(("Device location"))
  node_browser_storage[("Browser cache")]
  node_ar_runtime["A-Frame and AR.js"]
end

node_player(("Player"))

node_player -.->|"opens"| node_current_pages
node_current_init -.->|"fetches"| node_current_data
node_current_init -.->|"requests location"| node_browser_location
node_current_init -.->|"creates scene"| node_current_scene
node_current_scene -->|"sets components"| node_current_components
node_current_pages -.->|"links pages"| node_current_info
node_current_offline -->|"caches files"| node_browser_storage
node_current_pages -->|"cached by"| node_current_offline
node_v3_init -->|"fetches"| node_v3_data
node_v3_init -->|"requests location"| node_browser_location
node_v3_init -->|"calls createPlanets"| node_v3_scene
node_v3_scene -->|"sets components"| node_v3_components
node_v3_pages -.->|"links pages"| node_v3_info
node_v3_offline -->|"caches files"| node_browser_storage
node_v3_pages -->|"cached by"| node_v3_offline
node_old_main -->|"dispatches worker"| node_old_worker
node_old_worker -->|"fetches data"| node_browser_storage
node_old_main -.->|"registers components"| node_old_components
node_old_main -.->|"registers components"| node_old_components_v2
node_player -.->|"uses AR"| node_ar_runtime

click node_current_pages "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/Pages"
click node_current_init "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/js"
click node_current_data "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/data"
click node_current_scene "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/js/script.js"
click node_current_components "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/js/componentsV2.js"
click node_current_utils "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/js/utils.js"
click node_current_info "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/Pages"
click node_current_offline "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/sw.js"
click node_v3_pages "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/Pages"
click node_v3_init "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/js"
click node_v3_data "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/data"
click node_v3_scene "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/js/script.js"
click node_v3_components "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/js/componentsV2.js"
click node_v3_utils "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/js/utils.js"
click node_v3_info "https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/Pages"
click node_v3_offline "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/sw.js"
click node_old_main "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/Old/Old_main.js"
click node_old_worker "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/Testes/planetWorker.js"
click node_old_components "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/components.js"
click node_old_components_v2 "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/componentsV2.js"
click node_old_script "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/script.js"
click node_old_quiz "https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/quiz.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_current_pages,node_current_init,node_current_data,node_current_scene,node_current_components,node_current_utils,node_current_info,node_current_offline toneBlue
class node_v3_pages,node_v3_init,node_v3_data,node_v3_scene,node_v3_components,node_v3_utils,node_v3_info,node_v3_offline toneAmber
class node_old_main,node_old_worker,node_old_components,node_old_components_v2,node_old_script,node_old_quiz toneMint
class node_browser_location,node_browser_storage,node_ar_runtime toneRose
class node_player toneIndigo
```

## Components

### Current AR game

- [Game pages](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/Pages): `webview/Pages`
- [Scenario initializers](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/js): `webview/js`
- [Planet data](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/data): `webview/data`
- [Scene builder](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/js/script.js): `webview/js/script.js`
- [AR components](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/js/componentsV2.js): `webview/js/componentsV2.js`
- [Utilities](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/js/utils.js): `webview/js/utils.js`
- [Instructions and about](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview/Pages): `webview/Pages`
- [Offline cache](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview/sw.js): `webview/sw.js`

### V3 AR game

- [Game pages](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/Pages): `webview_v3/Pages`
- [Scenario initializers](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/js): `webview_v3/js`
- [Planet data](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/data): `webview_v3/data`
- [Scene builder](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/js/script.js): `webview_v3/js/script.js`
- [AR components](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/js/componentsV2.js): `webview_v3/js/componentsV2.js`
- [Utilities](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/js/utils.js): `webview_v3/js/utils.js`
- [Instructions and about](https://github.com/projeto-final-lei-ipt/planetarysystemv2/tree/main/webview_v3/Pages): `webview_v3/Pages`
- [Offline cache](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_v3/sw.js): `webview_v3/sw.js`

### Earlier implementations

- [Worker game entry](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/Old/Old_main.js): `webview_antigo/Old/Old_main.js`
- [Planet worker](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/Testes/planetWorker.js): `webview_antigo/Testes/planetWorker.js`
- [Legacy AR components](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/components.js): `webview_antigo/js/components.js`
- [Legacy AR components v2](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/componentsV2.js): `webview_antigo/js/componentsV2.js`
- [Legacy scene builder](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/script.js): `webview_antigo/js/script.js`
- [Legacy quiz](https://github.com/projeto-final-lei-ipt/planetarysystemv2/blob/main/webview_antigo/js/quiz.js): `webview_antigo/js/quiz.js`

### Browser platform

- **Device location**
- **Browser cache**
- **A-Frame and AR.js**

### Other components

- **Player**

## Connections

- Player → Game pages: opens
- Scenario initializers → Planet data: fetches
- Scenario initializers → Device location: requests location
- Scenario initializers → Scene builder: creates scene
- Scene builder → AR components: sets components (evidence: `webview/js/script.js`)
- Game pages → Instructions and about: links pages
- Offline cache → Browser cache: caches files (evidence: `webview/sw.js`)
- Game pages → Offline cache: cached by (evidence: `webview/sw.js`)
- Scenario initializers → Planet data: fetches (evidence: `webview_v3/js/initializerX2.js`)
- Scenario initializers → Device location: requests location (evidence: `webview_v3/js/initializerX2.js`)
- Scenario initializers → Scene builder: calls createPlanets (evidence: `webview_v3/js/initializerX2.js`)
- Scene builder → AR components: sets components (evidence: `webview_v3/js/script.js`)
- Game pages → Instructions and about: links pages
- Offline cache → Browser cache: caches files (evidence: `webview_v3/sw.js`)
- Game pages → Offline cache: cached by (evidence: `webview_v3/sw.js`)
- Worker game entry → Planet worker: dispatches worker (evidence: `webview_antigo/Old/Old_main.js`)
- Planet worker → Browser cache: fetches data (evidence: `webview_antigo/Testes/planetWorker.js`)
- Worker game entry → Legacy AR components: registers components
- Worker game entry → Legacy AR components v2: registers components
- Player → A-Frame and AR.js: uses AR
