# watchitdev/watchit-app architecture

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

- Interactive diagram: https://gitdiagram.com/watchitdev/watchit-app
- Repository: https://github.com/watchitdev/watchit-app

## Overview

##### Main Architectural Components
- Frontend/UI Layer:
- Overall client-side application, which is structured as a collection of React components (see the extensive “src/components” directory) including common UI elements (e.g., carousels, modals, dialogs, nav sections, and forms).
- “layouts”, “pages”, and “themes” directories, which define how the content is visually structured and styled.
- State Management & Business Logic:
- Context providers present in the “src/auth/context” (e.g., web3Auth context), and other hooks in “src/hooks” that encapsulate domain logic such as blockchain interactions and UI behavior.
- Blockchain Integration & Smart Contract Communication:
- “src/config” folder containing ABI definitions for blockchain contracts and the “src/clients” folder (e.g., using viem for publicClient) that wrap the blockchain connectivity.
- Specialized hooks (“src/hooks/protocol”) that facilitate interactions with decentralized protocols and smart contracts.
- Decentralized Content Delivery & Synapse Protocol:
- Integration with Synapse technology (as noted in the README) – mark an external connection to a distributed content delivery network powered by blockchain. Although the decentralized nodes are external, they are critical to the system architecture.
- Supporting Components:
- Static assets (“public” and “src/assets”) for images, fonts, and other media.
- Background workers (“src/workers”) for handling background tasks.
- The configuration, testing, and utility modules (e.g., “src/utils”, “src/hooks”) that support various functionalities throughout the app.

##### Out the Relationships and Interactions
- How user interactions in the Frontend/UI Trigger State Management updates (via Redux and React Context) and through the use of custom hooks.
- How the UI components interact with blockchain integration modules (via clients and protocol hooks) to validate authentication, fetch smart contract data, or perform transactions.
- From UI elements to the Redux store and context providers.
- From the Redux layer to the blockchain client modules (wrapping underlying smart contract calls).
- From blockchain integrations to external decentralized nodes (via the Synapse protocol).
- That the theming and layout components orchestrate the user experience, feeding into the overall UI presentation.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: Emphasize the modular React components clearly separated into directories (such as “components”, “layouts”, “pages”) that indicate reusability and encapsulation.
- State Management and Context Pattern: Illustrate how Redux and React Context for authentication (e.g., “src/auth/context/web3Auth”) are used to manage global state and access control, essential for decentralized authentication.
- Decoupling Between UI and Blockchain Logic: The design separates user interface concerns from blockchain communication (managed in dedicated “clients”, “config”, and “hooks/protocol” directories).
- Use of Testing and Configuration: Include references to test folders, ESLint, Prettier, and CI/CD workflows (in the “.github” folder) to denote attention to code quality and continuous integration.

##### Relevant Technologies and Frameworks
- Frontend: React, TypeScript, and Vite (as per “vite.config.ts”).
- State Management: Redux and React Context.
- Blockchain/Decentralized Components: Integration via web3Auth, Synapse protocol, and smart contract communication (ABIs in “src/config/abi”).
- UI/UX: Theming with custom shadows, typography, and overrides (see “src/theme”), along with robust component libraries (for modals, carousels, dialogs, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        UI_Components("React UI Components"):::frontend
        Layouts("Layouts"):::frontend
        Pages("Pages"):::frontend
        Theming("Theming & Styles"):::frontend
    end

    %% State Management & Business Logic
    subgraph "State Management & Business Logic"
        Redux("Redux Store & Reducers"):::state
        Auth("Authentication Context"):::state
        Hooks("Custom Hooks"):::state
    end

    %% Blockchain Integration & Smart Contract Communication
    subgraph "Blockchain Integration"
        ABIs("Blockchain ABIs & Config"):::blockchain
        Clients("Blockchain Clients (viem)"):::blockchain
        ProtHooks("Protocol Hooks"):::blockchain
    end

    %% External Decentralized Content Delivery
    nodeExternal("Decentralized Content Delivery (Synapse Protocol)"):::external

    %% Supporting Components
    subgraph "Supporting Components"
        AssetsPublic("Static Assets (Public)"):::support
        AssetsSrc("Static Assets (Source)"):::support
        Workers("Background Workers"):::support
        Utils("Utilities & Config"):::support
    end

    %% Data Flow Connections
    UI_Components -->|"triggers"| Redux
    UI_Components -->|"triggers"| Auth
    UI_Components -->|"triggers"| Hooks
    Layouts -->|"structures"| UI_Components
    Pages -->|"structures"| UI_Components
    Theming -->|"styles"| UI_Components

    Redux -->|"calls"| Clients
    Auth -->|"invokes"| ABIs
    Hooks -->|"utilizes"| ProtHooks
    Hooks -->|"utilizes"| Clients

    ABIs -->|"configures"| Clients

    Clients -->|"communicates"| nodeExternal
    ProtHooks -->|"interacts"| nodeExternal

    AssetsPublic -->|"supports"| UI_Components
    AssetsSrc -->|"supports"| UI_Components
    Workers -->|"processes"| UI_Components
    Utils -->|"supports"| Redux
    Utils -->|"supports"| Auth
    Utils -->|"supports"| Hooks

    %% Class Definitions for Colors
    classDef frontend fill:#A7D7C5,stroke:#333,stroke-width:2px;
    classDef state fill:#C5E1A5,stroke:#333,stroke-width:2px;
    classDef blockchain fill:#F8B195,stroke:#333,stroke-width:2px;
    classDef external fill:#FFD3B6,stroke:#333,stroke-width:2px;
    classDef support fill:#FFAAA5,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend/UI Layer
    click UI_Components "https://github.com/watchitdev/watchit-app/tree/main/src/components"
    click Layouts "https://github.com/watchitdev/watchit-app/tree/main/src/layouts"
    click Pages "https://github.com/watchitdev/watchit-app/tree/main/src/pages"
    click Theming "https://github.com/watchitdev/watchit-app/tree/main/src/theme"

    %% Click Events for State Management & Business Logic
    click Redux "https://github.com/watchitdev/watchit-app/tree/main/src/redux"
    click Auth "https://github.com/watchitdev/watchit-app/tree/main/src/auth/context/web3Auth"
    click Hooks "https://github.com/watchitdev/watchit-app/tree/main/src/hooks"

    %% Click Events for Blockchain Integration & Smart Contract Communication
    click ABIs "https://github.com/watchitdev/watchit-app/tree/main/src/config/abi"
    click Clients "https://github.com/watchitdev/watchit-app/tree/main/src/clients/viem"
    click ProtHooks "https://github.com/watchitdev/watchit-app/tree/main/src/hooks/protocol"

    %% Click Events for Supporting Components
    click AssetsPublic "https://github.com/watchitdev/watchit-app/tree/main/public"
    click AssetsSrc "https://github.com/watchitdev/watchit-app/tree/main/src/assets"
    click Workers "https://github.com/watchitdev/watchit-app/tree/main/src/workers"
    click Utils "https://github.com/watchitdev/watchit-app/tree/main/src/utils"
```
