# azrizhaziq/tradingview-syariah-indicator architecture

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

- Interactive diagram: https://gitdiagram.com/azrizhaziq/tradingview-syariah-indicator
- Repository: https://github.com/azrizhaziq/tradingview-syariah-indicator

## Overview

##### Main Components
- Data Package: This package (found under packages/data) contains the scripts for scraping, processing, and diffing stock list data. It also holds JSON data files (e.g., stock-list.json) and utilities to keep these data up-to-date.
- Extension Package: This core package (packages/extension) is the browser extension. It includes source code for background scripts, content scripts (page injection logic), popup UI components (React/TSX components), localization files, and manifest files for different browsers (Chrome and Firefox). It also includes end-to-end testing (e2e) with Playwright.
- Shared Package: (packages/shared) provides utility functions, common types, and models that are shared between the extension and the web components.
- Web Package: (packages/web) implements the website component, which serves as the frontend for information related to the extension, documentation, and possibly demo pages.
- Assets & Supporting Resources: The assets folder includes images/screenshots used in the README and documentation; additional configuration directories (.github, .husky, etc.) support continuous integration, linting, and formatting.

##### Relationships and Interactions
- The Data Package periodically updates stock data by scraping various listed sources (Bursa Malaysia, Wahed ETF HLAL, China ETF, etc.). The generated JSON data files will be used by the Extension Package.
- The Extension Package uses shared code from the Shared Package and integrates the data from the Data Package to determine when and where to inject the indicator on TradingView pages.
- The Web Package acts as a consumer of the shared utilities and the updated data may be rendered on the website, perhaps for listing stock data or offering an administration interface.
- There is a clear boundary between the browser extension’s logic (which interacts with TradingView pages) and the supporting data backend and website.

##### Architectural Patterns and Design Principles
- Modular Monorepo Structure: The project is split into several packages that handle distinct responsibilities, which encourages separation of concerns.
- Data Flow Pattern: Data is scraped/processed in one module, stored as JSON files, and then consumed by the browser extension to reflect real-time updates.
- Component-driven UI: The extension’s popup and page scripts are built with React-like component patterns (TSX components) and are clearly based on modern UI design principles.
- Testing and CI/CD Integration: Presence of E2E tests in the extension package using Playwright along with GitHub Actions for automated testing.

##### Technologies, Frameworks, and Libraries
- Node.js and TypeScript: Used across the packages, with configuration files such as tsconfig.json in several packages.
- PNPM Workspace: To manage dependencies and inter-package linking.
- Webpack and Vite: Webpack is used in the extension package (see webpack.config.ts) while Vite is used for the web package.
- Babel is configured (via .babelrc) for the extension package for JavaScript transpilation.
- Playwright is integrated for E2E testing in the extension package.
- SolidJS (mentioned in the README for the web package) as the frontend framework for the website.
- Environment configuration files (like .env.example and .nvmrc) ensure consistent development environments.

##### Elements
- From Data Package to Extension Package (indicating data updates).
- Between Shared Package and both Extension & Web packages.
- Annotations for important configuration artifacts (CI/CD pipeline using GitHub actions, linting/checking via Husky pre-commit scripts).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Package Cluster
    subgraph "Stock Data Scraping & Processing (Data Package)"
        DS("Data Scripts"):::dataClass
        JO("JSON Output"):::dataClass
        DM("Diffing Mechanism"):::dataClass
    end

    %% Extension Package Cluster
    subgraph "Browser Extension (Extension Package)"
        BG("Background Script"):::extClass
        CS("Content Script"):::extClass
        PU("Popup UI Components"):::extClass
        LF("Localization Files"):::extClass
        EP("Build Process (npm run build)"):::extClass
        PT("E2E Testing Suite"):::extClass
    end

    %% Shared Package Cluster
    subgraph "Shared Utilities & Models (Shared Package)"
        SU("Shared Utilities & Models"):::sharedClass
    end

    %% Web Package Cluster
    subgraph "Web Interface / Documentation (Web Package)"
        WI("SolidJS SPA Components"):::webClass
    end

    %% Assets & Supporting Resources Cluster
    subgraph "Assets & Supporting Resources"
        AS("Images, CI/CD, Linting & Configs"):::assetsClass
    end

    %% External System
    EX("TradingView Pages"):::external

    %% Connections:
    %% Data Package -> Extension Package
    JO -->|"dataUpdate"| BG

    %% Shared Package contributions
    SU -->|"sharedUsage"| BG
    SU -->|"sharedUsage"| WI

    %% Extension Package internal flow
    CS -->|"injects"| EX
    EP -->|"triggers"| PT

    %% Optional connection: Build process integrates UI components
    PU -->|"packaged"| EP

    %% Click Events:
    click DS "https://github.com/azrizhaziq/tradingview-syariah-indicator/tree/master/packages/data"
    click BG "https://github.com/azrizhaziq/tradingview-syariah-indicator/tree/master/packages/extension"
    click SU "https://github.com/azrizhaziq/tradingview-syariah-indicator/tree/master/packages/shared"
    click WI "https://github.com/azrizhaziq/tradingview-syariah-indicator/tree/master/packages/web"
    click AS "https://github.com/azrizhaziq/tradingview-syariah-indicator/tree/master/assets"

    %% Styles
    classDef dataClass fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef extClass fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef sharedClass fill:#ffd699,stroke:#cc6600,stroke-width:2px;
    classDef webClass fill:#e6ccff,stroke:#9933cc,stroke-width:2px;
    classDef assetsClass fill:#f2f2f2,stroke:#999999,stroke-width:2px;
    classDef external fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
```
