# yossy4411/earthquake architecture

> Architecture diagram of the GitHub repository yossy4411/earthquake, 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/yossy4411/earthquake
- Repository: https://github.com/yossy4411/earthquake

## Overview

##### Project Type and Purpose
- This is a multi-platform application designed to display earthquake (and tsunami) information. It renders earthquake data on maps, shows distribution graphs, and supports various front-end clients (desktop, Android, iOS, browser, and even console tests).
- The README indicates it is aimed at displaying real-time or near-real-time earthquake information, including features like map overlays, vector maps, and a P2P communication component for earthquake data.

##### Main Components

a. Core Backend Logic:
- Earthquake data models (e.g., EarthQuakes, Station, Scale).
- P2P communication modules (under EarthQuake.Core/EarthQuakes/P2PQuake) for managing client-server connections and data channels.
- Supporting libraries for processing GeoJson and TopoJson data.
- Animation and data interpolation components.

b. And Visualization:
- Rendering using different layers (vector layers, raster layers, grid, cacheable layers, overlays for hypo views, etc.).
- Handling tile-based map rendering (dividing into subcomponents for file-based, raster, and vector tile controllers).

c. Platform-Specific Frontends:
- There are multiple UI projects indicating a multi-platform approach:
- “EarthQuake.Desktop” and main “EarthQuake” application for desktop (using Avalonia XAML as seen in App.axaml, various Views, and ViewModels).
- “EarthQuake.Browser” which appears to be a web-based client (with wwwroot files like index.html, main.js, and styling).
- “EarthQuake.Android” and “EarthQuake.iOS” representing mobile frontends.
- “MapTest” and “ConsoleTest” as testing or demo harnesses.

d. Utility and Data Generation:
- “MapDataGenerator” is a utility project for processing geo-data (GeoJson, TopoJson), which feeds data to the main application. Mark this as a supporting service feeding preprocessed data into the overall system.
- Console tests (P2PConsole and PerformanceTest) can be denoted as separate testing components used during development to validate key components (especially P2P communication and load performance).

##### Relationships and Interactions
- Within “EarthQuake.Core”, show internal communications between submodules (e.g., P2P communications interacting with network streams, converters, and earthquake data models).
- That “MapDataGenerator” feeds map assets/data to “EarthQuake.Map”.
- Optionally, include a connection to external services or repositories (e.g., a link or note referring to the external Go-based map generator repository).

##### Architectural Patterns and Design Principles
- The project appears to use the MVVM pattern in the main EarthQuake application (evident from ViewModels and Views directories).
- The separation of concerns is clear: core business logic is isolated from UI presentation, and map rendering is encapsulated in its module.
- P2P components in the Core suggest network communication is an orchestration pattern that might use client-server or peer-to-peer patterns.
- Multiple platform-specific projects indicate an abstraction layer, where shared core and map functionality is reused across different presentation layers.

##### Technologies and Frameworks
- .NET (particularly .NET 8.0) across most of the projects.
- Avalonia (or a similar XAML framework) for desktop frontends.
- Android and iOS projects with platform-specific packages.
- Web technologies are hinted at in the Browser project (HTML, CSS, JavaScript).
- In the map layer, integration with Skia/Canvas drawing (e.g., SkiaCanvasView) for rendering graphics.
- Also reference Python, Node.js, and Go in notes as used for ancillary data processing even though that code isn’t contained here.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Backend Layer
    subgraph "Backend Layer"
        Core["EarthQuake.Core"]:::backend
        P2P["P2P Communication"]:::backendSub
        MapModule["EarthQuake.Map"]:::backend2
        Generator["MapDataGenerator"]:::utility
        Core -->|"includes"| P2P
        Generator -->|"feeds"| MapModule
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        Desktop["Desktop Frontend"]:::frontend
        MainApp["Main EarthQuake Application"]:::frontend
        Browser["Browser Frontend"]:::frontend
        Android["Android Frontend"]:::frontend
        iOS["iOS Frontend"]:::frontend
    end

    %% Testing & Demo Layer
    subgraph "Testing & Demo"
        P2PTest["P2P Console Test"]:::testing
        Performance["Performance Test"]:::testing
        MapTest["Map Testing Harness"]:::testing
    end

    %% Connections: Frontend to Backend Components
    Desktop -->|"calls"| Core
    Desktop -->|"calls"| MapModule
    MainApp -->|"calls"| Core
    MainApp -->|"calls"| MapModule
    Browser -->|"calls"| Core
    Browser -->|"calls"| MapModule
    Android -->|"calls"| Core
    Android -->|"calls"| MapModule
    iOS -->|"calls"| Core
    iOS -->|"calls"| MapModule

    %% Connections: Testing Modules to Core Components
    P2PTest -.->|"tests"| Core
    Performance -.->|"tests"| Core
    MapTest -.->|"tests"| MapModule

    %% Click Events
    click Core "https://github.com/yossy4411/earthquake/blob/main/EarthQuake.Core"
    click P2P "https://github.com/yossy4411/earthquake/tree/main/EarthQuake.Core/EarthQuakes/P2PQuake"
    click MapModule "https://github.com/yossy4411/earthquake/blob/main/EarthQuake.Map"
    click Desktop "https://github.com/yossy4411/earthquake/blob/main/EarthQuake.Desktop"
    click MainApp "https://github.com/yossy4411/earthquake/tree/main/EarthQuake"
    click Browser "https://github.com/yossy4411/earthquake/blob/main/EarthQuake.Browser"
    click Android "https://github.com/yossy4411/earthquake/blob/main/EarthQuake.Android"
    click iOS "https://github.com/yossy4411/earthquake/blob/main/EarthQuake.iOS"
    click Generator "https://github.com/yossy4411/earthquake/tree/main/MapDataGenerator"
    click P2PTest "https://github.com/yossy4411/earthquake/tree/main/ConsoleTest/P2PConsole"
    click Performance "https://github.com/yossy4411/earthquake/tree/main/ConsoleTest/PerformanceTest"
    click MapTest "https://github.com/yossy4411/earthquake/tree/main/MapTest"

    %% Styles
    classDef backend fill:#ffadad,stroke:#d62728,stroke-width:2px;
    classDef backendSub fill:#ffcccb,stroke:#d62728,stroke-width:2px;
    classDef backend2 fill:#ffeb99,stroke:#d62728,stroke-width:2px;
    classDef utility fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef frontend fill:#d5f5e3,stroke:#196f3d,stroke-width:2px;
    classDef testing fill:#e2e3e5,stroke:#95999c,stroke-dasharray:5,5,stroke-width:2px;
```
