# arunpkio/tymoz architecture

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

- Interactive diagram: https://gitdiagram.com/arunpkio/tymoz
- Repository: https://github.com/arunpkio/tymoz

## Overview

##### Project Overview and Type
- tymoz is a cross-platform application built with Rust on the backend and SlintUI for the user interface. It supports desktop usage as well as deployment via WebAssembly.
- The primary purpose is to manage and display time zone information for selected cities, with functionalities like city selection, time formatting, and theme toggling.

##### Main Components
a. Desktop Application Components:
- Core Rust Backend: Represented by files such as src/main.rs and src/time_zones.rs. This is where the application logic and time zone processing occur.
- User Interface (UI): The ui directory includes Slint (.slint) files that define the layout and visual components (appwindow, various controls, headers, popups, etc.).
- Build Script: The build.rs file indicates custom build logic for the Rust application.
b. WebAssembly (WASM) Components:
- The pkg directory contains generated WebAssembly assets (WASM, JS glue, TypeScript declaration files) that enable the application to run in the browser.
- The existence of index.html and pkg.zip also points to a packaged demo for the web.

##### Understand the Architectural Patterns
- The UI (SlintUI components) layer calls into the Rust business logic.
- The backend (Rust logic) processes time and date functionalities and interacts with the UI.

##### Relationships and Interactions
- Clear two-way communication between the UI components (in the ui directory) and the backend logic (in src). This integration ensures that user actions (e.g., city selection, theme toggling) trigger updates in the backend logic and then the UI is refreshed accordingly.
- For the WebAssembly target, include the conversion or binding process where Rust is compiled to WASM. This component should show how the WASM module (from pkg) is loaded in the browser through the index.html.

##### Relevant Technologies and Tools
- Rust (core application logic).
- SlintUI (UI layer).
- WebAssembly (for loading the application in a web environment).
- Cargo (Rust’s build and dependency manager) evidenced by Cargo.toml and Cargo.lock.

- UI events (from Slint controls) to backend invocation.
- Data flow from backend logic to UI updates.
- WASM export from Rust to web, initiated in index.html.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Desktop Application"
        subgraph "Rust Backend"
            main["Rust Main (src/main.rs)"]:::rust
            tz["Time Zones (src/time_zones.rs)"]:::rust
            build["Build Script (build.rs)"]:::rust
        end
        subgraph "UI Layer (SlintUI)"
            appwindow["App Window (ui/appwindow.slint)"]:::ui
            cityPopup["City List Popup (ui/city_list_popup.slint)"]:::ui
            controls["Controls (ui/controls/*)"]:::ui
            dataAdapter["Data Adapter (ui/data_adapter.slint)"]:::ui
            header["Header (ui/header.slint)"]:::ui
            icons["Icons (ui/icons)"]:::ui
        end
    end

    subgraph "WebAssembly Module"
        wasmPkg["WASM Package (pkg/)"]:::wasm
        index["Index HTML (index.html)"]:::wasm
    end

    subgraph "Deployment/CI"
        workflows["GitHub Workflows (.github/workflows/)"]:::deploy
    end

    %% Communication between UI and Rust Backend
    appwindow -->|"UserAction"| main
    main -->|"UpdateUI"| appwindow
    cityPopup -->|"UserAction"| tz
    tz -->|"TimeData"| dataAdapter

    %% Rust Backend to WebAssembly Module flow
    main -->|"CompiledToWASM"| wasmPkg
    index -->|"LoadsWASM"| wasmPkg

    %% Deployment/CI triggering builds for both Desktop and Web targets
    workflows -->|"CI/CDPipeline"| build
    workflows -->|"CI/CDPipeline"| index

    %% Click Events for Rust Backend
    click main "https://github.com/arunpkio/tymoz/blob/main/src/main.rs"
    click tz "https://github.com/arunpkio/tymoz/blob/main/src/time_zones.rs"
    click build "https://github.com/arunpkio/tymoz/blob/main/build.rs"

    %% Click Events for UI Layer (SlintUI)
    click appwindow "https://github.com/arunpkio/tymoz/blob/main/ui/appwindow.slint"
    click cityPopup "https://github.com/arunpkio/tymoz/blob/main/ui/city_list_popup.slint"
    click controls "https://github.com/arunpkio/tymoz/tree/main/ui/controls"
    click dataAdapter "https://github.com/arunpkio/tymoz/blob/main/ui/data_adapter.slint"
    click header "https://github.com/arunpkio/tymoz/blob/main/ui/header.slint"
    click icons "https://github.com/arunpkio/tymoz/tree/main/ui/icons"

    %% Click Events for WebAssembly Module
    click wasmPkg "https://github.com/arunpkio/tymoz/tree/main/pkg/"
    click index "https://github.com/arunpkio/tymoz/blob/main/index.html"

    %% Click Event for Deployment/CI
    click workflows "https://github.com/arunpkio/tymoz/tree/main/.github/workflows/"

    %% Styling
    classDef rust fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef ui fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef wasm fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef deploy fill:#FF8C00,stroke:#000,stroke-width:2px;
```
