# vtex-apps/my-account architecture

> Architecture diagram of the GitHub repository vtex-apps/my-account, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vtex-apps/my-account
- Repository: https://github.com/vtex-apps/my-account

## Overview

##### Project Type and Purpose
- Full-stack VTEX IO app (“My Account” hub)
- Purpose: centralize customer data (profile, addresses, orders, cards) and expose extension points for other apps (e.g. vtex.my-orders-app).
- Key builders in manifest.json: react (3.x), node (GraphQL resolvers), store (0.x), messages (i18n).

##### File Structure
- Top-level “react” folder: UI code (TSX, GraphQL queries, Router, pages, components, hooks, utils, typings).
- Top-level “node” folder: GraphQL schema (graphql/schema.graphql), resolvers (node/resolvers), service.json (VTEX platform bindings).
- “store” folder: store/interfaces.json & store/plugins.json – configuration for Store Builder extension points.
- “messages” folder: context.json for internationalization (Messages Builder).
- “my-account-extension-example”: reference sample illustrating how to use extension points.

##### README for Additional Insights
- Clarifies how clients add pages/links via store/interfaces.json + store/plugins.json.
- Shows React integration points: AppRouter, ProfileEdit, ProfileFormBox.
- Describes the flow of data through GraphQL queries/mutations (e.g., getProfile, saveAddress).

##### Main Components and Their Interactions
A. VTEX IO Core Platform
– Hosts your app, orchestrates builders, and provides render-runtime.
B. Front-end (React Builder)
– Components: AppRouter, Menu, Profile, Addresses, Loaders, shared UI.
– GraphQL queries (.gql) & auto-generated typings.
– Internationalization via messages/context.json.
C. Back-end (Node Builder)
– GraphQL server: schema.graphql + resolvers → orchestrates calls to Master Data, other VTEX APIs.
– service.json defines HTTP clients for external VTEX services.
D. Store Builder
– store/interfaces.json: declares extension point IDs → React components.
– store/plugins.json: mounts components into CMS extension slots (menu links, pages).
E. Messages Builder
– Provides locale/context for user-visible strings (messages/context.json).
F. Example Extension (“my-account-extension-example”)
– Illustrates how a third-party app can plug into the menu and page extension points.

##### Relationships & Data Flows
1. User opens “/account” URL in the storefront → VTEX render-runtime kicks in.
2. React bundle loads (DefaultPage → AppRouter), renders menu & routes.
3. Components fire GraphQL queries/mutations (via vtex.render-runtime fetch) to the Node GraphQL server.
4. Node resolvers translate GraphQL operations into calls to VTEX services (defined in service.json).
5. Responses flow back to React UI; state updates and pages re-render.
6. Store Builder injection points let additional React components (from your app or third-party apps) appear in the menu or as sub-pages.
7. Messages Builder injects translated strings into the React UI at runtime.

##### Architectural Patterns & Principles
- Builder pattern (VTEX IO builders: react, node, store, messages).
- Component-based UI (high cohesion, reuse).
- GraphQL façade – single endpoint hiding multiple backend calls.
- Extension points – loose coupling, open-closed principle.
- Separation of concerns – UI vs. API layer vs. store config vs. i18n.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Core Platform
    User["User"]:::user
    Core["VTEX IO Core Platform"]:::core
    User -->|opens /account| Core

    %% Manifest
    Manifest["manifest.json"]:::core
    Core --> Manifest

    %% React Builder
    subgraph "React Builder"
        direction TB
        Entry["react/index.tsx"]:::frontend
        DefaultRoute["react/DefaultRoute.tsx"]:::frontend
        DefaultPage["react/DefaultPage.tsx"]:::frontend
        AppRouter["AppRouter"]:::frontend
        Menu["Menu"]:::frontend
        MenuLink["MenuLink"]:::frontend
        MyProfileLink["Profile link"]:::frontend
        MyAddressesLink["Addresses link"]:::frontend
        ProfilePage["Profile page"]:::frontend
        ProfileBox["ProfileBox"]:::frontend
        ProfileFormBox["ProfileFormBox"]:::frontend
        AddressesPage["Addresses page"]:::frontend
        AddressBox["AddressBox"]:::frontend
        AddressForm["AddressForm"]:::frontend
        AddressDeleter["AddressDeleter"]:::frontend
        EmptyAddress["emptyAddress"]:::frontend
        Loaders["Loaders"]:::frontend
        SharedUI["Shared UI"]:::frontend
        GQLQueries["*.gql queries"]:::frontend
        GQLTypings["GraphQL Typings"]:::frontend
    end

    Core --> Entry
    Entry --> DefaultRoute --> DefaultPage --> AppRouter
    AppRouter --> Menu
    Menu --> MenuLink
    MenuLink --> MyProfileLink
    MenuLink --> MyAddressesLink
    AppRouter --> ProfilePage
    ProfilePage --> ProfileBox --> ProfileFormBox
    AppRouter --> AddressesPage
    AddressesPage --> AddressBox --> AddressForm
    AddressBox --> AddressDeleter
    AddressesPage --> EmptyAddress
    AppRouter --> Loaders
    AppRouter --> SharedUI
    AppRouter --> GQLQueries --> GQLTypings

    %% Node Builder
    subgraph "Node Builder"
        direction TB
        Schema["schema.graphql"]:::backend
        Resolvers["resolvers/settings.ts"]:::backend
        Server["node/index.ts"]:::backend
        ServiceJSON["service.json"]:::backend
    end

    Entry -->|GraphQL calls| Server
    Server --> Schema
    Server --> Resolvers
    Server --> ServiceJSON
    Server --> External["VTEX Services"]:::external

    %% Store Builder
    subgraph "Store Builder"
        direction TB
        Interfaces["interfaces.json"]:::store
        Plugins["plugins.json"]:::store
    end

    Interfaces -->|declare extension points| Entry
    Plugins -->|mount components| Entry

    %% Messages Builder
    subgraph "Messages Builder"
        direction TB
        MsgContext["context.json"]:::messages
    end

    MsgContext -->|i18n| Entry

    %% Example Extension
    subgraph "my-account-extension-example"
        direction TB
        ExtManifest["manifest.json"]:::store
        ExtMessages["messages/context.json"]:::messages
        ExtReact["react/*"]:::frontend
        ExtInterfaces["store/interfaces.json"]:::store
        ExtPlugins["store/plugins.json"]:::store
    end

    ExtInterfaces --> Entry
    ExtPlugins --> Entry

    %% Styles
    classDef core fill:#CCCCCC,stroke:#333;
    classDef frontend fill:#ADD8E6,stroke:#333;
    classDef backend fill:#90EE90,stroke:#333;
    classDef store fill:#FFFF99,stroke:#333;
    classDef messages fill:#FFD580,stroke:#333;
    classDef external fill:#E0E0E0,stroke:#888,stroke-dasharray:5 5;
    classDef user fill:#FFF2CC,stroke:#333;

    %% Click Events
    click Manifest "https://github.com/vtex-apps/my-account/blob/main/manifest.json"
    click Entry "https://github.com/vtex-apps/my-account/blob/main/react/index.tsx"
    click DefaultRoute "https://github.com/vtex-apps/my-account/blob/main/react/DefaultRoute.tsx"
    click DefaultPage "https://github.com/vtex-apps/my-account/blob/main/react/DefaultPage.tsx"
    click AppRouter "https://github.com/vtex-apps/my-account/blob/main/react/components/AppRouter.tsx"
    click Menu "https://github.com/vtex-apps/my-account/blob/main/react/components/Menu/index.tsx"
    click MenuLink "https://github.com/vtex-apps/my-account/blob/main/react/components/Menu/MenuLink.tsx"
    click MyProfileLink "https://github.com/vtex-apps/my-account/blob/main/react/MyProfileLink.tsx"
    click MyAddressesLink "https://github.com/vtex-apps/my-account/blob/main/react/MyAddressesLink.tsx"
    click ProfilePage "https://github.com/vtex-apps/my-account/blob/main/react/components/pages/Profile.tsx"
    click ProfileBox "https://github.com/vtex-apps/my-account/blob/main/react/components/Profile/ProfileBox.tsx"
    click ProfileFormBox "https://github.com/vtex-apps/my-account/blob/main/react/components/Profile/ProfileFormBox.tsx"
    click AddressesPage "https://github.com/vtex-apps/my-account/blob/main/react/components/pages/Addresses.tsx"
    click AddressBox "https://github.com/vtex-apps/my-account/blob/main/react/components/Addresses/AddressBox.tsx"
    click AddressForm "https://github.com/vtex-apps/my-account/blob/main/react/components/Addresses/AddressForm.tsx"
    click AddressDeleter "https://github.com/vtex-apps/my-account/blob/main/react/components/Addresses/AddressDeleter.tsx"
    click EmptyAddress "https://github.com/vtex-apps/my-account/blob/main/react/components/Addresses/emptyAddress.ts"
    click Loaders "https://github.com/vtex-apps/my-account/tree/main/react/components/loaders"
    click SharedUI "https://github.com/vtex-apps/my-account/tree/main/react/components/shared"
    click GQLQueries "https://github.com/vtex-apps/my-account/tree/main/react/graphql"
    click GQLTypings "https://github.com/vtex-apps/my-account/tree/main/react/typings/graphql"
    click Schema "https://github.com/vtex-apps/my-account/blob/main/graphql/schema.graphql"
    click Resolvers "https://github.com/vtex-apps/my-account/blob/main/node/resolvers/settings.ts"
    click Server "https://github.com/vtex-apps/my-account/blob/main/node/index.ts"
    click ServiceJSON "https://github.com/vtex-apps/my-account/blob/main/node/service.json"
    click Interfaces "https://github.com/vtex-apps/my-account/blob/main/store/interfaces.json"
    click Plugins "https://github.com/vtex-apps/my-account/blob/main/store/plugins.json"
    click MsgContext "https://github.com/vtex-apps/my-account/blob/main/messages/context.json"
    click ExtManifest "https://github.com/vtex-apps/my-account/blob/main/my-account-extension-example/manifest.json"
    click ExtMessages "https://github.com/vtex-apps/my-account/blob/main/my-account-extension-example/messages/context.json"
    click ExtReact "https://github.com/vtex-apps/my-account/tree/main/my-account-extension-example/react"
    click ExtInterfaces "https://github.com/vtex-apps/my-account/blob/main/my-account-extension-example/store/interfaces.json"
    click ExtPlugins "https://github.com/vtex-apps/my-account/blob/main/my-account-extension-example/store/plugins.json"
```
