# hirongbao/servicehub architecture

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

- Interactive diagram: https://gitdiagram.com/hirongbao/servicehub
- Repository: https://github.com/hirongbao/servicehub

## Overview

ServiceHub is a Spring Boot service hub exposing administrator APIs and separate file, short-link, and personal-site capabilities. A typical API-client workflow authenticates a Service Token, invokes a capability endpoint, and records usage; administrators also manage tokens and inspect usage. File uploads are validated and deduplicated before COS storage, while short links support redirects and visit analytics. The graph follows README capabilities and sampled service/controller calls; unsampled subsystem wiring is left conservative.

Main entry points: [`servicehub-authhub/src/main/java/com/shirongbao/authhub/service/ServiceTokenService.java`](https://github.com/hirongbao/servicehub/blob/main/servicehub-authhub/src/main/java/com/shirongbao/authhub/service/ServiceTokenService.java) (Token Service), [`servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/controller/HirongbaoHubController.java`](https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/controller/HirongbaoHubController.java) (Public Site API), [`servicehub-linkhub/src/main/java/com/shirongbao/linkhub/service/ShortLinkService.java`](https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/service/ShortLinkService.java) (Short Link Logic), [`servicehub-filehub/src/main/java/com/shirongbao/filehub/controller/PublicFileHubController.java`](https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/controller/PublicFileHubController.java) (File Endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin["Admin and Auth"]
  node_admin_app["Application Entry"]
  node_admin_auth["Admin Auth API"]
  node_token_api["Token API"]
  node_usage_api["Usage API"]
  node_overview_api["Overview API"]
  node_logs_api["Access Logs<br/>[LogController.java]"]
  node_token_service["Token Service"]
  node_token_store[("Token and Usage Data")]
  node_access_store[("Access Log Data<br/>[LogController.java]")]
end

subgraph group_files["FileHub"]
  node_file_api["File Endpoints"]
  node_file_service["File Records"]
  node_file_store[("File Metadata")]
  node_cos_service["COS Storage"]
end

subgraph group_links["LinkHub"]
  node_link_api["Public Link API"]
  node_link_service["Short Link Logic"]
  node_link_store[("Links and Visits")]
  node_redirect_api["Redirect API"]
end

subgraph group_site["Personal Site"]
  node_site_api["Public Site API"]
  node_site_post["Posts and Activity"]
  node_site_profile["Profile and Social"]
  node_site_comments["Comments"]
  node_site_store[("Site Content Data")]
  node_notice["Email Notices<br/>[NoticeService.java]"]
end

node_administrator(("Administrator"))
node_api_client(("API Client"))
node_site_visitor(("Site Visitor"))
node_cos[("Tencent COS")]
node_smtp(("SMTP Service"))

node_administrator -->|"signs in"| node_admin_auth
node_administrator -->|"manages tokens"| node_token_api
node_administrator -->|"reviews usage"| node_usage_api
node_administrator -->|"views overview"| node_overview_api
node_administrator -->|"inspects traffic"| node_logs_api
node_admin_auth -->|"authenticates"| node_token_service
node_token_api -->|"manages"| node_token_service
node_usage_api -->|"queries usage"| node_token_service
node_overview_api -->|"reads counts"| node_token_service
node_token_service -->|"reads and writes"| node_token_store
node_logs_api -->|"queries logs"| node_access_store
node_api_client -->|"uploads files"| node_file_api
node_file_api -->|"validates token"| node_token_service
node_file_api -->|"uploads or deletes"| node_file_service
node_file_service -->|"reads and writes"| node_file_store
node_file_service -->|"stores objects"| node_cos_service
node_cos_service -->|"uploads and deletes"| node_cos
node_api_client -->|"creates links"| node_link_api
node_link_api -->|"validates and logs"| node_token_service
node_link_api -->|"creates or queries"| node_link_service
node_link_service -->|"reads and writes"| node_link_store
node_site_visitor -->|"requests content"| node_site_api
node_site_api -->|"queries posts"| node_site_post
node_site_api -->|"queries profile"| node_site_profile
node_site_api -->|"handles comments"| node_site_comments
node_site_post -->|"reads and writes"| node_site_store
node_site_profile -->|"reads profile data"| node_site_store
node_site_comments -->|"reads and writes"| node_site_store
node_site_comments -.->|"sends notification"| node_notice
node_notice -.->|"sends email"| node_smtp
node_site_visitor -->|"follows short link"| node_redirect_api
node_redirect_api -->|"resolves code"| node_link_service
node_link_service -->|"records visits"| node_link_store

click node_admin_app "https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/ServiceHubApplication.java"
click node_admin_auth "https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/AdminController.java"
click node_token_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/TokenController.java"
click node_usage_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/UsageController.java"
click node_overview_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/OverviewController.java"
click node_logs_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/LogController.java"
click node_token_service "https://github.com/hirongbao/servicehub/blob/main/servicehub-authhub/src/main/java/com/shirongbao/authhub/service/ServiceTokenService.java"
click node_token_store "https://github.com/hirongbao/servicehub/blob/main/servicehub-authhub/src/main/java/com/shirongbao/authhub/mapper/ServiceTokenMapper.java"
click node_access_store "https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/LogController.java"
click node_file_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/controller/PublicFileHubController.java"
click node_file_service "https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/service/FileRecordService.java"
click node_file_store "https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/mapper/FileRecordMapper.java"
click node_cos_service "https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/service/CosStorageService.java"
click node_link_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/controller/PublicLinkController.java"
click node_link_service "https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/service/ShortLinkService.java"
click node_link_store "https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/mapper/ShortLinkMapper.java"
click node_redirect_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/controller/RedirectController.java"
click node_site_api "https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/controller/HirongbaoHubController.java"
click node_site_post "https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SitePostService.java"
click node_site_profile "https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SiteProfileService.java"
click node_site_comments "https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SiteCommentService.java"
click node_site_store "https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/mapper/SitePostMapper.java"
click node_notice "https://github.com/hirongbao/servicehub/blob/main/servicehub-noticehub/src/main/java/com/shirongbao/noticehub/service/NoticeService.java"

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_admin_app,node_admin_auth,node_token_api,node_usage_api,node_overview_api,node_logs_api,node_token_service,node_token_store,node_access_store,node_api_client toneBlue
class node_file_api,node_file_service,node_file_store,node_cos_service,node_cos toneAmber
class node_link_api,node_link_service,node_link_store,node_redirect_api toneMint
class node_site_api,node_site_post,node_site_profile,node_site_comments,node_site_store,node_notice toneRose
class node_administrator,node_site_visitor,node_smtp toneIndigo
```

## Components

### Admin and Auth

- [Application Entry](https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/ServiceHubApplication.java): `servicehub-admin/src/main/java/com/shirongbao/admin/ServiceHubApplication.java`
- [Admin Auth API](https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/AdminController.java): `servicehub-admin/src/main/java/com/shirongbao/admin/controller/AdminController.java`
- [Token API](https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/TokenController.java): `servicehub-admin/src/main/java/com/shirongbao/admin/controller/TokenController.java`
- [Usage API](https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/UsageController.java): `servicehub-admin/src/main/java/com/shirongbao/admin/controller/UsageController.java`
- [Overview API](https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/OverviewController.java): `servicehub-admin/src/main/java/com/shirongbao/admin/controller/OverviewController.java`
- [Access Logs](https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/LogController.java): `servicehub-admin/src/main/java/com/shirongbao/admin/controller/LogController.java`
- [Token Service](https://github.com/hirongbao/servicehub/blob/main/servicehub-authhub/src/main/java/com/shirongbao/authhub/service/ServiceTokenService.java): `servicehub-authhub/src/main/java/com/shirongbao/authhub/service/ServiceTokenService.java`
- [Token and Usage Data](https://github.com/hirongbao/servicehub/blob/main/servicehub-authhub/src/main/java/com/shirongbao/authhub/mapper/ServiceTokenMapper.java): `servicehub-authhub/src/main/java/com/shirongbao/authhub/mapper/ServiceTokenMapper.java`
- [Access Log Data](https://github.com/hirongbao/servicehub/blob/main/servicehub-admin/src/main/java/com/shirongbao/admin/controller/LogController.java): `servicehub-admin/src/main/java/com/shirongbao/admin/controller/LogController.java`

### FileHub

- [File Endpoints](https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/controller/PublicFileHubController.java): `servicehub-filehub/src/main/java/com/shirongbao/filehub/controller/PublicFileHubController.java`
- [File Records](https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/service/FileRecordService.java): `servicehub-filehub/src/main/java/com/shirongbao/filehub/service/FileRecordService.java`
- [File Metadata](https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/mapper/FileRecordMapper.java): `servicehub-filehub/src/main/java/com/shirongbao/filehub/mapper/FileRecordMapper.java`
- [COS Storage](https://github.com/hirongbao/servicehub/blob/main/servicehub-filehub/src/main/java/com/shirongbao/filehub/service/CosStorageService.java): `servicehub-filehub/src/main/java/com/shirongbao/filehub/service/CosStorageService.java`

### LinkHub

- [Public Link API](https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/controller/PublicLinkController.java): `servicehub-linkhub/src/main/java/com/shirongbao/linkhub/controller/PublicLinkController.java`
- [Short Link Logic](https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/service/ShortLinkService.java): `servicehub-linkhub/src/main/java/com/shirongbao/linkhub/service/ShortLinkService.java`
- [Links and Visits](https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/mapper/ShortLinkMapper.java): `servicehub-linkhub/src/main/java/com/shirongbao/linkhub/mapper/ShortLinkMapper.java`
- [Redirect API](https://github.com/hirongbao/servicehub/blob/main/servicehub-linkhub/src/main/java/com/shirongbao/linkhub/controller/RedirectController.java): `servicehub-linkhub/src/main/java/com/shirongbao/linkhub/controller/RedirectController.java`

### Personal Site

- [Public Site API](https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/controller/HirongbaoHubController.java): `servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/controller/HirongbaoHubController.java`
- [Posts and Activity](https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SitePostService.java): `servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SitePostService.java`
- [Profile and Social](https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SiteProfileService.java): `servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SiteProfileService.java`
- [Comments](https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SiteCommentService.java): `servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/service/SiteCommentService.java`
- [Site Content Data](https://github.com/hirongbao/servicehub/blob/main/servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/mapper/SitePostMapper.java): `servicehub-hirongbaohub/src/main/java/com/shirongbao/hirongbaohub/mapper/SitePostMapper.java`
- [Email Notices](https://github.com/hirongbao/servicehub/blob/main/servicehub-noticehub/src/main/java/com/shirongbao/noticehub/service/NoticeService.java): `servicehub-noticehub/src/main/java/com/shirongbao/noticehub/service/NoticeService.java`

### Other components

- **Administrator**
- **API Client**
- **Site Visitor**
- **Tencent COS**
- **SMTP Service**

## Connections

- Administrator → Admin Auth API: signs in
- Administrator → Token API: manages tokens
- Administrator → Usage API: reviews usage
- Administrator → Overview API: views overview
- Administrator → Access Logs: inspects traffic
- Admin Auth API → Token Service: authenticates
- Token API → Token Service: manages
- Usage API → Token Service: queries usage
- Overview API → Token Service: reads counts
- Token Service → Token and Usage Data: reads and writes
- Access Logs → Access Log Data: queries logs
- API Client → File Endpoints: uploads files
- File Endpoints → Token Service: validates token
- File Endpoints → File Records: uploads or deletes
- File Records → File Metadata: reads and writes
- File Records → COS Storage: stores objects
- COS Storage → Tencent COS: uploads and deletes
- API Client → Public Link API: creates links
- Public Link API → Token Service: validates and logs
- Public Link API → Short Link Logic: creates or queries
- Short Link Logic → Links and Visits: reads and writes
- Site Visitor → Public Site API: requests content
- Public Site API → Posts and Activity: queries posts
- Public Site API → Profile and Social: queries profile
- Public Site API → Comments: handles comments
- Posts and Activity → Site Content Data: reads and writes
- Profile and Social → Site Content Data: reads profile data
- Comments → Site Content Data: reads and writes
- Comments → Email Notices: sends notification
- Email Notices → SMTP Service: sends email
- Site Visitor → Redirect API: follows short link
- Redirect API → Short Link Logic: resolves code
- Short Link Logic → Links and Visits: records visits
