# navigraph/navigraph-js-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/navigraph/navigraph-js-sdk
- Repository: https://github.com/navigraph/navigraph-js-sdk

## Overview

##### And define the main components
- Monorepo structure: Represent the overall project as a monorepo that encapsulates various interrelated packages.
- Navigraph App (packages/app)
- Navigraph Auth (packages/auth)
- Navigraph Charts (packages/charts)
- Other related packages such as amdb, leaflet, weather, and packages (which itself aggregates package-related functionality)
- The “navigraph” package that further organizes or aggregates these
- Examples/Demos: Include the “examples” folder with separate demos (e.g., “getting-started” and “playground”) that show how end-users integrate the SDK into full-stack applications.

##### Component relationships and interactions
- Examples as consuming the public API exposed by these packages and demonstrating the internal interactions.

##### Architectural patterns
- Separation of concerns: Note that each package handles a distinct domain (e.g., authentication, chart retrieval, weather data), following modular design principles.
- API Layer Abstraction: Illustrate that packages abstract over underlying Navigraph API endpoints and external services used by Microsoft Flight Simulator and similar environments.

##### Technologies and tools
- TypeScript/JavaScript is the primary language.
- Vite is used in example projects (as seen from vite.config.ts).
- Testing is integrated via Jest (jest.config.js files are present in several packages).
- Code quality and formatting tools such as ESLint and Prettier are configured.
- Build tools like tsup and Turbo are used for bundling and managing tasks.

- At the highest level, display the Monorepo container that holds subcomponents.
– An “Initialization & Core” section (navigraph/app, including the initializeApp function).
– “Authentication” (navigraph/auth) showing API calls (sign in, token management).
– “Data Services” such as charts, weather, and amdb, each with their APIs.
– “Presentation/Examples” (the examples directory), which consume and showcase how these packages work together.
- With the relevant details (e.g., “calls getAuth()”, “retrieves charts index”) tied to the example code in the README.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Container
    M["Monorepo Structure"]:::core

    %% Core SDK Packages Subgraph
    subgraph "Core SDK Packages"
        A["Navigraph App"]:::core
        U["Navigraph Auth"]:::core
        C["Navigraph Charts"]:::core
        D["Navigraph AMDB"]:::core
        L["Navigraph Leaflet"]:::core
        W["Navigraph Weather"]:::core
        P["Navigraph Packages"]:::core
    end

    %% Example/Demos Subgraph
    subgraph "Example/Demos"
        GS["Getting Started"]:::example
        PG["Playground"]:::example
    end

    %% External API Endpoint
    E["Navigraph API Endpoint"]:::external

    %% Relationships
    M --> A
    A -->|"initializeApp/signIn"| U
    A -->|"uses aggregation"| P

    U -->|"getAuth"| C
    U -->|"tokenPass"| D
    U -->|"tokenPass"| W

    C -->|"retrieveCharts"| E
    D -->|"retrieveAMDB"| E
    W -->|"retrieveWeather"| E
    L -->|"mapsCharts"| C

    GS -->|"demoIntegration"| A
    PG -->|"demoIntegration"| A

    %% Click Events
    click M "https://github.com/navigraph/navigraph-js-sdk/tree/main/[Root Project Directory]"
    click A "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/app"
    click A "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/navigraph/app"
    click U "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/auth"
    click U "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/navigraph/auth"
    click C "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/charts"
    click C "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/navigraph/charts"
    click D "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/amdb"
    click D "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/navigraph/amdb"
    click L "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/leaflet"
    click W "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/weather"
    click W "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/navigraph/weather"
    click P "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/packages"
    click P "https://github.com/navigraph/navigraph-js-sdk/tree/main/packages/navigraph/packages"
    click GS "https://github.com/navigraph/navigraph-js-sdk/tree/main/examples/getting-started"
    click PG "https://github.com/navigraph/navigraph-js-sdk/tree/main/examples/playground"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef example fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef external fill:#F7DC6F,stroke:#B7950B,stroke-width:2px;
```
