# openziti/ziti-browzer-bootstrapper architecture

> Architecture diagram of the GitHub repository openziti/ziti-browzer-bootstrapper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openziti/ziti-browzer-bootstrapper
- Repository: https://github.com/openziti/ziti-browzer-bootstrapper

## Overview

##### Main Components

a. Core Components:
- OIDC Provider (External Authentication Service)
- OpenZiti Controller
- Ziti BrowZer Bootstrapper Server
- Client Web Browser
- Protected Web Services

b. Supporting Components:
- Certificate Management System
- Environment Configuration
- HTTP Proxy System

**Client Layer**

**Security Layer**

**Bootstrapper Core**

**Network Layer**

##### Component Relationships

a. Client Flow:
- Browser → OIDC Provider (Authentication)
- Browser → Bootstrapper (Initial Connection)
- Browser → Protected Services (Post-Bootstrap)

b. Security Flow:
- Bootstrapper ↔ Certificate Management
- Bootstrapper ↔ OIDC Provider
- Bootstrapper ↔ OpenZiti Controller

##### Technical Details

a. Core Services (from lib/ directory):
- Edge Service (lib/edge/)
- HTTP Proxy (lib/http-proxy/)
- OIDC Integration (lib/oidc/)

b. Configuration Elements:
- Environment Variables
- Target Configuration
- SSL/TLS Certificate Paths

##### Specific Implementation Details

a. HTTP Proxy System:
- Custom proxy passes (from lib/http-proxy/passes/)
- CORS handling
- Ziti-specific request/response handling

b. Edge Communication:
- Context management
- Fetch polyfill implementation
- Options handling

##### Key Flows to Illustrate

a. Bootstrap Process:
**Browser → Bootstrapper**
- → OIDC Authentication
- → JWT Token Validation
- → Service Access Grant

b. Service Access:
**Browser → Protected Service**
- → Ziti Network
- → Target Service

##### Additional Elements

- Version/environment indicators
- Configuration dependencies
- Security boundaries

##### Integration Points

Clearly mark:
- OIDC Provider integration
- OpenZiti Controller communication
- Protected service connections
- Certificate management points

Remember to include notes about scaling considerations and security boundaries, as these are crucial for a zero-trust implementation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Security
        OIDC["OIDC Provider"]:::security
        CertMgmt["Certificate Management"]:::security
        click CertMgmt "https://github.com/openziti/ziti-browzer-bootstrapper/tree/main/greenlock.d/"
        WhiteList["White List Filter"]:::security
        click WhiteList "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/white-list-filter.js"
    end

    subgraph Bootstrapper["Bootstrapper Core"]
        direction TB
        MainEntry["Main Entry Point"]:::core
        click MainEntry "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/index.js"
        
        subgraph EdgeService["Edge Service"]
            direction TB
            Context["Context Management"]:::edge
            click Context "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/edge/context.js"
            Options["Options Handler"]:::edge
            click Options "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/edge/context-options.js"
            FetchImpl["Fetch Implementation"]:::edge
            click FetchImpl "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/edge/fetch-polyfill.js"
            EdgeConst["Edge Constants"]:::edge
            click EdgeConst "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/edge/constants.js"
        end

        subgraph ProxySystem["HTTP Proxy System"]
            direction TB
            MainProxy["Main Proxy"]:::proxy
            click MainProxy "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/http-proxy/index.js"
            CORSHandler["CORS Handler"]:::proxy
            click CORSHandler "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/http-proxy/passes/cors-proxy.js"
            ZitiReq["Ziti Request Handler"]:::proxy
            click ZitiReq "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/http-proxy/passes/ziti-request.js"
            ZitiRes["Ziti Response Handler"]:::proxy
            click ZitiRes "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/http-proxy/passes/ziti-response.js"
            WebIncoming["Web Incoming Handler"]:::proxy
            click WebIncoming "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/http-proxy/passes/web-incoming-zitified.js"
        end

        subgraph Config["Configuration"]
            direction TB
            EnvHandler["Environment Handler"]:::config
            click EnvHandler "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/env.js"
            MainConfig["Main Configuration"]:::config
            click MainConfig "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/config.json"
            SSLConfig["SSL Configuration"]:::config
            click SSLConfig "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/greenlock.d/config.json"
        end

        subgraph Templates["Web Templates"]
            direction TB
            MainTemplate["Main Template"]:::template
            click MainTemplate "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/assets/template.ejs"
            BrowZerTemplate["BrowZer Template"]:::template
            click BrowZerTemplate "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/assets/template-zbr.ejs"
            ZrokTemplate["Zrok Template"]:::template
            click ZrokTemplate "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/assets/template-zrok.ejs"
        end

        OIDCUtils["OIDC Integration"]:::core
        click OIDCUtils "https://github.com/openziti/ziti-browzer-bootstrapper/blob/main/lib/oidc/utils.js"
    end

    subgraph Network
        ZitiController["OpenZiti Controller"]:::network
        ProtectedServices["Protected Web Services"]:::network
    end

    %% Relationships
    Browser --> OIDC
    Browser --> MainEntry
    Browser --> ProtectedServices
    MainEntry --> OIDCUtils
    OIDCUtils --> OIDC
    MainEntry --> CertMgmt
    MainEntry --> WhiteList
    MainEntry --> ZitiController
    ProxySystem --> ProtectedServices
    EdgeService --> ZitiController

    %% Styles
    classDef core fill:#2374ab
    classDef edge fill:#2374ab,stroke:#666
    classDef proxy fill:#2374ab,stroke:#666
    classDef config fill:#2374ab,stroke:#666
    classDef template fill:#2374ab,stroke:#666
    classDef security fill:#48a9a6
    classDef network fill:#e4572e
    
    %% Legend
    subgraph Legend
        CoreComponent["Core Components"]:::core
        SecurityComponent["Security Components"]:::security
        NetworkComponent["Network Components"]:::network
    end
```
