# sillyvan/rust-axum-htmx-example architecture

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

- Interactive diagram: https://gitdiagram.com/sillyvan/rust-axum-htmx-example
- Repository: https://github.com/sillyvan/rust-axum-htmx-example

## Overview

##### Main Components

A. Frontend Layer:
- HTMX-powered client interface
- Static files (HTML, CSS)
- Vite development server
- PicoCSS styling

B. Backend Layer:
- Axum web server
- Authentication system
- Cat management system
- Sailfish template engine
- LibSQL database

**[Client Tier]**
- HTMX Frontend (Port: Vite Dev Server)
- Static Assets
- PicoCSS Styling

**[Server Tier]**
- Axum Web Server
- Handler Layer
- Auth Module (sign_in, sign_up, sign_out)
- Cats Module (CRUD operations)
- Nav Module
- Model Layer
- Cat Entity
- Owner Entity
- Utils Layer
- Token Validation
- Secret Management

**[Data Tier]**
- LibSQL Database

##### Key Interactions to Highlight

- HTMX requests from frontend to backend
- Template rendering flow (Sailfish)
- Authentication flow
- Database operations
- API endpoints for cat management

##### Technical Details

- Environment configuration (.env file)
- Server URL and port configuration
- Template locations and processing
- Static file serving
- Test infrastructure

##### Additional Elements

- Version information for major components
- Development vs production configurations
- API endpoints and their purposes

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Tier"]
        HTMX["HTMX Frontend"]
        Static["Static Assets"]
        CSS["PicoCSS Styling"]
        HTMX --> Static
        HTMX --> CSS
    end

    subgraph Server["Server Tier"]
        direction TB
        Axum["Axum Web Server"]

        subgraph Handlers["Handler Layer"]
            direction TB
            Auth["Authentication Module"]
            Cats["Cats Module"]
            Nav["Navigation Module"]
        end

        subgraph Models["Model Layer"]
            direction TB
            CatEntity["Cat Entity"]
            OwnerEntity["Owner Entity"]
        end

        subgraph Utils["Utils Layer"]
            direction TB
            TokenVal["Token Validation"]
            SecretMgmt["Secret Management"]
        end

        Axum --> Handlers
        Handlers --> Models
        Handlers --> Utils
    end

    subgraph Data["Data Tier"]
        DB[(LibSQL Database)]
    end

    HTMX --> Axum
    Models --> DB
    
    %% Component Mappings
    click HTMX "https://github.com/Sillyvan/rust-axum-htmx-example/tree/main/frontend/"
    click Static "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/frontend/index.html"
    click CSS "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/frontend/src/style.css"
    
    click Auth "https://github.com/Sillyvan/rust-axum-htmx-example/tree/main/src/handler/auth/"
    click Cats "https://github.com/Sillyvan/rust-axum-htmx-example/tree/main/src/handler/cats/"
    click Nav "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/src/handler/nav/mod.rs"
    
    click CatEntity "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/src/model/cat.rs"
    click OwnerEntity "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/src/model/owner.rs"
    
    click TokenVal "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/src/utils/validate_token.rs"
    click SecretMgmt "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/src/utils/get_secret.rs"
    
    click DB "https://github.com/Sillyvan/rust-axum-htmx-example/blob/main/dump.sqlite.sql"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef auth fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef utils fill:#95a5a6,stroke:#7f8c8d,color:white

    class HTMX,Static,CSS frontend
    class Axum,Handlers,Models backend
    class Auth,TokenVal auth
    class DB database
    class Utils,SecretMgmt utils
```
