# james58899/hath-rust architecture

> Architecture diagram of the GitHub repository james58899/hath-rust, 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/james58899/hath-rust
- Repository: https://github.com/james58899/hath-rust

## Overview

##### Main Components

A. Core Service Components:
- Cache Manager (from cache_manager.rs)
- Gallery Downloader (from gallery_downloader.rs)
- RPC Client (from rpc.rs)
- Server Component (from server/mod.rs)
- SSL Handler (from server/ssl.rs)

B. Middleware Layer:
- Connection Counter
- Logger
- Error Handler

C. Route Handlers:
- Cache Routes
- Server Command Routes
- Speed Test Routes

**[External Clients/Browsers] ←→ [SSL Handler]**
- ↓
**[Server Component]**
- ↓
**[Middleware Layer]**
- ↓
**[Route Handlers] ←→ [Cache Manager] ←→ [Local Storage]**
- ↓
**[RPC Client] ←→ [Main H@H Server]**

##### Important Relationships to Highlight

a. Data Flow:
- Client requests → SSL Handler → Server → Middleware → Routes
- Cache Manager ←→ Local Storage
- RPC Client ←→ External H@H Server

b. Component Interactions:
- How the Cache Manager interfaces with both Route Handlers and Storage
- Gallery Downloader's connection to the Cache Manager
- Middleware chain order (Connection Counter → Logger)

##### Technical Details

- Async boundaries
- Error propagation paths
- Where logging occurs
- Cache size management flow

##### Notes for Implementation

- Keep the main service flow clear and centered
- Related components visually
- Use standardized symbols for databases, services, and external systems
- Version/platform support information in a separate section

- Low memory usage architecture
- Parallel processing capabilities
- Certificate management
- Cache management
- Speed testing functionality

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External
        Clients([External Clients/Browsers])
        MainServer([Main H@H Server])
    end

    subgraph ServerLayer
        SSL[SSL Handler]:::security
        Server[Server Component]:::core
    end

    subgraph MiddlewareLayer
        ConnCounter[Connection Counter]:::middleware
        Logger[Logger]:::middleware
        ErrorHandler[Error Handler]:::middleware
    end

    subgraph RouteHandlers
        CacheRoutes[Cache Routes]:::route
        CommandRoutes[Server Command Routes]:::route
        SpeedRoutes[Speed Test Routes]:::route
    end

    subgraph CoreComponents
        CacheManager[Cache Manager]:::core
        GalleryDownloader[Gallery Downloader]:::core
        RPCClient[RPC Client]:::core
        Storage[(Local Storage)]:::storage
    end

    %% Main Flow
    Clients <--> SSL
    SSL --> Server
    Server --> ConnCounter
    ConnCounter --> Logger
    Logger --> ErrorHandler
    ErrorHandler --> RouteHandlers

    %% Route Handlers to Core Components
    CacheRoutes <--> CacheManager
    CommandRoutes <--> CacheManager
    SpeedRoutes <--> CacheManager
    
    %% Core Component Interactions
    CacheManager <--> Storage
    GalleryDownloader <--> CacheManager
    RPCClient <--> MainServer
    
    %% Styling
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef security fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef middleware fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef route fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:2px
    
    %% Click Events
    click CacheManager "https://github.com/james58899/hath-rust/blob/main/src/cache_manager.rs"
    click GalleryDownloader "https://github.com/james58899/hath-rust/blob/main/src/gallery_downloader.rs"
    click RPCClient "https://github.com/james58899/hath-rust/blob/main/src/rpc.rs"
    click Server "https://github.com/james58899/hath-rust/blob/main/src/server/mod.rs"
    click SSL "https://github.com/james58899/hath-rust/blob/main/src/server/ssl.rs"
    click ConnCounter "https://github.com/james58899/hath-rust/blob/main/src/middleware/connection_counter.rs"
    click Logger "https://github.com/james58899/hath-rust/blob/main/src/middleware/logger.rs"
    click ErrorHandler "https://github.com/james58899/hath-rust/blob/main/src/error.rs"
    click CacheRoutes "https://github.com/james58899/hath-rust/blob/main/src/route/cache.rs"
    click CommandRoutes "https://github.com/james58899/hath-rust/blob/main/src/route/server_command.rs"
    click SpeedRoutes "https://github.com/james58899/hath-rust/blob/main/src/route/speed_test.rs"

    %% Legend
    subgraph Legend
        L1[Core Component]:::core
        L2[Security Component]:::security
        L3[Middleware Component]:::middleware
        L4[Route Handler]:::route
        L5[(Storage)]:::storage
    end
```
