# julianfssen/jupiter-perps-anchor-idl-parsing architecture

> Architecture diagram of the GitHub repository julianfssen/jupiter-perps-anchor-idl-parsing, 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/julianfssen/jupiter-perps-anchor-idl-parsing
- Repository: https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing

## Overview

##### Main Components
- Examples Module – The heart of the repo lies in the "src/examples" directory. Each file here is a sample script (e.g., create-market-trade-request.ts, get-liquidation-price.ts, etc.) that demonstrates specific functionalities.
- IDL Parsing Module – Located in "src/idl", this includes:
- The TypeScript definition file (doves-idl.ts and jupiter-perpetuals-idl.ts)
- A JSON representation of the IDL (jupiter-perpetuals-idl-json.json)
These files represent the core of how the project parses and understands the Jupiter Perpetuals interface definition.
- Core Utilities – Supporting files like:
- constants.ts for shared constants across examples
- types.ts for common type definitions
- utils.ts for shared helper functions
- Configuration & Build – Standard project setup files such as package.json, tsconfig.json, and package-lock.json.

##### Relationships and Interactions
- The sample scripts inside the "src/examples" directory are the entry points that demonstrate data fetching and interactions. They primarily reference and import modules from the "src/constants.ts", "src/types.ts", and "src/utils.ts".
- These examples use the IDL parsing modules to understand the structure of the Jupiter Perpetuals interface, allowing them to construct and send the correct kinds of requests or data processing.
- The parsed IDL definitions outline how requests should be formatted and how responses are interpreted, which in turn affects how individual examples operate.
- Although external connectivity isn’t explicitly handled in the code structure, the README references external station guides and implies interaction with Jupiter’s back-end or blockchain network for data (price updates, fees, positions, etc.). This could be depicted as an external service connection.

##### Important Architectural Patterns and Design Principles
- Modularity – Components are clearly separated between examples, core utilities, and IDL definitions. Emphasize the import and dependency relationships.
- Layering – There is a clear “utility” layer (constants, types, utils) that supports the "business logic" in the examples.
- Reusability – The same IDL parsing files are used by multiple example scripts, indicating a central, reusable logic for interfacing with Jupiter’s perpetuals data.

##### Relevant Technologies, Frameworks, or Libraries
- Language & Build – The project is written in TypeScript (with tsconfig.json and a package.json); using Node.js.
- JSON-Based IDL – The repository contains both TypeScript and JSON representations of the IDL, which can be highlighted as an important aspect of its interface contract.
- External References – Links in the README point to guides on the Jupiter Station site, suggesting that these examples are meant to work with external APIs or blockchain data.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Examples Module
    subgraph "Examples Module"
        E1["create-market-trade-request.ts"]:::example
        E2["get-liquidation-price.ts"]:::example
    end

    %% IDL Parsing Module
    subgraph "IDL Parsing Module"
        I1["doves-idl.ts"]:::idl
        I2["jupiter-perpetuals-idl.ts"]:::idl
        I3["jupiter-perpetuals-idl-json.json"]:::idl
    end

    %% Core Utilities
    subgraph "Core Utilities"
        U1["constants.ts"]:::utility
        U2["types.ts"]:::utility
        U3["utils.ts"]:::utility
    end

    %% Configuration & Build
    subgraph "Configuration & Build"
        C1["package.json"]:::config
        C2["tsconfig.json"]:::config
        C3["package-lock.json"]:::config
    end

    %% External Service
    X(("Jupiter Perpetual Data Service/Blockchain")):::external

    %% Connections
    E1 -->|"imports_IDL"| I1
    E1 -->|"imports_util"| U1
    I1 -->|"fetches_data"| X

    %% Styles
    classDef example fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef idl fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef utility fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef config fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef external fill:#fdebd0,stroke:#f39c12,stroke-width:2px;

    %% Click Events
    click E1 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/examples/create-market-trade-request.ts"
    click E2 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/examples/get-liquidation-price.ts"
    click I1 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/idl/doves-idl.ts"
    click I2 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/idl/jupiter-perpetuals-idl.ts"
    click I3 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/idl/jupiter-perpetuals-idl-json.json"
    click U1 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/constants.ts"
    click U2 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/types.ts"
    click U3 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/src/utils.ts"
    click C1 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/package.json"
    click C2 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/tsconfig.json"
    click C3 "https://github.com/julianfssen/jupiter-perps-anchor-idl-parsing/blob/main/package-lock.json"
```
