# koioio/myblog architecture

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

- Interactive diagram: https://gitdiagram.com/koioio/myblog
- Repository: https://github.com/koioio/myblog

## Overview

MyBlog-ES is a Go/Gin and Vue 3 blogging system. A visitor or administrator uses the web UI, whose API modules communicate with the server; the server routes requests through authentication/authorization middleware to API handlers and business services. Services manage blog content, users, comments, and site features, using MySQL for relational data, Elasticsearch for article search, and Redis for cached/session-related state. Other documented capabilities include image storage, third-party login, weather, hot searches, and scheduled work. The README describes these capabilities; some subsystem links below reflect its documentation rather than sampled implementation.

Main entry points: [`server/api`](https://github.com/koioio/myblog/tree/main/server/api) (API handlers), [`server/service/user.go`](https://github.com/koioio/myblog/blob/main/server/service/user.go) (User and auth), [`server/router`](https://github.com/koioio/myblog/tree/main/server/router) (Domain routes), [`server/service/article.go`](https://github.com/koioio/myblog/blob/main/server/service/article.go) (Content services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Vue application<br/>[main.ts]"]
  node_webviews["Web and dashboard"]
  node_webapi["API clients"]
end

subgraph group_server["Server request flow"]
  node_serverentry["Server startup<br/>[main.go]"]
  node_routes["Route registration<br/>[router.go]"]
  node_routermodules["Domain routes"]
  node_middleware["Auth and logging"]
  node_handlers["API handlers"]
end

subgraph group_content["Blog capabilities"]
  node_contentservices["Content services<br/>[article.go]"]
  node_userservice["User and auth<br/>[user.go]"]
  node_comments["Comments and feedback<br/>[comment.go]"]
  node_images["Image management<br/>[image.go]"]
  node_sitefeatures["Site features<br/>[website.go]"]
end

subgraph group_state["Data and storage"]
  node_mysql[("MySQL")]
  node_es[("Elasticsearch")]
  node_redis[("Redis")]
  node_upload["Image storage<br/>[upload.go]"]
end

subgraph group_integrations["Integrations and tasks"]
  node_hotservice["Hot search service<br/>[hot_search.go]"]
  node_hottask["Hot search task<br/>[hot_search.go]"]
  node_hotsources["Hot search sources<br/>[hot_search.go]"]
  node_gaode["Weather integration<br/>[gaode.go]"]
  node_qq["QQ login integration<br/>[qq.go]"]
  node_email["Email utility<br/>[email.go]"]
  node_scheduler["Scheduled jobs<br/>[corn.go]"]
end

node_visitor(("Visitor"))
node_administrator(("Administrator"))

node_visitor -->|"uses"| node_webapp
node_administrator -->|"manages"| node_webapp
node_webapp -->|"renders"| node_webviews
node_webviews -->|"requests"| node_webapi
node_webapi -->|"sends HTTP"| node_routermodules
node_serverentry -->|"starts"| node_routes
node_routes -->|"registers"| node_routermodules
node_routermodules -->|"applies"| node_middleware
node_routermodules -->|"dispatches"| node_handlers
node_handlers -->|"calls"| node_contentservices
node_handlers -->|"calls"| node_userservice
node_handlers -->|"calls"| node_comments
node_handlers -->|"calls"| node_images
node_handlers -->|"calls"| node_sitefeatures
node_contentservices -->|"reads and writes"| node_mysql
node_contentservices -->|"searches"| node_es
node_userservice -->|"reads and writes"| node_mysql
node_userservice -->|"uses"| node_redis
node_comments -->|"reads and writes"| node_mysql
node_images -->|"reads and writes"| node_mysql
node_images -->|"stores files"| node_upload
node_hotservice -->|"reads and writes"| node_redis
node_hotservice -->|"fetches on miss"| node_hotsources
node_hottask -->|"fetches"| node_hotsources
node_hottask -->|"writes cache"| node_redis
node_scheduler -->|"schedules"| node_hottask
node_sitefeatures -.->|"uses"| node_gaode
node_userservice -.->|"uses"| node_qq
node_userservice -.->|"uses"| node_email

click node_webapp "https://github.com/koioio/myblog/blob/main/web/src/main.ts"
click node_webviews "https://github.com/koioio/myblog/tree/main/web/src/views"
click node_webapi "https://github.com/koioio/myblog/tree/main/web/src/api"
click node_serverentry "https://github.com/koioio/myblog/blob/main/server/main.go"
click node_routes "https://github.com/koioio/myblog/blob/main/server/initialize/router.go"
click node_routermodules "https://github.com/koioio/myblog/tree/main/server/router"
click node_middleware "https://github.com/koioio/myblog/tree/main/server/middleware"
click node_handlers "https://github.com/koioio/myblog/tree/main/server/api"
click node_contentservices "https://github.com/koioio/myblog/blob/main/server/service/article.go"
click node_userservice "https://github.com/koioio/myblog/blob/main/server/service/user.go"
click node_comments "https://github.com/koioio/myblog/blob/main/server/service/comment.go"
click node_images "https://github.com/koioio/myblog/blob/main/server/service/image.go"
click node_sitefeatures "https://github.com/koioio/myblog/blob/main/server/service/website.go"
click node_upload "https://github.com/koioio/myblog/blob/main/server/utils/upload/upload.go"
click node_hotservice "https://github.com/koioio/myblog/blob/main/server/service/hot_search.go"
click node_hottask "https://github.com/koioio/myblog/blob/main/server/task/hot_search.go"
click node_hotsources "https://github.com/koioio/myblog/blob/main/server/utils/hotSearch/hot_search.go"
click node_gaode "https://github.com/koioio/myblog/blob/main/server/service/gaode.go"
click node_qq "https://github.com/koioio/myblog/blob/main/server/service/qq.go"
click node_email "https://github.com/koioio/myblog/blob/main/server/utils/email.go"
click node_scheduler "https://github.com/koioio/myblog/blob/main/server/initialize/corn.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_webviews,node_webapi toneBlue
class node_serverentry,node_routes,node_routermodules,node_middleware,node_handlers toneAmber
class node_contentservices,node_userservice,node_comments,node_images,node_sitefeatures toneMint
class node_mysql,node_es,node_redis,node_upload toneRose
class node_hotservice,node_hottask,node_hotsources,node_gaode,node_qq,node_email,node_scheduler,node_visitor,node_administrator toneIndigo
```

## Components

### Web application

- [Vue application](https://github.com/koioio/myblog/blob/main/web/src/main.ts): `web/src/main.ts`
- [Web and dashboard](https://github.com/koioio/myblog/tree/main/web/src/views): `web/src/views`
- [API clients](https://github.com/koioio/myblog/tree/main/web/src/api): `web/src/api`

### Server request flow

- [Server startup](https://github.com/koioio/myblog/blob/main/server/main.go): `server/main.go`
- [Route registration](https://github.com/koioio/myblog/blob/main/server/initialize/router.go): `server/initialize/router.go`
- [Domain routes](https://github.com/koioio/myblog/tree/main/server/router): `server/router`
- [Auth and logging](https://github.com/koioio/myblog/tree/main/server/middleware): `server/middleware`
- [API handlers](https://github.com/koioio/myblog/tree/main/server/api): `server/api`

### Blog capabilities

- [Content services](https://github.com/koioio/myblog/blob/main/server/service/article.go): `server/service/article.go`
- [User and auth](https://github.com/koioio/myblog/blob/main/server/service/user.go): `server/service/user.go`
- [Comments and feedback](https://github.com/koioio/myblog/blob/main/server/service/comment.go): `server/service/comment.go`
- [Image management](https://github.com/koioio/myblog/blob/main/server/service/image.go): `server/service/image.go`
- [Site features](https://github.com/koioio/myblog/blob/main/server/service/website.go): `server/service/website.go`

### Data and storage

- **MySQL**
- **Elasticsearch**
- **Redis**
- [Image storage](https://github.com/koioio/myblog/blob/main/server/utils/upload/upload.go): `server/utils/upload/upload.go`

### Integrations and tasks

- [Hot search service](https://github.com/koioio/myblog/blob/main/server/service/hot_search.go): `server/service/hot_search.go`
- [Hot search task](https://github.com/koioio/myblog/blob/main/server/task/hot_search.go): `server/task/hot_search.go`
- [Hot search sources](https://github.com/koioio/myblog/blob/main/server/utils/hotSearch/hot_search.go): `server/utils/hotSearch/hot_search.go`
- [Weather integration](https://github.com/koioio/myblog/blob/main/server/service/gaode.go): `server/service/gaode.go`
- [QQ login integration](https://github.com/koioio/myblog/blob/main/server/service/qq.go): `server/service/qq.go`
- [Email utility](https://github.com/koioio/myblog/blob/main/server/utils/email.go): `server/utils/email.go`
- [Scheduled jobs](https://github.com/koioio/myblog/blob/main/server/initialize/corn.go): `server/initialize/corn.go`

### Other components

- **Visitor**
- **Administrator**

## Connections

- Visitor → Vue application: uses
- Administrator → Vue application: manages
- Vue application → Web and dashboard: renders
- Web and dashboard → API clients: requests
- API clients → Domain routes: sends HTTP
- Server startup → Route registration: starts
- Route registration → Domain routes: registers
- Domain routes → Auth and logging: applies
- Domain routes → API handlers: dispatches
- API handlers → Content services: calls
- API handlers → User and auth: calls
- API handlers → Comments and feedback: calls
- API handlers → Image management: calls
- API handlers → Site features: calls
- Content services → MySQL: reads and writes
- Content services → Elasticsearch: searches
- User and auth → MySQL: reads and writes
- User and auth → Redis: uses
- Comments and feedback → MySQL: reads and writes
- Image management → MySQL: reads and writes
- Image management → Image storage: stores files
- Hot search service → Redis: reads and writes
- Hot search service → Hot search sources: fetches on miss
- Hot search task → Hot search sources: fetches
- Hot search task → Redis: writes cache
- Scheduled jobs → Hot search task: schedules
- Site features → Weather integration: uses
- User and auth → QQ login integration: uses
- User and auth → Email utility: uses
