# go-fuego/fuego architecture

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

- Interactive diagram: https://gitdiagram.com/go-fuego/fuego
- Repository: https://github.com/go-fuego/fuego

## Overview

##### Main Components

a. Core Components:
- Router/Engine (based on net/http)
- Context Handler System
- Middleware Pipeline
- OpenAPI Generator
- Serialization/Deserialization Engine
- Validation System
- Error Handler
- Template Renderer

b. External Interfaces:
- HTTP Server Interface
- Client Applications
- Database Connections (when used)
- Template Engines (html/template, templ, gomponents)

**┌─────────────────────────────────────────────────────────┐**
- Client Layer                          │
- (HTTP Clients, Web Browsers, API Consumers)            │
- ┘
- ↕ HTTP
**┌─────────────────────────────────────────────────────────┐**
- Server Layer                          │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- Router    │→ │  Middleware │→ │   Context   │     │
- ┘  └─────────────┘  └─────────────┘     │
- ↓             ↓                ↓              │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- Validator  │  │ Serializer  │  │   Handler   │     │
- ┘  └─────────────┘  └─────────────┘     │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Support Systems                         │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- OpenAPI   │  │   Error     │  │  Template   │     │
- Generator  │  │   Handler   │  │  Renderer   │     │
- ┘  └─────────────┘  └─────────────┘     │
- ┘

##### Component Details

For each major component, include:
- Input/Output interfaces
- Key responsibilities
- Integration points
- Configuration options

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        C1["HTTP Clients"]
        C2["Web Browsers"]
        C3["API Consumers"]
    end

    subgraph Server["Server Layer"]
        direction TB
        R["Router/Engine"]:::core
        M["Middleware Pipeline"]:::middleware
        CH["Context Handler"]:::core
        V["Validator"]:::processing
        S["Serializer"]:::processing
        H["Handler"]:::processing
        
        R --> M
        M --> CH
        CH --> V
        CH --> S
        CH --> H
    end

    subgraph Support["Support Systems"]
        direction TB
        OA["OpenAPI Generator"]:::support
        EH["Error Handler"]:::support
        TR["Template Renderer"]:::support
        PM["Performance Monitor"]:::support
        SEC["Security"]:::support
    end

    Client --> |HTTP Request| Server
    Server --> |HTTP Response| Client
    Server --> Support
    Support --> Server

    %% Component mappings with click events
    click R "https://github.com/go-fuego/fuego/blob/main/engine.go"
    click M "https://github.com/go-fuego/fuego/tree/main/middleware/"
    click CH "https://github.com/go-fuego/fuego/blob/main/ctx.go"
    click V "https://github.com/go-fuego/fuego/blob/main/validation.go"
    click S "https://github.com/go-fuego/fuego/blob/main/serialization.go"
    click OA "https://github.com/go-fuego/fuego/blob/main/openapi.go"
    click EH "https://github.com/go-fuego/fuego/blob/main/errors.go"
    click TR "https://github.com/go-fuego/fuego/blob/main/html.go"
    click PM "https://github.com/go-fuego/fuego/blob/main/perf.go"
    click SEC "https://github.com/go-fuego/fuego/blob/main/security.go"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef middleware fill:#2ecc71,stroke:#27ae60,color:white
    classDef processing fill:#e67e22,stroke:#d35400,color:white
    classDef support fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        direction TB
        L1["Core Components"]:::core
        L2["Middleware"]:::middleware
        L3["Processing"]:::processing
        L4["Support Systems"]:::support
        L5["External Systems"]:::external
    end
```
