# friggframework/api-module-library architecture

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

- Interactive diagram: https://gitdiagram.com/friggframework/api-module-library
- Repository: https://github.com/friggframework/api-module-library

## Overview

- v1-ready API Modules – the refactored, optimized modules built for the new Frigg v1 architecture.
- Older “needs-updating” API Modules – the legacy modules originally from Frigg v0.

##### Overall Project Context
– Represent the Frigg API Module Library as the central system.
– Note that the purpose is to serve as a collection of modules, each encapsulating integration logic with a specific third-party API.

##### Main Components
a. Repository Infrastructure:
- Inside, two primary groups:
– “v1-ready API Modules” (new family)
– “Needs-Updating API Modules” (legacy family)
b. Individual API Modules:
- Within each group, represent individual modules as separate components (rectangles) with names such as “activecampaign”, “stripe”, “hubspot”, “asana”, etc.
- Each module should include internal components such as:
– API Layer (api.js)
– Configuration (defaultConfig.json)
– Manager/Controller (manager.js) that encapsulates business logic and helper functions.
– Models (for credential or entity definitions).
– Test suites (illustrated to denote testing structure).
c. External Third-Party APIs:

##### Relationships and Data Flow
– Connect the “API Modules” components to the external third-party services indicating that these modules act as bridges.
– Illustrate how “v1-ready” modules might adhere to improved, uniform integration patterns, while the “needs-updating” modules are legacy implementations.

##### Architectural Patterns and Technologies
– Highlight that the system employs a modular (plug-in) architecture where each module is developed independently.
– Note the use of Lerna and NX as tools for monorepo management – you might encapsulate these as “DevOps/Build Tools” alongside the repository.
– Point out that each module is structured similarly (with API, configs, models, tests), which shows a consistency in design—perhaps a “template” can be visually indicated.
– Mention common usage of Node.js and JavaScript testing workflows (jest, setup/teardown scripts) to illustrate the technical stack.
– Optionally, annotate that continuous integration (via GitHub Actions workflows in the .github directory) ties the modules together for streamlined builds and releases.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    FC["Frigg Core/Consumer"]:::core
    Repo["Monorepo (API Module Library for Frigg Integrations)"]:::monorepo
    DevOps["DevOps/Build Tools"]:::devops

    %% Directory Nodes (for component mapping)
    V1Dir["v1-ready Directory"]:::v1Based
    LegacyDir["Needs-Updating Directory"]:::legacy

    %% External Services
    ExtAsana["External: Asana"]:::external
    ExtStripe["External: Stripe"]:::external
    ExtHubSpot["External: HubSpot"]:::external
    ExtActiveCampaign["External: ActiveCampaign"]:::external
    ExtSlack["External: Slack"]:::external
    ExtMSTeams["External: Microsoft Teams"]:::external

    %% Subgraph for v1-ready API Modules
    subgraph "v1-ready API Modules"
        Asana["API Module: Asana"]:::v1Based
        Stripe["API Module: Stripe"]:::v1Based
        HubSpot["API Module: HubSpot"]:::v1Based
    end

    %% Subgraph for Needs-Updating API Modules
    subgraph "Needs-Updating API Modules"
        ActiveCampaign["API Module: ActiveCampaign"]:::legacy
        Slack["API Module: Slack"]:::legacy
        MSTeams["API Module: Microsoft Teams"]:::legacy
    end

    %% Data Flow Connections
    FC -->|"consumes"| Repo
    Repo -->|"contains"| V1Dir
    Repo -->|"contains"| LegacyDir
    Repo ---|"managed by"| DevOps

    %% Link Directory nodes to individual modules
    V1Dir --> Asana
    V1Dir --> Stripe
    V1Dir --> HubSpot

    LegacyDir --> ActiveCampaign
    LegacyDir --> Slack
    LegacyDir --> MSTeams

    %% API Module to External Service connections
    Asana -->|"integrates"| ExtAsana
    Stripe -->|"integrates"| ExtStripe
    HubSpot -->|"integrates"| ExtHubSpot

    ActiveCampaign -->|"integrates"| ExtActiveCampaign
    Slack -->|"integrates"| ExtSlack
    MSTeams -->|"integrates"| ExtMSTeams

    %% Class Definitions for Colour Coding
    classDef core fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef monorepo fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef devops fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef v1Based fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef legacy fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef external fill:#ADD8E6,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click Repo "https://github.com/friggframework/api-module-library/blob/main/package.json"
    click V1Dir "https://github.com/friggframework/api-module-library/tree/main/packages/v1-ready"
    click LegacyDir "https://github.com/friggframework/api-module-library/tree/main/packages/needs-updating"
    click DevOps "https://github.com/friggframework/api-module-library/tree/main/.github/workflows"
    click Asana "https://github.com/friggframework/api-module-library/tree/main/packages/v1-ready/asana"
    click Stripe "https://github.com/friggframework/api-module-library/tree/main/packages/v1-ready/stripe"
    click HubSpot "https://github.com/friggframework/api-module-library/tree/main/packages/v1-ready/hubspot"
    click ActiveCampaign "https://github.com/friggframework/api-module-library/tree/main/packages/needs-updating/activecampaign"
    click Slack "https://github.com/friggframework/api-module-library/tree/main/packages/needs-updating/slack"
    click MSTeams "https://github.com/friggframework/api-module-library/tree/main/packages/needs-updating/microsoft-teams"
```
