# scc749/go_blog architecture

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

- Interactive diagram: https://gitdiagram.com/scc749/go_blog
- Repository: https://github.com/scc749/go_blog

## Overview

##### Project type and purpose
- This is a full-stack personal blog application (“go_blog”), with a Go/Gin-based RESTful backend and a Vue3 frontend.
- It supports CRUD blog posts, serves static assets (images, emojis), and integrates with MySQL for relational data, Elasticsearch for full-text search, and Redis for caching or session data.

##### File structure
- Top-level directories:
- server: Go code, configuration (config.yaml), initialization commands, main.go entrypoint.
- web: Vue3 source, build scripts, dist folder for production assets.
- Root files: README.md (setup & deployment), LICENSE, .gitmodules (if submodules exist).
- No microservices subfolders: the backend is a single monolith.
- Deployment artifacts: Docker containers for MySQL, Elasticsearch, Redis; compiled Go binary; built Vue “dist” directory; Nginx and Supervisor configurations.

##### README for additional insights
- Technology stack: Go 1.23, Gin framework, Vue3+Vite, MySQL, Elasticsearch 8.x, Redis, Docker, Nginx, Supervisor.
- Development workflow:
- Local Docker containers for DB/ES/Redis
- go run main.go with flags to initialize DB, ES and admin user
- npm run dev for frontend
- Production deploy:
- Compile Go binary (GOOS=linux)
- Build Vue “dist”
- Host structure under /opt/go_blog
- Containers configured with bind mounts for persistent data
- Nginx as SSL-terminating reverse proxy and static file server
- Supervisor to manage the Go process

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend Layer"
        Browser["Browser (Vue3 SPA)"]:::frontend
    end

    subgraph "Server Host"
        Supervisor["Supervisor (Process Manager)"]:::tool
        Gin["Gin HTTP Server"]:::backend
        Config["Config (config.yaml)"]:::config
        Handlers["REST API Routes & Controllers"]:::backend
        Service["Business Logic Layer"]:::backend
        Repo["Data Access Layer & Persistence"]:::backend
        FileStorage["Static File Storage"]:::storage
    end

    subgraph "Container Platform"
        Docker["Docker Engine"]:::tool
        MySQL["MySQL Container"]:::database
        ES["Elasticsearch Container"]:::database
        Redis["Redis Container"]:::database
    end

    subgraph "Documentation"
        README["README.md"]:::doc
        License["LICENSE"]:::doc
    end

    %% Connections
    Browser -->|HTTP/HTTPS| Nginx["Nginx (SSL Termination,<br/>Static & Proxy)"]:::proxy
    Nginx -->|serve SPA/static| Browser
    Nginx -->|proxy /api| Gin
    Supervisor -->|monitors| Gin
    Gin -->|reads config| Config
    Gin -->|routes requests| Handlers
    Handlers -->|business logic| Service
    Service -->|data operations| Repo
    Repo -->|SQL queries| MySQL
    Repo -->|Index/Search| ES
    Repo -->|Cache/Session| Redis
    Gin -->|uploads/downloads| FileStorage
    Docker -->|hosts| MySQL
    Docker -->|hosts| ES
    Docker -->|hosts| Redis

    %% Click Events
    click Browser "https://github.com/scc749/go_blog/tree/main/web/src"
    click Gin "https://github.com/scc749/go_blog/blob/main/server/main.go"
    click Config "https://github.com/scc749/go_blog/blob/main/server/config.yaml"
    click Handlers "https://github.com/scc749/go_blog/tree/main/server/internal/handlers"
    click Service "https://github.com/scc749/go_blog/tree/main/server/internal/service"
    click Repo "https://github.com/scc749/go_blog/tree/main/server/internal/repository"
    click FileStorage "https://github.com/scc749/go_blog/tree/main/server/static"
    click README "https://github.com/scc749/go_blog/blob/main/README.md"
    click License "https://github.com/scc749/go_blog/tree/main/LICENSE"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB
    classDef proxy fill:#D5F5E3,stroke:#27AE60
    classDef backend fill:#FCF3CF,stroke:#F1C40F
    classDef database fill:#FADBD8,stroke:#C0392B
    classDef storage fill:#E8DAEF,stroke:#8E44AD
    classDef tool fill:#E5E8E8,stroke:#566573
    classDef config fill:#FDEDEC,stroke:#922B21
    classDef doc fill:#EBF5FB,stroke:#2E86C1
```
