# brewpipeline/blog-ui architecture

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

- Interactive diagram: https://gitdiagram.com/brewpipeline/blog-ui
- Repository: https://github.com/brewpipeline/blog-ui

## Overview

##### Project type and purpose
- This is a full-stack web UI (single-page application + partial SSR) written in Rust, using Yew for the client, compiled to WebAssembly, styled with Bootstrap.
- It provides a blog interface: posts, authors, tags, comments, admin panel, plus authentication (Telegram, Yandex, internal), SSR for SEO, and integrations (Telegram notifications, image mirroring).

##### File structure
- Top-level:
- Cargo.toml, build.rs, Trunk.toml → Rust build and Trunk configuration for WASM + SSR.
- index.html, index.css, images/ → static assets.
- src/app.rs + src/lib.rs → application entry points; SSR hooks.
- src/components/, src/pages/ → component-based UI (Yew).
- src/utils/ → reusable helpers (API calls, context, formatting).
- src/bin/blog_ui.rs → optional binary entry (e.g., SSR server).
- CI: .github/workflows/builds.yml, tests.yml.
- README describes features, environment vars, dev and prod build commands.

##### Architecture overview
Main layers and components:
A. Developer & CI/CD
1. Developer machines (Rust + Trunk + Git)
2. GitHub Actions (build + test workflows)
3. Artifacts: WASM bundle, HTML/CSS, static images
B. Deployment & Hosting
1. CDN or static file host for front-end assets
2. SSR service (binary from src/bin or embedded in a server) for server-side rendering of selected routes (posts, authors, tags)
C. Client & Runtime
1. Browser loads index.html + index.css + WASM module
2. Yew-powered front-end executes in WASM, hydrates/controls the DOM
3. Calls to backend API (API_URL) for data (posts, comments, authors, tags, settings)
D. Backend & External Services
1. Blog-server (REST API)
2. Authentication providers (Telegram OAuth, Yandex OAuth)
3. Notification service (Telegram bot for new posts)
4. Images processor service (mirroring, resizing)

##### Detail is key—but keep it focused
- Major service and flow.
- Non-obvious environment variables or build steps (e.g., Trunk SSR).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Environment
    subgraph "Developer Environment" 
        DEV[("Developer Machine\n(Rust + Trunk + Git)")]:::pipeline
        CARGO["Cargo.toml"]:::pipeline
        BUILD_RS["build.rs"]:::pipeline
        TRUNK["Trunk.toml"]:::pipeline
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        GH_BUILD["builds.yml"]:::pipeline
        GH_TEST["tests.yml"]:::pipeline
    end

    %% Build Artifacts
    subgraph "Build Tools & Artifacts"
        ARTIFACTS[("WASM Bundle\nHTML/CSS\nStatic Images")]:::build
    end

    %% Deployment Targets
    subgraph "Deployment & Hosting"
        CDN["CDN / Static Host"]:::hosting
        SSR_HOST["SSR Host\n(Server-Side Rendering)"]:::hosting
    end

    %% Browser Client
    subgraph "Browser Client" 
        BROWSER[("Browser")]:::client
        INDEX_HTML["index.html"]:::hosting
        INDEX_CSS["index.css"]:::hosting
        IMAGES_DIR["images/"]:::hosting
        WASM["WASM Module\n(Yew + Hydration)"]:::client
        APP_RS["src/app.rs"]:::client
        LIB_RS["src/lib.rs"]:::client
    end

    %% UI Codebase
    subgraph "UI Codebase (Yew)" 
        COMPONENTS["src/components/"]:::client
        PAGES["src/pages/"]:::client
        ROUTE["src/route.rs"]:::client
    end

    %% Utils / Data Layer
    subgraph "Data Layer & Helpers" 
        UTILS["src/utils/"]:::client
    end

    %% SSR Service
    SSR_SVC["src/bin/blog_ui.rs\n(SSR Entry Point)"]:::hosting

    %% Backend & External Services
    subgraph "Backend & External Services"
        API["Blog-server API\n(REST)"]:::external
        AUTH_PROVIDERS["Auth Providers\n(Telegram, Yandex)"]:::external
        NOTIF["Notification Service\n(Telegram Bot)"]:::external
        IMG_PROC["Image Processor Service"]:::external
    end

    %% Connections Developer to CI/CD
    DEV -->|"push code"| GH_BUILD
    DEV --> GH_TEST
    CARGO --> GH_BUILD
    BUILD_RS --> GH_BUILD
    TRUNK --> GH_BUILD

    %% CI/CD to Build Artifacts
    GH_BUILD -->|"build"| ARTIFACTS
    GH_TEST -->|"test"| ARTIFACTS

    %% Deploy artifacts
    ARTIFACTS -->|"deploy"| CDN
    ARTIFACTS -->|"deploy"| SSR_HOST

    %% Browser requests
    BROWSER -->|GET index.html| CDN
    BROWSER -->|GET index.css| CDN
    BROWSER -->|GET images| CDN
    BROWSER -->|GET wasm| CDN

    %% Instantiate WASM
    BROWSER -->|loads| WASM
    WASM -->|hydrate| BROWSER

    %% Click events for Browser entry
    click INDEX_HTML "https://github.com/brewpipeline/blog-ui/blob/main/index.html"
    click INDEX_CSS "https://github.com/brewpipeline/blog-ui/blob/main/index.css"
    click IMAGES_DIR "https://github.com/brewpipeline/blog-ui/tree/main/images/"
    click APP_RS "https://github.com/brewpipeline/blog-ui/blob/main/src/app.rs"
    click LIB_RS "https://github.com/brewpipeline/blog-ui/blob/main/src/lib.rs"

    %% UI codebase linkage
    WASM --> COMPONENTS
    WASM --> PAGES
    WASM --> ROUTE

    click COMPONENTS "https://github.com/brewpipeline/blog-ui/tree/main/src/components/"
    click PAGES "https://github.com/brewpipeline/blog-ui/tree/main/src/pages/"
    click ROUTE "https://github.com/brewpipeline/blog-ui/blob/main/src/route.rs"

    %% Data layer
    COMPONENTS --> UTILS
    PAGES --> UTILS

    click UTILS "https://github.com/brewpipeline/blog-ui/tree/main/src/utils/"

    %% SSR service
    SSR_HOST --> SSR_SVC
    SSR_SVC --> API
    click SSR_SVC "https://github.com/brewpipeline/blog-ui/blob/main/src/bin/blog_ui.rs"

    %% Client & SSR call backend
    WASM -->|API calls| API
    SSR_SVC -->|SSR data fetch| API

    %% OAuth flows
    WASM -->|OAuth redirects| AUTH_PROVIDERS
    AUTH_PROVIDERS -->|tokens| API

    %% Notifications
    API -->|new post event| NOTIF

    %% Image processing
    WASM -->|image fetch| IMG_PROC
    API -->|generate image| IMG_PROC

    %% Styles
    classDef pipeline fill:#e0e0e0,stroke:#888,stroke-width:1px,color:#000
    classDef build fill:#f0f0f0,stroke:#555,stroke-width:1px,color:#000
    classDef hosting fill:#cce5ff,stroke:#0069d9,stroke-width:1px,color:#004085
    classDef client fill:#d4edda,stroke:#155724,stroke-width:1px,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:1px,color:#856404
```
