# cryptocj520/jiankong architecture

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

- Interactive diagram: https://gitdiagram.com/cryptocj520/jiankong
- Repository: https://github.com/cryptocj520/jiankong

## Overview

##### Project type and purpose
- This is a static, client-side web application (single-page app) for monitoring price differences between spot and perpetual contracts on Backpack Exchange.
- It provides a GUI in the browser, allowing users to configure parameters, fetch live price data from an external API, display it in a table, and issue alerts and logs.

##### File structure
- Top-level files:
- index.html – the HTML entry point and GUI layout
- price_monitor.js – main JavaScript module handling data fetch, processing, UI updates, notifications, and logging
- config.js – module for reading/applying user configuration settings
- README.md / .gitattributes – documentation and repo metadata
- There are no server or backend folders; all logic runs in the browser.
- No build scripts or package manifests—this is pure static HTML/JS/CSS.

##### README for additional insights
- Core features: real-time price table, configuration panel, browser desktop notifications, operation log area
- Workflow hints: user enters API credentials → clicks “Connect” → JS opens a connection (REST or WebSocket) to Backpack Exchange → polls or streams data → computes spreads → triggers UI updates and notifications
- Security note: in a production system you’d move API calls and signing to a backend—this implies potential future separation of client and server.

##### Elements
- Component labels: e.g., “Config Manager,” “Price Fetcher,” “Spread Calculator,” “UI – Price Table”
- Rectangles for in-browser modules

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser Boundary
    subgraph "Browser Environment"
        direction TB
        UI["UI - Price Table<br/>Configuration Panel<br/>Control Buttons<br/>Log Area"]:::frontend
        ConfigMgr["Configuration Manager"]:::logic
        Engine["Price Monitor Engine"]:::logic
        subgraph "Engine Components"
            direction TB
            Fetch["Data Fetch Module<br/>(REST/WebSocket Client)"]:::logic
            Calc["Spread Calculator"]:::logic
            Notify["Notification Manager<br/>(Browser Notification API)"]:::logic
            Logger["Logger<br/>(In-page Log Buffer)"]:::logic
        end
    end

    %% External Services
    API["Backpack Exchange API"]:::external
    BrowserNotify["Browser Notification Service"]:::external

    %% Documentation
    Docs["Documentation & Metadata"]:::docs

    %% Relationships
    UI -->|"applies settings"| ConfigMgr
    UI -->|"triggers connect"| Engine
    ConfigMgr -->|"provides config"| Engine
    Engine -->|"requests prices"| API
    API -->|"streams price data"| Fetch
    Fetch -->|"sends raw data"| Calc
    Calc -->|"computed spreads"| UI
    Calc -->|"threshold exceeded"| Notify
    Notify -->|"desktop notification"| BrowserNotify
    Notify -->|"log entry"| Logger
    UI -->|"shows logs"| Logger

    %% Click Events
    click UI "https://github.com/cryptocj520/jiankong/blob/main/index.html"
    click ConfigMgr "https://github.com/cryptocj520/jiankong/blob/main/config.js"
    click Engine "https://github.com/cryptocj520/jiankong/blob/main/price_monitor.js"
    click Docs "https://github.com/cryptocj520/jiankong/blob/main/README.md"
    click Docs "https://github.com/cryptocj520/jiankong/blob/main/.gitattributes"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef logic fill:#c8e6c9,stroke:#43a047,color:#1b5e20
    classDef external fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef docs fill:#e1bee7,stroke:#8e24aa,color:#4a148c
```
