# therealparmesh/go-htmx-boilerplate architecture

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

- Interactive diagram: https://gitdiagram.com/therealparmesh/go-htmx-boilerplate
- Repository: https://github.com/therealparmesh/go-htmx-boilerplate

## Overview

##### Main Components

a) Frontend Layer:
- HTMX Client (represented by main.js and main.css)
- HTML Templates (main.gohtml)
- How HTMX handles partial page updates

b) Backend Layer:
- Go Web Server (main.go)
- Template Engine (Go's built-in template system)

c) Development Tools:
- Air (hot-reload capability, indicated by .air.toml)
- Bun (JavaScript runtime/package manager)
- Make (build system)

**┌─────────────────────────────────────────────┐**
- Client Browser              │
- ┘
- ↑                    ↓
- HTMX Requests   │

**┌─────────────────────────────────────────────┐**
- Go Web Server                   │
- ┤
- Template Engine                           │
- Route Handlers                            │
- HTMX Response Generation                  │
- ┘
- ↑                    ↑

**┌──────────────────┐  ┌──────────────────────┐**
- Static Assets   │  │   HTML Templates      │
- (CSS/JS)       │  │   (.gohtml)           │
- ┘  └──────────────────────┘

##### Development Environment Flow
**┌─────────────────┐**
- Make         │
- ┬────────┘
- ↓
**┌─────────────────┐    ┌─────────────────┐**
- Air         │←───│    Go Build     │
- ┬────────┘    └─────────────────┘
- ↓
**┌─────────────────┐    ┌─────────────────┐**
- Bun           │←───│  JS/CSS Assets  │
- ┘    └─────────────────┘

##### Key Aspects to Highlight

- HTMX Architecture:
- How HTMX requests flow from client to server
- Partial page update mechanisms
- Server-side HTML generation

- Development Workflow:
- Demonstrate how Air handles hot-reloading
- Bun's role in asset management
- Make's orchestration of the build process

##### Important Notes

- Version information for major components
- Development vs production flow differences
- How the template engine integrates with the main server
- Where static assets are served from

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Browser"]
        HTMX["HTMX Client"]:::frontend
        CSS["Static CSS"]:::frontend
        JS["Static JS"]:::frontend
    end

    subgraph Server
        WebServer["Go Web Server"]:::backend
        TemplateEngine["Template Engine"]:::backend
        Templates["HTML Templates"]:::backend
        RouteHandlers["Route Handlers"]:::backend
    end

    subgraph DevTools
        Make["Make Build System"]:::devtool
        Air["Air Hot-Reload"]:::devtool
        Bun["Bun Package Manager"]:::devtool
    end

    Browser --> |HTMX Requests| WebServer
    WebServer --> |HTML Responses| Browser
    HTMX --> |Partial Updates| WebServer
    WebServer --> |Partial HTML| HTMX
    
    WebServer --> TemplateEngine
    TemplateEngine --> Templates
    RouteHandlers --> WebServer

    Make --> Air
    Air --> WebServer
    Make --> Bun
    Bun --> |Asset Building| CSS
    Bun --> |Asset Building| JS

    %% Click Events
    click WebServer "https://github.com/therealparmesh/go-htmx-boilerplate/blob/master/main.go"
    click Templates "https://github.com/therealparmesh/go-htmx-boilerplate/blob/master/main.gohtml"
    click JS "https://github.com/therealparmesh/go-htmx-boilerplate/blob/master/main.js"
    click CSS "https://github.com/therealparmesh/go-htmx-boilerplate/blob/master/main.css"
    click Air "https://github.com/therealparmesh/go-htmx-boilerplate/blob/master/.air.toml"
    click Make "https://github.com/therealparmesh/go-htmx-boilerplate/tree/master/Makefile"
    click Bun "https://github.com/therealparmesh/go-htmx-boilerplate/blob/master/package.json"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef devtool fill:#f1c40f,stroke:#f39c12,color:black

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        DevTool["Development Tool"]:::devtool
    end
```
