# gofynd/fdk-client-javascript architecture

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

- Interactive diagram: https://gitdiagram.com/gofynd/fdk-client-javascript
- Repository: https://github.com/gofynd/fdk-client-javascript

## Overview

##### Main Components

a. Core SDK Layer:
- Three main client interfaces: ApplicationClient, PlatformClient, and PublicClient
- Common utilities and base components (BaseOAuthClient, AxiosHelper, etc.)

b. Service Modules Layer:
- Various service modules (Cart, Catalog, Payment, etc.)
- How they inherit from their respective base clients

c. Authentication & Configuration Layer:
- ApplicationConfig, PlatformConfig, and PublicConfig components
- OAuth authentication flow

**[Client Applications]**
- ↓
**[SDK Entry Points]**
- ApplicationClient
- PlatformClient
- PublicClient
- ↓
**[Configuration Layer]**
- ApplicationConfig
- PlatformConfig
- PublicConfig
- ↓
**[Common Infrastructure]**
- OAuth Handling
- Axios Helpers
- Error Handling
- Logging
- ↓
**[Service Modules]**
- Cart
- Catalog
- Payment
- Other Services...
- ↓
**[External Services]**
- Fynd Platform API

##### Important Elements to Highlight

a. Client Flow:
- How requests flow from client application through the SDK layers
- Where authentication and request signing happens
- Points where cookie handling occurs

b. Module Organization:
- Related services (e.g., all commerce-related modules together)
- Shared components used across different clients

c. Infrastructure Components:
- Error handling mechanisms
- Logging system integration
- Where request/response transformation happens

##### Relationships

- Inheritance relationships between clients and their base classes
- Dependencies between modules
- Data flow directions
- Authentication token flow

##### Additional Details

- Version information
- SDK configuration options
- Browser vs Node.js support paths
- Public vs private interfaces

**→ Request Flow**
**⇢ Inheritance**
**● Required Component**
**○ Optional Component**
**█ External System**
**▢ Internal Module**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        ClientApp[Client Applications]
    end

    subgraph "SDK Entry Points"
        AppClient[ApplicationClient]:::core
        PlatClient[PlatformClient]:::core
        PubClient[PublicClient]:::core
    end

    subgraph "Configuration Layer"
        AppConfig[ApplicationConfig]:::config
        PlatConfig[PlatformConfig]:::config
        PubConfig[PublicConfig]:::config
    end

    subgraph "Common Infrastructure"
        OAuth[OAuth Handler]:::infra
        Axios[Axios Helper]:::infra
        Error[Error Handler]:::infra
        Logger[Logger]:::infra
        Utils[Utilities]:::infra
    end

    subgraph "Service Modules"
        direction TB
        Cart[Cart Service]:::service
        Catalog[Catalog Service]:::service
        Payment[Payment Service]:::service
        Order[Order Service]:::service
        User[User Service]:::service
        Theme[Theme Service]:::service
        Comm[Communication Service]:::service
    end

    subgraph "API Clients"
        AppAPI[Application API Client]:::api
        PlatAPI[Platform API Client]:::api
        PubAPI[Public API Client]:::api
    end

    subgraph "External"
        FyndAPI[Fynd Platform API]:::external
    end

    %% Connections
    ClientApp --> AppClient & PlatClient & PubClient
    AppClient --> AppConfig
    PlatClient --> PlatConfig
    PubClient --> PubConfig
    
    AppConfig & PlatConfig & PubConfig --> OAuth
    OAuth --> Axios
    Axios --> Error & Logger
    
    AppClient --> Cart & Catalog & Payment & Order & User & Theme & Comm
    Cart & Catalog & Payment & Order & User & Theme & Comm --> AppAPI
    AppAPI & PlatAPI & PubAPI --> Axios
    Axios --> FyndAPI

    %% Click Events
    click AppClient "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/ApplicationClient.js"
    click PlatClient "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/platform/PlatformClient.js"
    click PubClient "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/public/PublicClient.js"
    click AppConfig "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/ApplicationConfig.js"
    click PlatConfig "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/platform/PlatformConfig.js"
    click PubConfig "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/public/PublicConfig.js"
    click OAuth "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/common/BaseOAuthClient.js"
    click Axios "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/common/AxiosHelper.js"
    click Error "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/common/FDKError.js"
    click Logger "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/common/Logger.js"
    click Utils "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/common/Utility.js"
    click Cart "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/Cart/CartApplicationClient.js"
    click Catalog "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/Catalog/CatalogApplicationClient.js"
    click Payment "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/Payment/PaymentApplicationClient.js"
    click Order "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/Order/OrderApplicationClient.js"
    click User "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/User/UserApplicationClient.js"
    click Theme "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/Theme/ThemeApplicationClient.js"
    click Comm "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/Communication/CommunicationApplicationClient.js"
    click AppAPI "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/application/ApplicationAPIClient.js"
    click PlatAPI "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/platform/PlatformAPIClient.js"
    click PubAPI "https://github.com/gofynd/fdk-client-javascript/blob/master/sdk/public/PublicAPIClient.js"

    %% Styles
    classDef core fill:#2374e1,color:white
    classDef config fill:#4caf50,color:white
    classDef infra fill:#757575,color:white
    classDef service fill:#ffd700,color:black
    classDef api fill:#ff7043,color:white
    classDef external fill:#e91e63,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Configuration]:::config
        L3[Infrastructure]:::infra
        L4[Services]:::service
        L5[API Clients]:::api
        L6[External Systems]:::external
    end
```
