# bia-pain-bache/bpb-wizard architecture

> Architecture diagram of the GitHub repository bia-pain-bache/bpb-wizard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bia-pain-bache/bpb-wizard
- Repository: https://github.com/bia-pain-bache/bpb-wizard

## Overview

BPB Wizard installs BPB Panel into a user’s Cloudflare account through separate Web and CLI editions. Both collect account credentials, choose Workers or Pages, create a KV namespace, build a configured panel script, deploy it, and return the panel URL. The CLI additionally supports saved multiple accounts; the Web edition returns an encrypted token for its one-click private-link flow. Source excerpts show the main orchestration and deployment calls; static-page wiring and some CLI helper details are not shown, so those links are omitted.

Main entry points: [`web/src/index.ts`](https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/index.ts) (Web request handler), [`main.go`](https://github.com/bia-pain-bache/bpb-wizard/blob/main/main.go) (CLI workflow), [`internal/app.go`](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/app.go) (Account and deploy prompts), [`internal/api.go`](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/api.go) (Cloudflare account API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI edition"]
  node_cli_entry["CLI workflow<br/>[main.go]"]
  node_cli_prompts["Account and deploy prompts<br/>[app.go]"]
  node_token_store[("Saved logins<br/>[token_store.go]")]
  node_cli_logger["CLI logger<br/>[logger.go]"]
end

subgraph group_web["Web edition"]
  node_web_handler["Web request handler<br/>[index.ts]"]
  node_web_logger["Stream logger<br/>[logger.ts]"]
  node_token_crypto["Private-link encryption<br/>[encryption.ts]"]
end

subgraph group_shared["Deployment logic"]
  node_cli_api["Cloudflare account API<br/>[api.go]"]
  node_cli_script["Script builder<br/>[script.go]"]
  node_cli_random["Random values<br/>[random.go]"]
  node_web_account["Cloudflare account API<br/>[api.ts]"]
  node_web_builder["Script builder<br/>[script.ts]"]
  node_web_random["Random values<br/>[random.ts]"]
end

subgraph group_external["External services"]
  node_cloudflare{{"Cloudflare platform"}}
  node_panel_release["BPB Panel release"]
end

node_cli_user(("CLI user"))
node_web_user(("Web user"))
node_panel_result["Installed panel URL"]

node_cli_user -->|"runs wizard"| node_cli_entry
node_cli_entry -->|"loads and saves"| node_token_store
node_cli_entry -->|"requests choices"| node_cli_prompts
node_cli_entry -->|"creates namespace"| node_cli_api
node_cli_entry -->|"checks name"| node_cli_api
node_cli_entry -->|"selects deploy flow"| node_cli_prompts
node_cli_entry -->|"reports progress"| node_cli_logger
node_cli_prompts -->|"validates account"| node_cli_api
node_cli_prompts -->|"builds deployment script"| node_cli_script
node_cli_prompts -->|"deploys Workers or Pages"| node_cli_api
node_cli_api -->|"calls account APIs"| node_cloudflare
node_cli_script -->|"generates settings"| node_cli_random
node_web_user -->|"submits deployment"| node_web_handler
node_web_handler -->|"streams status"| node_web_logger
node_web_handler -->|"decrypts or encrypts token"| node_token_crypto
node_web_handler -->|"creates account and namespace"| node_web_account
node_web_handler -->|"deploys Workers"| node_web_account
node_web_handler -->|"deploys Pages"| node_web_account
node_web_handler -->|"builds deployment script"| node_web_builder
node_web_handler -->|"returns URL and key"| node_panel_result
node_web_account -->|"calls account APIs"| node_cloudflare
node_web_builder -->|"fetches panel script"| node_panel_release
node_web_builder -->|"generates settings"| node_web_random

click node_cli_entry "https://github.com/bia-pain-bache/bpb-wizard/blob/main/main.go"
click node_cli_prompts "https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/app.go"
click node_token_store "https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/token_store.go"
click node_cli_api "https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/api.go"
click node_cli_script "https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/script.go"
click node_cli_random "https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/random.go"
click node_cli_logger "https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/logger.go"
click node_web_handler "https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/index.ts"
click node_web_logger "https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/logger.ts"
click node_web_account "https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/api.ts"
click node_web_builder "https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/script.ts"
click node_web_random "https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/random.ts"
click node_token_crypto "https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/encryption.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli_entry,node_cli_prompts,node_token_store,node_cli_logger,node_cli_user,node_web_user toneBlue
class node_web_handler,node_web_logger,node_token_crypto toneAmber
class node_cli_api,node_cli_script,node_cli_random,node_web_account,node_web_builder,node_web_random toneMint
class node_cloudflare,node_panel_release toneRose
class node_panel_result toneIndigo
```

## Components

### CLI edition

- [CLI workflow](https://github.com/bia-pain-bache/bpb-wizard/blob/main/main.go): `main.go`
- [Account and deploy prompts](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/app.go): `internal/app.go`
- [Saved logins](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/token_store.go): `internal/token_store.go`
- [CLI logger](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/logger.go): `internal/logger.go`

### Web edition

- [Web request handler](https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/index.ts): `web/src/index.ts`
- [Stream logger](https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/logger.ts): `web/src/logger.ts`
- [Private-link encryption](https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/encryption.ts): `web/src/encryption.ts`

### Deployment logic

- [Cloudflare account API](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/api.go): `internal/api.go`
- [Script builder](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/script.go): `internal/script.go`
- [Random values](https://github.com/bia-pain-bache/bpb-wizard/blob/main/internal/random.go): `internal/random.go`
- [Cloudflare account API](https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/api.ts): `web/src/api.ts`
- [Script builder](https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/script.ts): `web/src/script.ts`
- [Random values](https://github.com/bia-pain-bache/bpb-wizard/blob/main/web/src/random.ts): `web/src/random.ts`

### External services

- **Cloudflare platform**
- **BPB Panel release**

### Other components

- **CLI user**
- **Web user**
- **Installed panel URL**

## Connections

- CLI user → CLI workflow: runs wizard (evidence: `README.md`)
- CLI workflow → Saved logins: loads and saves (evidence: `main.go`)
- CLI workflow → Account and deploy prompts: requests choices (evidence: `main.go`)
- CLI workflow → Cloudflare account API: creates namespace (evidence: `main.go`)
- CLI workflow → Cloudflare account API: checks name (evidence: `main.go`)
- CLI workflow → Account and deploy prompts: selects deploy flow (evidence: `main.go`)
- CLI workflow → CLI logger: reports progress (evidence: `main.go`)
- Account and deploy prompts → Cloudflare account API: validates account (evidence: `internal/app.go`)
- Account and deploy prompts → Script builder: builds deployment script (evidence: `internal/app.go`)
- Account and deploy prompts → Cloudflare account API: deploys Workers or Pages (evidence: `internal/app.go`)
- Cloudflare account API → Cloudflare platform: calls account APIs (evidence: `internal/api.go`)
- Script builder → Random values: generates settings (evidence: `internal/script.go`)
- Web user → Web request handler: submits deployment (evidence: `web/src/index.ts`)
- Web request handler → Stream logger: streams status (evidence: `web/src/index.ts`)
- Web request handler → Private-link encryption: decrypts or encrypts token (evidence: `web/src/index.ts`)
- Web request handler → Cloudflare account API: creates account and namespace (evidence: `web/src/index.ts`)
- Web request handler → Cloudflare account API: deploys Workers (evidence: `web/src/index.ts`)
- Web request handler → Cloudflare account API: deploys Pages (evidence: `web/src/index.ts`)
- Web request handler → Script builder: builds deployment script (evidence: `web/src/index.ts`)
- Web request handler → Installed panel URL: returns URL and key (evidence: `web/src/index.ts`)
- Cloudflare account API → Cloudflare platform: calls account APIs (evidence: `web/src/api.ts`)
- Script builder → BPB Panel release: fetches panel script (evidence: `web/src/script.ts`)
- Script builder → Random values: generates settings (evidence: `web/src/script.ts`)
