# galdor/boulevard architecture

> Architecture diagram of the GitHub repository galdor/boulevard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/galdor/boulevard
- Repository: https://github.com/galdor/boulevard

## Overview

##### Main Components Identification

a. Core Components (pkg/boulevard):
- Format String Handler
- Module System
- Spill Buffer
- Templates Engine

b. Network Components (pkg/modules):
- HTTP Server Module
- TCP Server Module
- FastCGI Client
- Network Utilities

c. Service Layer (pkg/service):
- ACME Certificate Management
- Configuration Management
- Control API
- Module Management

**┌─ Client Layer ─────────────────────────┐**
- HTTP Clients │ TCP Clients │ FastCGI    │
- ┴─────────────┴───────────┘
- ↓             ↓            ↓
**┌─ Frontend Layer ──────────────────────────────┐**
- TCP Listeners │ TLS Termination │ ACME Cert   │
- ┴─────────────────┴────────────┘
- ↓             ↓            ↓
**┌─ Core Processing Layer ────────────────────────┐**
- HTTP Server │ TCP Server │ Reverse Proxy       │
- Auth (Basic/Bearer) │ Request Handling        │
- ┘
- ↓             ↓            ↓
**┌─ Backend Services Layer ──────────────────────┐**
- FastCGI │ Static Files │ Upstream Services    │
- ┘

##### Key Relationships to Highlight

a. Request Flow:
- How requests enter through listeners
- TLS termination points
- Routing through the HTTP/TCP servers
- Demonstrate backend service connections

b. Control Flow:
- Control API paths
- Configuration management flow
- Certificate management process

##### Implementation Details

- HTTP Server Module (pkg/modules/httpserver)
- Access Logger
- Authentication (Basic/Bearer)
- Request Handlers
- Path Patterns
- Actions (FastCGI, Redirect, Reverse Proxy, etc.)

- TCP Server Module (pkg/modules/tcpserver)
- Connection Management
- Listeners
- Status Monitoring

- Service Layer (pkg/service)
- Configuration Management
- Control API
- Module Management
- ACME Integration

##### Additional Notes

- Version information and date
- Experimental status of the project
- Configuration file relationship (cfg/*.yaml)
- Command-line interface points (cmd/boulevard-cli)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        HTTP_C[HTTP Clients]
        TCP_C[TCP Clients]
        FCGI_C[FastCGI]
    end

    %% Frontend Layer
    subgraph Frontend
        TCP_L["TCP Listeners"]:::network
        TLS["TLS Termination"]:::security
        ACME["ACME Certificate Management"]:::security
    end
    click ACME "https://github.com/galdor/boulevard/blob/master/pkg/service/acme.go"

    %% Core Processing Layer
    subgraph Core
        HTTP_S["HTTP Server"]:::core
        TCP_S["TCP Server"]:::core
        RP["Reverse Proxy"]:::core
        AUTH["Authentication"]:::security
        REQ_H["Request Handler"]:::core
    end
    click HTTP_S "https://github.com/galdor/boulevard/tree/master/pkg/modules/httpserver/"
    click TCP_S "https://github.com/galdor/boulevard/tree/master/pkg/modules/tcpserver/"
    click AUTH "https://github.com/galdor/boulevard/blob/master/pkg/modules/httpserver/auth_basic.go"
    click REQ_H "https://github.com/galdor/boulevard/blob/master/pkg/modules/httpserver/handler.go"

    %% Core Components
    subgraph Components
        FMT["Format String Handler"]:::util
        MOD["Module System"]:::util
        SPILL["Spill Buffer"]:::util
        TMPL["Templates Engine"]:::util
    end
    click FMT "https://github.com/galdor/boulevard/blob/master/pkg/boulevard/format_string.go"
    click MOD "https://github.com/galdor/boulevard/blob/master/pkg/boulevard/module.go"
    click SPILL "https://github.com/galdor/boulevard/blob/master/pkg/boulevard/spill_buffer.go"
    click TMPL "https://github.com/galdor/boulevard/blob/master/pkg/boulevard/templates.go"

    %% Service Layer
    subgraph Services
        CFG["Configuration Management"]:::util
        CTRL["Control API"]:::core
        MOD_MGT["Module Management"]:::util
    end
    click CFG "https://github.com/galdor/boulevard/blob/master/pkg/service/cfg.go"
    click CTRL "https://github.com/galdor/boulevard/blob/master/pkg/service/control_api.go"
    click MOD_MGT "https://github.com/galdor/boulevard/blob/master/pkg/service/modules.go"

    %% Backend Layer
    subgraph Backend
        FCGI["FastCGI Handler"]:::backend
        STATIC["Static File Server"]:::backend
        UPSTREAM["Upstream Services"]:::backend
    end
    click FCGI "https://github.com/galdor/boulevard/blob/master/pkg/fastcgi/client.go"
    click STATIC "https://github.com/galdor/boulevard/blob/master/pkg/modules/httpserver/action_serve.go"

    %% CLI Interface
    subgraph CLI
        MAIN_CLI["Main CLI"]:::cli
        STATUS["Status Command"]:::cli
        VERSION["Version Command"]:::cli
    end
    click MAIN_CLI "https://github.com/galdor/boulevard/blob/master/cmd/boulevard-cli/main.go"
    click STATUS "https://github.com/galdor/boulevard/blob/master/cmd/boulevard-cli/cmd_status.go"
    click VERSION "https://github.com/galdor/boulevard/blob/master/cmd/boulevard-cli/cmd_version.go"

    %% Relationships
    HTTP_C --> TCP_L
    TCP_C --> TCP_L
    FCGI_C --> TCP_L
    
    TCP_L --> TLS
    TLS --> HTTP_S
    TLS --> TCP_S
    ACME --> TLS
    
    HTTP_S --> AUTH
    AUTH --> REQ_H
    REQ_H --> RP
    
    RP --> FCGI
    RP --> STATIC
    RP --> UPSTREAM
    
    CTRL --> MOD_MGT
    MOD_MGT --> Components
    CFG --> Components

    %% Styling
    classDef network fill:#a8d1ff,stroke:#333
    classDef security fill:#90EE90,stroke:#333
    classDef core fill:#ffb366,stroke:#333
    classDef util fill:#d3d3d3,stroke:#333
    classDef backend fill:#ffccff,stroke:#333
    classDef cli fill:#ffffcc,stroke:#333

    %% Legend
    subgraph Legend
        N["Network Component"]:::network
        S["Security Component"]:::security
        C["Core Component"]:::core
        U["Utility Component"]:::util
        B["Backend Component"]:::backend
        L["CLI Component"]:::cli
    end
```
