# ch-chang/rocket architecture

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

- Interactive diagram: https://gitdiagram.com/ch-chang/rocket
- Repository: https://github.com/ch-chang/rocket

## Overview

##### Project type and purpose
- This is a desktop GUI application (“Rocket 火箭”) written entirely in PowerShell (v5.1) on top of .NET, aimed at providing a lightweight RESTful API testing tool where installing heavier tools (Postman, Apifox) is not permitted.
- It exposes a set of GUI windows for composing HTTP requests, cryptographic helpers, and project import/export, and records requests and responses for later analysis.

##### File structure
- Top‐level entry scripts:
- Main.ps1 / Run.bat – bootstrap the application
- ScriptAnalyzerSettings.psd1 – linting/config
- Utils folder (core services):
- Data.psm1 – data models and in‐memory storage
- Requester.psm1 – HTTP request builder/executor using .NET classes
- Settings.psm1 – load/save user and project configurations
- Writer.psm1 – persistence (log to disk, export/import)
- Windows folder (presentation layer):
- MainWindow.psm1 – primary GUI for composing requests
- AddDialogWindow.psm1 – create new request entries
- SettingWindow.psm1 – application settings
- CryptoWindow.psm1 / HashWindow.psm1 – cryptographic helpers
- CI: .github/workflows/Release.yml
- Documentation: README.md, CHANGELOG, LICENSE

##### README for additional insights
- Confirms pure PowerShell/.NET stack
- GUI‐centric, no external services beyond standard HTTP endpoints
- Features: RESTful requests, logging, import/export
- No microservices or separate backend; monolithic modular script

a. Main components
1. Presentation Layer (GUI)
– PowerShell window modules (.psm1 under Windows/)
2. Core Services (Business Logic)
– Utils modules: Data, Requester, Settings, Writer
3. Persistence Layer
– Local file system for request/response logs and project files
4. External Services
– Any RESTful API endpoints the user is testing
5. Runtime Environment
– PowerShell v5.1 + .NET CLR

b. Relationships and interactions
- GUI windows invoke functions in Utils modules.
- Requester builds and sends HTTP requests → receives responses.
- Data module holds in‐session state (current request list, history).
- Writer module persists state and logs to disk; Settings module reads/writes config.
- External REST API is the ultimate target of HTTP calls.
- Runtime is the host platform (PowerShell/.NET).

c. Architectural patterns / design principles
– Module separation: “Windows/” modules for UI; “Utils/” modules for services.
– Single‐process monolith with clear logical layers.
– Dependency injection via PowerShell module imports.
– Event‐driven UI: user actions → module calls → UI updates.

d. Key technologies / frameworks
- PowerShell v5.1 scripting host
- .NET Windows Presentation Foundation (WPF) or WinForms under the hood
- Native .NET HttpClient (invoked from Requester.psm1)

##### Detailed steps for the principal software engineer
2. Inside it, create three tiers:
- Middle tier “Core Modules”: Data.psm1, Requester.psm1, Settings.psm1, Writer.psm1
- Bottom tier “Persistence”: file system (requests.log, projects.json)
- From Requester.psm1 out to “External REST API” cloud
4. With technologies:
– Next to Requester, note “.NET HttpClient”
– Next to UI, note “WPF/WinForms via PowerShell”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Bootstrap Scripts and Documentation
    MP["Main.ps1"]:::script
    RB["Run.bat"]:::script
    SA["ScriptAnalyzerSettings.psd1"]:::script
    CI["Release.yml"]:::script
    RD1["README.md"]:::doc
    RD2["README_EN.md"]:::doc
    CL["CHANGELOG.md"]:::doc
    LI["LICENSE"]:::doc

    %% Runtime Container
    subgraph "PowerShell v5.1 + .NET CLR"
        %% GUI / Presentation Layer
        subgraph "GUI / Presentation"
            MW["MainWindow.psm1"]:::ui
            AD["AddDialogWindow.psm1"]:::ui
            SW["SettingWindow.psm1"]:::ui
            CW["CryptoWindow.psm1"]:::ui
            HW["HashWindow.psm1"]:::ui
        end
        %% Core Services Layer
        subgraph "Core Services"
            DT["Data.psm1"]:::service
            REQ["Requester.psm1"]:::service
            SET["Settings.psm1"]:::service
            WR["Writer.psm1"]:::service
        end
        %% Persistence Layer
        subgraph "Persistence Layer"
            FS["File System"]:::persistence
        end
    end

    %% External Services
    ER["External REST API"]:::external

    %% Relationships
    MP -->|"launches"| MW
    RB -->|"launches"| MW
    SA --- MW

    MW -->|invokes| DT
    MW -->|invokes| REQ
    MW -->|invokes| SET
    MW -->|invokes| WR

    AD -->|invokes| DT
    AD -->|invokes| WR

    SW -->|invokes| SET

    CW -->|invokes| DT
    HW -->|invokes| DT

    REQ -->|".NET HttpClient"| ER

    WR -->|writes to| FS
    SET -->|reads/writes| FS

    %% Click Events
    click MW "https://github.com/ch-chang/rocket/blob/main/Windows/MainWindow.psm1"
    click AD "https://github.com/ch-chang/rocket/blob/main/Windows/AddDialogWindow.psm1"
    click SW "https://github.com/ch-chang/rocket/blob/main/Windows/SettingWindow.psm1"
    click CW "https://github.com/ch-chang/rocket/blob/main/Windows/CryptoWindow.psm1"
    click HW "https://github.com/ch-chang/rocket/blob/main/Windows/HashWindow.psm1"
    click DT "https://github.com/ch-chang/rocket/blob/main/Utils/Data.psm1"
    click REQ "https://github.com/ch-chang/rocket/blob/main/Utils/Requester.psm1"
    click SET "https://github.com/ch-chang/rocket/blob/main/Utils/Settings.psm1"
    click WR "https://github.com/ch-chang/rocket/blob/main/Utils/Writer.psm1"
    click MP "https://github.com/ch-chang/rocket/blob/main/Main.ps1"
    click RB "https://github.com/ch-chang/rocket/blob/main/Run.bat"
    click SA "https://github.com/ch-chang/rocket/blob/main/ScriptAnalyzerSettings.psd1"
    click CI "https://github.com/ch-chang/rocket/blob/main/.github/workflows/Release.yml"
    click RD1 "https://github.com/ch-chang/rocket/blob/main/README.md"
    click RD2 "https://github.com/ch-chang/rocket/blob/main/README_EN.md"
    click CL "https://github.com/ch-chang/rocket/blob/main/CHANGELOG.md"
    click LI "https://github.com/ch-chang/rocket/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0066CC;
    classDef service fill:#DFFFE0,stroke:#339933;
    classDef persistence fill:#FFF5CC,stroke:#CC9933;
    classDef external fill:#EEEEEE,stroke:#888888,stroke-dasharray: 5 5;
    classDef script fill:#F0F8FF,stroke:#5A9BD4;
    classDef doc fill:#FFF0F0,stroke:#CC3333;
```
