# irislib/iris-messenger architecture

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

- Interactive diagram: https://gitdiagram.com/irislib/iris-messenger
- Repository: https://github.com/irislib/iris-messenger

## Overview

##### Main Components
- Web Frontend: This is the core client built using Vite and Preact. It includes all the user-facing components (views, UI elements, components for feed, chat, profiles, settings, etc.), state management (local state, storage adapters), and helper utilities.
- Tauri Desktop Backend: The “src-tauri” folder holds the Rust-based Tauri integration that wraps the web app into standalone native desktop applications for Windows, macOS, and Linux.
- Static Assets & Build Configuration: This covers the “public” folder (with images, configuration files such as assetlinks.json, robots.txt, etc.), build files (Dockerfile, docker-compose.yml), and project configuration (eslint, prettier, tsconfig, vite.config, etc.).
- Scripts and Tools: The “scripts” directory for CSV/translation utilities and the tests directory for verification.
- External Interfaces: (a) Communication with Nostr relays through various NIP implementations (the README clearly lists a number of NIPs such as NIP-04 for DMs, NIP-42 for relay authentication, etc.) and (b) External integrations for sign up, offline-first capabilities, and browser-based Nostr keys (window.nostr).

##### Relationships and Interactions
- The Web Frontend (Preact components, state management, routing) communicates with:
- User inputs and events (chat, feeds, profile management) via client-side event handlers.
- The Tauri backend when running as a desktop application; this is often a bidirectional message exchange to tap into native APIs.
- External Nostr relays for real-time event propagation and message exchange.
- The Tauri backend (Rust layer) provides a bridge between the web UI and native OS capabilities (such as file system access, notifications, etc.).
- Docker and build configurations provide environments for development and deployment – using Docker Compose to spin up the environment easily.
- The static assets layer holds assets required for UI presentation, SEO files, and other metadata.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project is cleanly split between frontend (view components, state management) and native desktop functionalities (Tauri).
- Component-Based Structure: In the “src/js/components” folder, individual UI pieces (headers, feeds, modals, chat views, etc.) are separated and can be individually updated or reused.
- Offline-first and local state: There’s a clear focus on local event storage (IndexedDB and in-memory adapters) that’s crucial for offline performance.

##### Including Relevant Technologies and Frameworks
- Vite (for development and bundling) and Preact (for the frontend UI).
- Tailwind CSS and DaisyUI (for styling and UI components).
- TypeScript for safer code in the “src” folder.
- Tauri / Rust (for native desktop builds).
- Docker for containerized development environments.
- GitHub Actions workflows (CI/CD pipelines are visible in the “.github/workflows” folder) that can be shown as supporting automation.

##### Putting It All Together
1. Client Layer: Include “UI Components”, “Utility Modules”, “Local State Management”, and “Translations/Helpers”.
2. Native/Desktop Layer: Represented by the “src-tauri” block (Rust-Tauri), connected to the Client Layer.
3. Infrastructure & Integration: Include external Nostr relays, Docker and CI/CD pipelines, and static assets/deployment configurations.

## Diagram (Mermaid)

```mermaid
graph TD
    irisApp["Iris Messenger Application"]:::title

    subgraph "Client Layer (UI)"
        frontend_UI["Web Client (Vite+Preact)"]:::frontend
        state_mgmt["State Management & Local Storage"]:::frontend
        helpers["Translations & Helper Utilities"]:::frontend
    end

    subgraph "Native/Desktop Layer"
        tauri_backend["Tauri Backend (Rust)"]:::backend
    end

    subgraph "Infrastructure & Integration"
        static_assets["Static Assets & Build Configurations"]:::config
        script_tools["Scripts & Tools (CSV/Translation, Tests)"]:::config
        external_nostr["External Nostr Relays & Protocol Endpoints"]:::external
    end

    irisApp -->|"start"| frontend_UI
    frontend_UI -->|"databinding"| state_mgmt
    state_mgmt -->|"updates"| frontend_UI
    helpers -->|"supports"| frontend_UI

    frontend_UI <-->|"native_bridge"| tauri_backend
    frontend_UI -->|"nostr_events"| external_nostr

    classDef title fill:#ffe0b2,stroke:#f57c00,stroke-width:2px;
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef external fill:#ffcc80,stroke:#000,stroke-width:2px;
    classDef config fill:#d3d3d3,stroke:#000,stroke-width:2px;

    click frontend_UI "https://github.com/irislib/iris-messenger/tree/master/src"
    click frontend_UI "https://github.com/irislib/iris-messenger/tree/master/src/js"
    click frontend_UI "https://github.com/irislib/iris-messenger/tree/master/src/views"
    click frontend_UI "https://github.com/irislib/iris-messenger/tree/master/src/css"
    click frontend_UI "https://github.com/irislib/iris-messenger/blob/master/src/main.tsx"

    click tauri_backend "https://github.com/irislib/iris-messenger/tree/master/src-tauri"
    click tauri_backend "https://github.com/irislib/iris-messenger/blob/master/src-tauri/src/main.rs"
    click tauri_backend "https://github.com/irislib/iris-messenger/blob/master/src-tauri/tauri.conf.json"

    click static_assets "https://github.com/irislib/iris-messenger/tree/master/public"
    click static_assets "https://github.com/irislib/iris-messenger/tree/master/Dockerfile"
    click static_assets "https://github.com/irislib/iris-messenger/blob/master/docker-compose.yml"
    click static_assets "https://github.com/irislib/iris-messenger/tree/master/.github/workflows"
    click static_assets "https://github.com/irislib/iris-messenger/blob/master/tsconfig.json"
    click static_assets "https://github.com/irislib/iris-messenger/blob/master/vite.config.ts"
    click static_assets "https://github.com/irislib/iris-messenger/blob/master/.eslintrc.cjs"
    click static_assets "https://github.com/irislib/iris-messenger/blob/master/.prettierrc"

    click script_tools "https://github.com/irislib/iris-messenger/tree/master/scripts"
    click script_tools "https://github.com/irislib/iris-messenger/blob/master/scripts/CsvToTranslations.mjs"
    click script_tools "https://github.com/irislib/iris-messenger/blob/master/scripts/TranslationsToCsv.mjs"
    click script_tools "https://github.com/irislib/iris-messenger/tree/master/tests"
    click script_tools "https://github.com/irislib/iris-messenger/blob/master/tests/RBSortedMap.ts"
    click script_tools "https://github.com/irislib/iris-messenger/blob/master/tests/SortedMap.bench.ts"

    click external_nostr "https://github.com/irislib/iris-messenger/tree/master/src/js/nostr"
    click external_nostr "https://github.com/irislib/iris-messenger/tree/master/src/js/nostr/hooks"
```
