# 0quake/zero-quake architecture

> Architecture diagram of the GitHub repository 0quake/zero-quake, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0quake/zero-quake
- Repository: https://github.com/0quake/zero-quake

## Overview

##### Project Type & Purpose
- Zero‐Quake is essentially a client-side application focused on presenting real‐time earthquake, tsunami, and related disaster information. It aggregates data from multiple external meteorological and seismic sources and displays it via an interactive map and several detailed information pages.
- The README indicates that the app pulls data from various external APIs and data sources (e.g., Japanese Meteorological Agency, USGS, etc.) and even uses community‐provided data. This confirms that the main purpose is related to disaster (earthquake/tsunami) information monitoring and visualization.

##### Analyzing the File Structure
- At the top level, you see project management files (.github directories for issue templates, workflows, etc.), licensing (LICENSE.md, CODE_OF_CONDUCT.md), and build scripts (build/appx) that indicate a mature, open-source project.
- The src directory is the core of the application and contains:
- HTML pages (e.g., index.html, EQDetail.html, TsunamiDetail.html, etc.) that form the various user interfaces.
- CSS and font assets to handle styling.
- JavaScript files (from UIcommon.js to mainWindow.js, worker scripts such as EQDetectWorker.js and ESMap_Worker.js) that orchestrate interactivity and background processing. Notice that several JS files have names indicative of utilizing web-worker technology to offload heavy computation.
- A rich set of “Resource” JSON files (such as Knet_Points.json, tsunami.json, basemap.json, etc.) which likely hold static datasets used for mapping and visualization.
- Audio files and additional HTML pages (WorkerWindow.html, settings.html) to support additional functionality.
- The tools directory has additional diagnostic or helper tools (such as 電文パース.html) and accompanying scripts, indicating extensibility or debug modes.

##### Main Components
a. User Interface (Frontend):
- HTML/CSS views (index.html, EQDetail.html, TsunamiDetail.html, etc.) that handle the presentation layer.
- JavaScript controller components (mainWindow.js, settings.js) that manage user interactions.
- A dedicated Worker Window component to process background tasks (WorkerWindow.html) and associated worker scripts (EQDetectWorker.js, ESMap_Worker.js).
b. Data & Resources:
- Resource directory content (JSON files storing geospatial datasets, seismic data, submarine information, etc.)
- Audio assets for notifications and alerts.
c. External Data Sources/Services:
- Although not directly seen as API integration scripts, the documentation and data source references in the README imply backend interactions (for example, fetching real-time earthquake and tsunami notifications from governmental APIs and community sources).
d. Build and Configuration Tools:
- Package.json and ESLint config (eslint.config.js) as part of the development tools and the build processes depicted under the “build” directory.
- GitHub workflows and CI configurations as supporting infrastructure components for automated testing and linting.

##### Suggested Architectural Patterns and Relationships
- A clear separation between the presentation layer (HTML/CSS), logic layer (JS modules, including main UI scripts and web workers), and static data (the JSON resource files).
– For example, user interactions in the UI triggering JavaScript functions.
– JavaScript invoking worker threads to process heavy computations (indicated by ESMap_Worker.js, EQDetectWorker.js).
– Workers processing data by loading local JSON resources and possibly interfacing with external APIs.

- Components:
– Frontend UI (index.html, detail pages, settings).
– JS Modules / Controllers: mainWindow.js, settings.js, UIcommon.js.
– Worker Threads: EQDetectWorker.js, ESMap_Worker.js.
– Static Resources: Organized under src/Resource (with subcategories like Submarine, basemap, etc.).
– External Data Sources: Marked with labels referencing the various earthquake, tsunami, and seismic feeds (as described in the README).
- Relationships and Directions:
– Connect the UI components to their underlying JS logic.
– Illustrate how worker threads process data in parallel and communicate results back to the main thread.
– Show the inflow of external data from APIs into the JS layer and subsequent presentation in the UI.
– Optionally, include the build/configuration environment (CI workflows, ESLint, and build scripts) as supporting components that ensure code quality and structure.
- Additional Considerations:
– Ensure clear, legible labels.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U("User"):::external

    %% Frontend UI
    subgraph "Frontend UI"
        A1("index.html"):::ui
        A2("EQDetail.html"):::ui
        A3("TsunamiDetail.html"):::ui
        A4("settings.html"):::ui
        A5("HokkaidoSanriku.html"):::ui
        A6("KatsudoJokyo.html"):::ui
        A7("NankaiTrough.html"):::ui
        A8("WorkerWindow.html"):::ui
    end

    %% CSS Assets
    subgraph "CSS Assets"
        B1("style.css"):::ui
        B2("map.css"):::ui
        B3("EQDetail.css"):::ui
        B4("tsunamiDetail.css"):::ui
        B5("setting.css"):::ui
    end

    %% JavaScript Controllers & Modules
    subgraph "JS Controllers"
        C1("mainWindow.js"):::js
        C2("EQDetail.js"):::js
        C3("tsunamiDetail.js"):::js
        C4("UIcommon.js"):::js
        C5("settings.js"):::js
        C6("preload.js"):::js
    end

    %% Worker Threads
    subgraph "Worker Threads"
        D1("EQDetectWorker.js"):::worker
        D2("ESMap_Worker.js"):::worker
    end

    %% Static Data & Resources
    subgraph "Static Data & Resources"
        subgraph "JSON Resources"
            E1("Knet_Points.json"):::resource
            E2("PointSeismicIntensityLocation.json"):::resource
            E3("Snet_Points.json"):::resource
            E4("TimeTable_JMA2001.json"):::resource
            E5("TsunamiStations.json"):::resource
            E6("World.json"):::resource
            E7("basemap.json"):::resource
            E8("feRegion.json"):::resource
            E9("lake.json"):::resource
            E10("prefectures.json"):::resource
            E11("tsunami.json"):::resource
        end
        E12("Submarine (Directory)"):::resource
        subgraph "Audio Assets"
            E13a("EEW1.mp3"):::resource
            E13b("EEW2.mp3"):::resource
            E13c("EQDetectLv1.mp3"):::resource
            E13d("EQDetectLv2.mp3"):::resource
            E13e("EQInfo.mp3"):::resource
            E13f("TsunamiInfo.mp3"):::resource
        end
    end

    %% External Data Sources
    subgraph "External Data Sources"
        F1("External APIs (JMA,USGS,Community)"):::external
    end

    %% Build & Configuration Tools
    subgraph "Build & Config Tools"
        G1("build/appx"):::build
        G2("package.json"):::build
        G3("package-lock.json"):::build
        G4("eslint.config.js"):::build
        G5(".github/workflows/eslint.yml"):::build
        G6(".github/dependabot.yml"):::build
        G7(".github/ISSUE_TEMPLATE"):::build
    end

    %% Additional Tools
    subgraph "Additional Tools"
        H1("電文パース.html"):::tool
        H2("tools.js"):::tool
        H3("README.md"):::tool
    end

    %% Relationships
    U -->|"interacts"| A1
    U -->|"interacts"| A2
    U -->|"interacts"| A3
    U -->|"interacts"| A4
    U -->|"interacts"| A5
    U -->|"interacts"| A6
    U -->|"interacts"| A7
    U -->|"interacts"| A8

    %% UI triggers JS controllers
    A1 -->|"loads"| C1
    A2 -->|"loads"| C2
    A3 -->|"loads"| C3
    A4 -->|"loads"| C5

    %% CSS assets applied to HTML views
    B1 --- A1
    B2 --- A1
    B3 --- A2
    B4 --- A3
    B5 --- A4

    %% Main UI communication with Workers
    C1 -->|"offloads task"| D1
    C1 -->|"offloads task"| D2
    D1 -->|"returns data"| C1
    D2 -->|"returns data"| C1

    %% JS Controllers fetch external data
    C1 -->|"fetches"| F1
    C2 -->|"fetches"| F1
    C3 -->|"fetches"| F1

    %% Static data feeds into JS controllers and workers
    E1 --- C1
    E2 --- C1
    E3 --- C1
    E4 --- C1
    E5 --- C1
    E6 --- C1
    E7 --- C1
    E8 --- C1
    E9 --- C1
    E10 --- C1
    E11 --- C1
    E12 --- C1
    E13a --- C1
    E13b --- C1
    E13c --- C1
    E13d --- C1
    E13e --- C1
    E13f --- C1

    %% Build & Config supports development and deployment
    G1 -->|"builds"| C1
    G2 -->|"configures"| C1
    G3 -->|"configures"| C1
    G4 -->|"enforces"| C1
    G5 -->|"CI/CD"| C1
    G6 -->|"CI/CD"| C1
    G7 -->|"issue tracking"| C1

    %% Additional Tools assist Build & Config
    H1 -->|"diagnoses"| G1
    H2 -->|"scripts"| G1
    H3 -->|"docs"| G1

    %% JS Controllers use common functions
    C4 --- C1

    %% Worker Threads can be triggered by multiple controllers
    C1 --- D1
    C1 --- D2

    %% External Data may also update UI directly
    F1 -->|"pushes updates"| A1

    %% Styling classes
    classDef ui fill:#E0F7FA,stroke:#006064,stroke-width:2px;
    classDef js fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef worker fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef resource fill:#FFECB3,stroke:#F57C00,stroke-width:2px;
    classDef build fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef tool fill:#B3E5FC,stroke:#0288D1,stroke-width:2px;

    %% Click Events for Frontend UI (HTML)
    click A1 "https://github.com/0quake/zero-quake/blob/main/src/index.html"
    click A2 "https://github.com/0quake/zero-quake/blob/main/src/EQDetail.html"
    click A3 "https://github.com/0quake/zero-quake/blob/main/src/TsunamiDetail.html"
    click A4 "https://github.com/0quake/zero-quake/blob/main/src/settings.html"
    click A5 "https://github.com/0quake/zero-quake/blob/main/src/HokkaidoSanriku.html"
    click A6 "https://github.com/0quake/zero-quake/blob/main/src/KatsudoJokyo.html"
    click A7 "https://github.com/0quake/zero-quake/blob/main/src/NankaiTrough.html"
    click A8 "https://github.com/0quake/zero-quake/blob/main/src/WorkerWindow.html"

    %% Click Events for CSS Files
    click B1 "https://github.com/0quake/zero-quake/blob/main/src/css/style.css"
    click B2 "https://github.com/0quake/zero-quake/blob/main/src/css/map.css"
    click B3 "https://github.com/0quake/zero-quake/blob/main/src/css/EQDetail.css"
    click B4 "https://github.com/0quake/zero-quake/blob/main/src/css/tsunamiDetail.css"
    click B5 "https://github.com/0quake/zero-quake/blob/main/src/css/setting.css"

    %% Click Events for JS Controllers & Modules
    click C1 "https://github.com/0quake/zero-quake/blob/main/src/js/mainWindow.js"
    click C2 "https://github.com/0quake/zero-quake/blob/main/src/js/EQDetail.js"
    click C3 "https://github.com/0quake/zero-quake/blob/main/src/js/tsunamiDetail.js"
    click C4 "https://github.com/0quake/zero-quake/blob/main/src/js/UIcommon.js"
    click C5 "https://github.com/0quake/zero-quake/blob/main/src/js/settings.js"
    click C6 "https://github.com/0quake/zero-quake/blob/main/src/js/preload.js"

    %% Click Events for Worker Threads
    click D1 "https://github.com/0quake/zero-quake/blob/main/src/js/EQDetectWorker.js"
    click D2 "https://github.com/0quake/zero-quake/blob/main/src/js/ESMap_Worker.js"

    %% Click Events for JSON Resource Files
    click E1 "https://github.com/0quake/zero-quake/blob/main/src/Resource/Knet_Points.json"
    click E2 "https://github.com/0quake/zero-quake/blob/main/src/Resource/PointSeismicIntensityLocation.json"
    click E3 "https://github.com/0quake/zero-quake/blob/main/src/Resource/Snet_Points.json"
    click E4 "https://github.com/0quake/zero-quake/blob/main/src/Resource/TimeTable_JMA2001.json"
    click E5 "https://github.com/0quake/zero-quake/blob/main/src/Resource/TsunamiStations.json"
    click E6 "https://github.com/0quake/zero-quake/blob/main/src/Resource/World.json"
    click E7 "https://github.com/0quake/zero-quake/blob/main/src/Resource/basemap.json"
    click E8 "https://github.com/0quake/zero-quake/blob/main/src/Resource/feRegion.json"
    click E9 "https://github.com/0quake/zero-quake/blob/main/src/Resource/lake.json"
    click E10 "https://github.com/0quake/zero-quake/blob/main/src/Resource/prefectures.json"
    click E11 "https://github.com/0quake/zero-quake/blob/main/src/Resource/tsunami.json"
    click E12 "https://github.com/0quake/zero-quake/tree/main/src/Resource/Submarine"

    %% Click Events for Audio Assets
    click E13a "https://github.com/0quake/zero-quake/blob/main/src/audio/EEW1.mp3"
    click E13b "https://github.com/0quake/zero-quake/blob/main/src/audio/EEW2.mp3"
    click E13c "https://github.com/0quake/zero-quake/blob/main/src/audio/EQDetectLv1.mp3"
    click E13d "https://github.com/0quake/zero-quake/blob/main/src/audio/EQDetectLv2.mp3"
    click E13e "https://github.com/0quake/zero-quake/blob/main/src/audio/EQInfo.mp3"
    click E13f "https://github.com/0quake/zero-quake/blob/main/src/audio/TsunamiInfo.mp3"

    %% Click Events for Build & Config Tools
    click G1 "https://github.com/0quake/zero-quake/tree/main/build/appx"
    click G2 "https://github.com/0quake/zero-quake/blob/main/package.json"
    click G3 "https://github.com/0quake/zero-quake/blob/main/package-lock.json"
    click G4 "https://github.com/0quake/zero-quake/blob/main/eslint.config.js"
    click G5 "https://github.com/0quake/zero-quake/blob/main/.github/workflows/eslint.yml"
    click G6 "https://github.com/0quake/zero-quake/blob/main/.github/dependabot.yml"
    click G7 "https://github.com/0quake/zero-quake/tree/main/.github/ISSUE_TEMPLATE"

    %% Click Events for Additional Tools
    click H1 "https://github.com/0quake/zero-quake/blob/main/tools/電文パース.html"
    click H2 "https://github.com/0quake/zero-quake/blob/main/tools/tools.js"
    click H3 "https://github.com/0quake/zero-quake/blob/main/tools/README.md"
```
