# thp-lab/organization-values architecture

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

- Interactive diagram: https://gitdiagram.com/thp-lab/organization-values
- Repository: https://github.com/thp-lab/organization-values

## Overview

##### Main Components
- Frontend: The entire "src/app" folder along with numerous UI components (e.g., Hero, Header, Footer, Carousel, Accordion, etc.). This is the Next.js-driven SPA that interacts directly with users.
- Backend / API Integration: The "src/backend" folder encapsulates various JavaScript modules (abi.js, gqlClient.js, mutations.js, queries.js) that manage communication with the external Intuition GraphQL API.
- Context and State Management: Components like "src/contexts/UserContext.js" and providers are used to manage application state and user sessions.
- Web3 Integration: Although not in a dedicated folder, integration with Ethereum (e.g., wallet connection via ConnectWalletButton and hooks for web3 interactions) is a crucial part of the architecture.

##### Relationships and Interactions
- The Frontend (Next.js SPA) is the central point, handling user interactions.
- UI Components: Users interact with various UI elements (forms, buttons, modals) that trigger actions via React and Next.js.
- Data Flow: When a user submits new values or votes, the frontend invokes functionality from the backend modules (e.g., queries or mutations) in "src/backend", which then communicate with the Intuition GraphQL API.
- Web3 Integration: A Web3 wallet (e.g., MetaMask) is used by users to authenticate and sign transactions. This interface, along with wagmi hooks, ensures a secure connection to the Ethereum network.

##### Architectural Patterns & Technologies
- Next.js Architecture: Leverage its built-in routing (from the "src/app" folder structure) to structure the front end as an SPA.
- Component-Based Design: The extensive use of React components (e.g., header, footer, modals, forms) suggests a modular design that allows for reusability and separation of concerns.
- API Integration: Use of a dedicated backend module pattern to encapsulate API calls (GraphQL operations) separately from UI logic.
- Web3 & GraphQL: Highlight the use of technologies such as wagmi hooks for wallet integration and GraphQL for data interaction.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Global Node
    UBR("User (Browser)"):::external

    %% Frontend Subgraph
    subgraph "Frontend (Next.js App)"
        direction TB
        NA("Next.js App"):::frontend
        A("UI Components"):::frontend
        subgraph "State Management & Contexts"
            direction TB
            BM("UserContext.js"):::frontend
            BP("providers.js"):::frontend
        end
        C("ConnectWalletButton"):::frontend
        subgraph "Utilities & Styling"
            direction TB
            U("Utils"):::utility
            S("Styles"):::utility
        end
    end

    %% Backend API Integration Subgraph
    subgraph "Backend API Integration"
        direction TB
        X("Backend Directory"):::backend
        E("abi.js"):::backend
        F("gqlClient.js"):::backend
        G("mutations.js"):::backend
        H("queries.js"):::backend
    end

    %% External Services Subgraph
    subgraph "External Services"
        direction TB
        I("Intuition GraphQL API"):::external
        J("Ethereum Blockchain"):::external
    end

    %% Connections
    UBR --> NA
    NA --> A
    A --> BM
    BP -->|"triggersAPI"| X
    NA --> C
    NA --> U
    U --> S

    %% Backend internal connections
    X --> E
    X --> F
    X --> G
    X --> H

    %% Data flow from Backend to External Services
    F -.->|"callsGraphQL"| I
    E -.->|"blockchainCall"| J

    %% Web3 integration flow
    C -.->|"walletSign"| J

    %% Class Definitions
    classDef frontend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef backend fill:#cfc,stroke:#333,stroke-width:2px;
    classDef external fill:#fcc,stroke:#333,stroke-width:2px;
    classDef utility fill:#ffc,stroke:#333,stroke-width:2px;

    %% Click Events
    click NA "https://github.com/thp-lab/organization-values/tree/main/src/app"
    click A "https://github.com/thp-lab/organization-values/tree/main/src/components"
    click BM "https://github.com/thp-lab/organization-values/blob/main/src/contexts/UserContext.js"
    click BP "https://github.com/thp-lab/organization-values/blob/main/src/contexts/providers.js"
    click C "https://github.com/thp-lab/organization-values/blob/main/src/components/connect-wallet-button/ConnectWalletButton.js"
    click U "https://github.com/thp-lab/organization-values/tree/main/src/utils"
    click S "https://github.com/thp-lab/organization-values/tree/main/src/styles"
    click X "https://github.com/thp-lab/organization-values/tree/main/src/backend"
    click E "https://github.com/thp-lab/organization-values/blob/main/src/backend/abi.js"
    click F "https://github.com/thp-lab/organization-values/blob/main/src/backend/gqlClient.js"
    click G "https://github.com/thp-lab/organization-values/blob/main/src/backend/mutations.js"
    click H "https://github.com/thp-lab/organization-values/blob/main/src/backend/queries.js"
```
