# northernside/wiredshield architecture

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

- Interactive diagram: https://gitdiagram.com/northernside/wiredshield
- Repository: https://github.com/northernside/wiredshield

## Overview

##### Main Components Identification

a) Core Proxy Layer
- HTTP/HTTPS handling (http/https.go)
- DNS resolution (dns/dns.go)
- Reverse proxy functionality

b) Security Components
- WAF functionality
- PGP authentication system (modules/pgp/*)
- SSL handling (commands/libs/ssl.go)

c) Database Layer
Multiple database support:
- LMDB (modules/db/lmdb.go)
- PostgreSQL (modules/db/psql.go)
- DNS database (modules/db/dns.go)

d) Service Layer
- Core services (services/services.go)
- WHOIS functionality (modules/whois/whois.go)

**[Incoming Traffic]**
- ↓
**[DNS Resolution Layer]**
- ↓
**[Reverse Proxy Layer]**
- ↓
**[WAF Security Layer]**
- ↓
**[Backend Services]**

##### Component Relationships

- Blue: Traffic flow components (DNS, Proxy)
- Red: Security components (WAF, PGP, SSL)
- Green: Database components
- Yellow: Service components

##### Detailed Component Breakdown

a) Proxy Layer:
**[HTTPS Handler] ← → [SSL Manager]**
- ↓
**[Route Handler]**
- ↓
**[Proxy Authentication]**

b) Security Layer:
**[WAF Rules Engine]**
- ↓
**[PGP Authentication]**
- ↙     ↓     ↘
**[Public] [Private] [Token]**

c) Database Layer:
**[Database Interface]**
- ↙     ↓     ↘
**[LMDB] [PostgreSQL] [DNS DB]**

##### Important Elements

- Command interface connections (commands/*)
- Environment configuration flow (modules/env/env.go)
- Logging system integration (modules/logging/logging.go)
- Service discovery and management
- Database interaction paths

##### Implementation Details

Use these symbols:
- Diamonds: Decision points (security checks, routing)
- Rectangles: Processing components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Traffic
        A[Incoming Traffic]
    end

    subgraph DNS
        DNS["DNS Resolution"]:::dns
    end

    subgraph "Proxy Layer"
        PL["HTTP/HTTPS Handler"]:::proxy
        SSL["SSL Manager"]:::security
        RA["Route Handler"]:::proxy
        PA["Proxy Authentication"]:::security
        RI["Route Information"]:::proxy
    end

    subgraph "Security Layer"
        WAF["WAF Rules Engine"]:::security
        PGP["PGP Authentication"]:::security
        PUB["Public Key Manager"]:::security
        PRV["Private Key Manager"]:::security
        TOK["Token Manager"]:::security
    end

    subgraph "Database Layer"
        DBI["Database Interface"]:::db
        LMDB["LMDB"]:::db
        PSQL["PostgreSQL"]:::db
        DNSDB["DNS Database"]:::db
    end

    subgraph "Service Layer"
        SVC["Core Services"]:::service
        WHOIS["WHOIS Service"]:::service
    end

    subgraph "System Components"
        ENV["Environment Config"]:::system
        LOG["Logging System"]:::system
        BOOT["Boot Configuration"]:::system
    end

    %% Connections
    A --> DNS
    DNS --> PL
    PL <--> SSL
    PL --> RA
    RA --> PA
    RA --> RI
    PA --> WAF
    WAF --> PGP
    PGP --> PUB
    PGP --> PRV
    PGP --> TOK
    
    WAF --> DBI
    DBI --> LMDB
    DBI --> PSQL
    DBI --> DNSDB
    
    WAF --> SVC
    SVC --> WHOIS
    
    %% System connections
    ENV --> PL
    ENV --> WAF
    LOG -.- PL
    LOG -.- WAF
    LOG -.- DBI
    BOOT --> PL
    BOOT --> WAF

    %% Click events
    click PL "https://github.com/Northernside/wiredshield/blob/main/http/https.go"
    click DNS "https://github.com/Northernside/wiredshield/blob/main/dns/dns.go"
    click PA "https://github.com/Northernside/wiredshield/blob/main/http/routes/ProxyAuth.go"
    click PGP "https://github.com/Northernside/wiredshield/tree/main/modules/pgp/"
    click PUB "https://github.com/Northernside/wiredshield/blob/main/modules/pgp/public.go"
    click PRV "https://github.com/Northernside/wiredshield/blob/main/modules/pgp/private.go"
    click TOK "https://github.com/Northernside/wiredshield/blob/main/modules/pgp/token.go"
    click SSL "https://github.com/Northernside/wiredshield/blob/main/commands/libs/ssl.go"
    click DBI "https://github.com/Northernside/wiredshield/tree/main/modules/db/"
    click LMDB "https://github.com/Northernside/wiredshield/blob/main/modules/db/lmdb.go"
    click PSQL "https://github.com/Northernside/wiredshield/blob/main/modules/db/psql.go"
    click DNSDB "https://github.com/Northernside/wiredshield/blob/main/modules/db/dns.go"
    click SVC "https://github.com/Northernside/wiredshield/blob/main/services/services.go"
    click WHOIS "https://github.com/Northernside/wiredshield/blob/main/modules/whois/whois.go"
    click ENV "https://github.com/Northernside/wiredshield/blob/main/modules/env/env.go"
    click LOG "https://github.com/Northernside/wiredshield/blob/main/modules/logging/logging.go"
    click BOOT "https://github.com/Northernside/wiredshield/blob/main/commands/boot.go"
    click RI "https://github.com/Northernside/wiredshield/blob/main/http/routes/Info.go"

    %% Styles
    classDef proxy fill:#3498db,stroke:#2980b9,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef db fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef system fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef dns fill:#9b59b6,stroke:#8e44ad,color:white
```
