# eightman999/hoi4navalmodder architecture

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

- Interactive diagram: https://gitdiagram.com/eightman999/hoi4navalmodder
- Repository: https://github.com/eightman999/hoi4navalmodder

## Overview

##### Main Components
- UI Layer:
- Views (found in the “View” directory) and Windows (in the “Window” directory). These represent the various screens (such as design views for guns, torpedoes, depth charges, radars, and fleet deployments) that the user interacts with.
- That Avalonia UI is used for the user interface.
- Business Logic / Core Layer:
- The “Core” folder contains the central logic, including Models (like NavalBase, NavalEquipment, IDESettingsManager), Services (e.g., DatabaseManager), and various Utilities (e.g., NavalGunIdGenerator, Map tools, UniqueIdGenerator). This layer orchestrates the core functionality, making calculations, data validations, and integrations.
- Calculators:
- The “Calculators” folder includes modules such as DepthChargeCalculator, GunCalculator, RadarCalculator, SonarCalculator, and TorpedoCalculator. These are specialized components that perform engineering and performance calculations for the naval designs.
- Mapper Layer:
- The “Mapper” folder contains modules that translate or map design data (e.g., gun, radar, sonar data) into the format needed by the database layer, ensuring that in-memory domain objects correctly align with the persistence model.
- Data Storage:
- Even though there isn’t an explicit “database” folder, dependencies like System.Data.SQLite indicate that a database (likely SQLite) is used, with data management integrated through services (DatabaseManager in Core/Services).

##### Relationships and Interactions
- UI Components (Views & Windows) interact directly with the Core layer through data binding and command patterns (the RelayCommand file in Core suggests use of MVVM).
- The Core layer relies on the Calculators to perform domain-specific computations which are often triggered via UI events.
- The Mapper layer serves as an adapter to transform in-memory data to database entities. It connects the Core and Persistence (DatabaseManager) components.
- The Core’s Utilities and Services provide cross-cutting functionalities (e.g., unique ID generation, map caching, etc.) that many components may call.

##### Architectural Patterns and Design Principles
- MVVM (Model-View-ViewModel): Indicated by Avalonia UI usage, separation of UI (View) from business logic (Models/Services).
- Layered Architecture: Clear separation between UI, Business Logic (including calculation and mapping), and Data Storage.
- Modularization: Separate directories for Calculators and Mapper modules to handle specific functionalities independently.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer (UI)"
        UIViews["Views (Avalonia UI)"]:::ui
        UIWindows["Windows (Main & Category)"]:::ui
    end

    subgraph "Business Logic (Core)"
        CoreModels["Core Models"]:::core
        CoreServices["Core Services (DatabaseManager)"]:::core
        CoreUtilities["Core Utilities"]:::core
    end

    subgraph "Computational Components"
        Calculators["Calculators Module"]:::calc
        Mapper["Mapper Module"]:::calc
    end

    subgraph "Data Storage"
        Database(("SQLite Database")):::db
    end

    subgraph "Supporting Assets"
        Assets["Assets (Icons & Fonts)"]:::assets
    end

    UIViews -->|"dataBinding"| CoreModels
    UIViews -->|"commands"| CoreServices
    UIWindows -->|"UIActions"| CoreServices
    CoreModels -->|"usedBy"| CoreServices
    CoreUtilities -->|"utilities"| CoreServices
    CoreServices -->|"invokeCalc"| Calculators
    CoreServices -->|"mapData"| Mapper
    Mapper -->|"persistData"| Database
    CoreServices -->|"persistData"| Database
    UIViews -->|"usesAssets"| Assets
    UIWindows -->|"usesAssets"| Assets

    click UIViews "https://github.com/eightman999/hoi4navalmodder/tree/master/View"
    click UIWindows "https://github.com/eightman999/hoi4navalmodder/tree/master/Window"
    click CoreModels "https://github.com/eightman999/hoi4navalmodder/tree/master/Core/Models"
    click CoreServices "https://github.com/eightman999/hoi4navalmodder/blob/master/Core/Services/DatabaseManager.cs"
    click CoreUtilities "https://github.com/eightman999/hoi4navalmodder/tree/master/Core/Utilities"
    click Calculators "https://github.com/eightman999/hoi4navalmodder/tree/master/Calculators"
    click Mapper "https://github.com/eightman999/hoi4navalmodder/tree/master/Mapper"
    click Assets "https://github.com/eightman999/hoi4navalmodder/tree/master/Assets"

    classDef ui fill:#a2d2ff,stroke:#000,stroke-width:1px;
    classDef core fill:#bde0fe,stroke:#000,stroke-width:1px;
    classDef calc fill:#ffc8dd,stroke:#000,stroke-width:1px;
    classDef db fill:#ffadad,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5;
    classDef assets fill:#caffbf,stroke:#000,stroke-width:1px;
```
