# iflytek/skillhub architecture

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

- Interactive diagram: https://gitdiagram.com/iflytek/skillhub
- Repository: https://github.com/iflytek/skillhub

## Overview

1. **Overall shape**
   SkillHub is a self-hosted skill registry with three user-facing entry points: a React web UI, REST/CLI-compatible APIs, and deployment/runtime scripts. The core product is implemented in a Java 21 / Spring Boot backend, with a separate TypeScript frontend and several backend support modules.

2. **Frontend boundary**
   The `web/` app is a React 19 + TypeScript SPA built with Vite. It uses TanStack Router and TanStack Query for navigation and server-state, i18next for localization, and generated OpenAPI types for API calls. The frontend is organized by feature areas such as auth, skills, namespaces, governance, review, notifications, search, admin, and settings.

3. **Backend module layout**
   The `server/` tree is a multi-module Maven system. The important modules are:
   - `skillhub-app`: Spring Boot application, controllers, orchestration services, filters, tasks, and wiring
   - `skillhub-domain`: business domain model and domain services
   - `skillhub-auth`: authentication, RBAC, tokens, OAuth, local auth, and account merge
   - `skillhub-search`: search indexing and query services
   - `skillhub-storage`: local filesystem and S3/MinIO storage abstractions
   - `skillhub-infra`: JPA repositories, HTTP client adapters, scanner integration
   - `skillhub-notification`: notification persistence, dispatch, and SSE delivery

4. **Layering and dependency direction**
   The architecture is intentionally layered. Controllers live in `skillhub-app` and call application services, which in turn depend on domain services and repositories. Persistence, HTTP clients, storage, and scanner integrations are pushed into `skillhub-infra` or other support modules so the domain layer stays relatively independent.

5. **Core domain boundaries**
   The domain model centers on skills, versions, files, labels, tags, namespaces, users, reviews, promotions, reports, social signals, audits, and governance notifications. Each area has its own entities, repositories, and services. This makes the diagram naturally split into bounded contexts rather than one large CRUD backend.

6. **Main business flows**
   The primary lifecycle is: a user publishes a skill package, the backend validates and stores it, then creates versions and searchable documents. Later, other users discover it via search, install/download it, star/rate it, or report it. Namespace and review workflows gate promotion from team scope to broader visibility.

7. **Authentication and authorization**
   Auth is handled by `skillhub-auth` and exposed through app controllers for OAuth login, local login, device auth, API tokens, password reset, and account merge. Security is policy-driven: routes can be open, provider-restricted, email-domain-restricted, or subject-whitelisted. RBAC and session/token validation are central cross-cutting boundaries.

8. **Search subsystem**
   Search is a distinct subsystem with its own query/index/rebuild services and event listener integration. It supports full-text search and visibility-aware filtering. The backend maintains search documents and rebuilds indexes from domain events and persisted skill data, rather than relying on the UI or an external search engine.

9. **Storage and package handling**
   Skill packages and related files are stored through an abstraction that can target local disk for development or S3-compatible object storage in production. Package upload uses archive extraction and validation steps before persistence. Deletion has compensating tasks, which suggests the storage lifecycle is asynchronous and failure-tolerant.

10. **Notifications and async events**
   The notification module stores notification state, user preferences, and serves realtime updates through SSE. Domain events such as ratings, stars, promotions, reviews, and governance actions feed listeners that create notifications or trigger follow-up processing. This is one of the main asynchronous paths in the system.

11. **Operational and runtime infrastructure**
   The repository includes Docker Compose, Kubernetes manifests, and release/runtime templates, so the deployment model is multi-target: local dev, compose-based runtime, and Kubernetes. PostgreSQL is the main system of record, Redis backs sessions/rate limiting/streams, and Prometheus scraping is wired through Actuator metrics. A scanner service is also part of the runtime for security analysis of skill packages.

12. **API and compatibility surface**
   The backend exposes native REST APIs for the web app and CLI, plus a compatibility layer for ClawHub-style clients. OpenAPI contracts are checked in and used to keep the frontend types aligned with the backend. That means the API boundary is a first-class contract, not just an internal implementation detail.

13. **Automation and repository operations**
   GitHub Actions workflows cover release notes, docs deployment, issue triage, reward automation, image publishing, and PR test/e2e pipelines. These workflows are not part of the runtime architecture, but they strongly shape how the product is validated, released, and documented.

14. **What to draw as the main boxes**
   For an architecture diagram, the key boxes are: Web UI, Backend API Gateway/Controllers, Application Services, Domain Model, Auth Module, Search Module, Notification Module, Storage Adapter, PostgreSQL, Redis, and Object Storage. The main arrows are: user/API traffic into controllers, domain events into search/notifications, and persistence/infrastructure dependencies from services into databases and storage.

Main entry points: [`server/skillhub-app`](https://github.com/iflytek/skillhub/tree/main/server/skillhub-app) (API app), [`server/skillhub-app/src/main/resources/db/migration`](https://github.com/iflytek/skillhub/tree/main/server/skillhub-app/src/main/resources/db/migration) (PostgreSQL), [`server/skillhub-domain`](https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain) (Domain model), [`web`](https://github.com/iflytek/skillhub/tree/main/web) (Web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web UI"]
  node_web["Web UI<br/>React SPA"]
  node_web_features["Feature apps<br/>UI features"]
  node_web_shared["Shared UI<br/>UI toolkit"]
  node_web_api["API client"]
end

subgraph group_backend["Backend"]
  node_server_app["API app<br/>Spring Boot app"]
  node_server_domain["Domain model<br/>Business domain"]
  node_server_auth["Auth module<br/>Auth/RBAC"]
  node_server_search["Search module<br/>Search service"]
  node_server_notification["Notification module<br/>Notifications"]
  node_server_storage["Storage module<br/>Object storage"]
  node_server_infra["Infra module<br/>Adapters"]
  node_controllers["Controllers<br/>API boundary"]
  node_app_services["App services<br/>Use-case layer"]
  node_domain_skill["Skills<br/>Skill lifecycle"]
  node_domain_governance["Governance<br/>Workflow"]
  node_domain_social["Social<br/>Engagement"]
  node_domain_user["Users<br/>User/profile"]
end

subgraph group_data["Data & Runtime"]
  node_postgres[("PostgreSQL<br/>System of record")]
  node_redis[("Redis<br/>Cache/streams")]
  node_object_storage[("Object storage<br/>S3/MinIO")]
  node_scanner["Scanner<br/>Security scan service"]
end

node_web -->|"renders"| node_web_features
node_web -->|"uses"| node_web_shared
node_web -->|"calls"| node_web_api
node_web_features -->|"HTTP"| node_server_app
node_controllers -->|"routes to"| node_app_services
node_app_services -->|"orchestrates"| node_server_domain
node_server_domain -->|"owns"| node_domain_skill
node_server_domain -->|"owns"| node_domain_governance
node_server_domain -->|"owns"| node_domain_social
node_server_domain -->|"owns"| node_domain_user
node_server_app -->|"depends on"| node_server_auth
node_server_app -->|"depends on"| node_server_search
node_server_app -->|"depends on"| node_server_notification
node_server_app -->|"depends on"| node_server_storage
node_server_app -->|"depends on"| node_server_infra
node_server_search -->|"indexes"| node_postgres
node_server_notification -->|"persists"| node_postgres
node_server_auth -->|"sessions/tokens"| node_redis
node_server_app -->|"rate limits"| node_redis
node_server_storage -->|"stores blobs"| node_object_storage
node_server_app -->|"scans packages"| node_scanner
node_domain_skill -->|"persists"| node_postgres
node_domain_governance -->|"persists"| node_postgres
node_domain_user -->|"persists"| node_postgres
node_domain_social -->|"persists"| node_postgres

click node_web "https://github.com/iflytek/skillhub/tree/main/web"
click node_web_features "https://github.com/iflytek/skillhub/tree/main/web/src/features"
click node_web_shared "https://github.com/iflytek/skillhub/tree/main/web/src/shared"
click node_web_api "https://github.com/iflytek/skillhub/tree/main/web/src/api"
click node_server_app "https://github.com/iflytek/skillhub/tree/main/server/skillhub-app"
click node_server_domain "https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain"
click node_server_auth "https://github.com/iflytek/skillhub/tree/main/server/skillhub-auth"
click node_server_search "https://github.com/iflytek/skillhub/tree/main/server/skillhub-search"
click node_server_notification "https://github.com/iflytek/skillhub/tree/main/server/skillhub-notification"
click node_server_storage "https://github.com/iflytek/skillhub/tree/main/server/skillhub-storage"
click node_server_infra "https://github.com/iflytek/skillhub/tree/main/server/skillhub-infra"
click node_controllers "https://github.com/iflytek/skillhub/tree/main/server/skillhub-app/src/main/java/com/iflytek/skillhub/controller"
click node_app_services "https://github.com/iflytek/skillhub/tree/main/server/skillhub-app/src/main/java/com/iflytek/skillhub/service"
click node_domain_skill "https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill"
click node_domain_governance "https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain"
click node_domain_social "https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/social"
click node_domain_user "https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/user"
click node_postgres "https://github.com/iflytek/skillhub/tree/main/server/skillhub-app/src/main/resources/db/migration"
click node_redis "https://github.com/iflytek/skillhub/blob/main/compose.release.yml"
click node_object_storage "https://github.com/iflytek/skillhub/tree/main/server/skillhub-storage"
click node_scanner "https://github.com/iflytek/skillhub/tree/main/scanner"

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_web,node_web_features,node_web_shared,node_web_api toneBlue
class node_server_app,node_server_domain,node_server_auth,node_server_search,node_server_notification,node_server_storage,node_server_infra,node_controllers,node_app_services,node_domain_skill,node_domain_governance,node_domain_social,node_domain_user toneAmber
class node_postgres,node_redis,node_object_storage,node_scanner toneMint
```

## Components

### Web UI

React SPA and client-side feature areas

- [Web UI](https://github.com/iflytek/skillhub/tree/main/web): React SPA · Vite-built React frontend for end users and admins · `web`
- [Feature apps](https://github.com/iflytek/skillhub/tree/main/web/src/features): UI features · Auth, skills, namespaces, review, governance, notifications, search, admin, settings · `web/src/features`
- [Shared UI](https://github.com/iflytek/skillhub/tree/main/web/src/shared): UI toolkit · Reusable components, hooks, and client-side utilities · `web/src/shared`
- [API client](https://github.com/iflytek/skillhub/tree/main/web/src/api): OpenAPI client · Typed API access and generated contracts · `web/src/api`

### Backend

Spring Boot app plus supporting Maven modules

- [API app](https://github.com/iflytek/skillhub/tree/main/server/skillhub-app): Spring Boot app · Controllers, orchestration services, filters, tasks, and wiring · `server/skillhub-app`
- [Domain model](https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain): Business domain · Skills, namespaces, reviews, reports, social, audits, and governance rules · `server/skillhub-domain`
- [Auth module](https://github.com/iflytek/skillhub/tree/main/server/skillhub-auth): Auth/RBAC · OAuth, local auth, API tokens, sessions, policies, and account merge · `server/skillhub-auth`
- [Search module](https://github.com/iflytek/skillhub/tree/main/server/skillhub-search): Search service · Indexing, query, rebuild, and visibility-aware search · `server/skillhub-search`
- [Notification module](https://github.com/iflytek/skillhub/tree/main/server/skillhub-notification): Notifications · Notification persistence, dispatch, preferences, and SSE delivery · `server/skillhub-notification`
- [Storage module](https://github.com/iflytek/skillhub/tree/main/server/skillhub-storage): Object storage · Local disk and S3-compatible storage abstraction · `server/skillhub-storage`
- [Infra module](https://github.com/iflytek/skillhub/tree/main/server/skillhub-infra): Adapters · JPA repositories, HTTP client adapters, and scanner integration · `server/skillhub-infra`
- [Controllers](https://github.com/iflytek/skillhub/tree/main/server/skillhub-app/src/main/java/com/iflytek/skillhub/controller): API boundary · Portal, admin, auth, CLI-compat, and health endpoints · `server/skillhub-app/src/main/java/com/iflytek/skillhub/controller`
- [App services](https://github.com/iflytek/skillhub/tree/main/server/skillhub-app/src/main/java/com/iflytek/skillhub/service): Use-case layer · Workflow orchestration for publish, review, governance, namespaces, search, and admin · `server/skillhub-app/src/main/java/com/iflytek/skillhub/service`
- [Skills](https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill): Skill lifecycle · Skills, versions, files, tags, labels, lifecycle, publish, and delete flows · `server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill`
- [Governance](https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain): Workflow · Namespaces, reviews, promotions, reports, notifications, and audits · `server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain`
- [Social](https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/social): Engagement · Ratings and stars plus related domain events · `server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/social`
- [Users](https://github.com/iflytek/skillhub/tree/main/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/user): User/profile · User accounts, profile updates, moderation, and review state · `server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/user`

### Data & Runtime

Datastores, storage, and deploy/runtime targets

- [PostgreSQL](https://github.com/iflytek/skillhub/tree/main/server/skillhub-app/src/main/resources/db/migration): System of record · Primary relational database for domain state · `server/skillhub-app/src/main/resources/db/migration`
- [Redis](https://github.com/iflytek/skillhub/blob/main/compose.release.yml): Cache/streams · Sessions, rate limiting, and stream-backed async coordination · `compose.release.yml`
- [Object storage](https://github.com/iflytek/skillhub/tree/main/server/skillhub-storage): S3/MinIO · Skill package and file blobs in production; local disk in development · `server/skillhub-storage`
- [Scanner](https://github.com/iflytek/skillhub/tree/main/scanner): Security scan service · External scanner/runtime used for package security analysis · `scanner`

## Connections

- Web UI → Feature apps: renders · The SPA is composed from feature areas
- Web UI → Shared UI: uses · Shared UI, hooks, and utilities support all pages
- Web UI → API client: calls · Frontend uses generated client types for backend APIs
- Feature apps → API app: HTTP · User actions invoke backend endpoints
- Controllers → App services: routes to · Controllers delegate orchestration to application services
- App services → Domain model: orchestrates · Use cases depend on domain services and model rules
- Domain model → Skills: owns · Core skill lifecycle and package handling rules
- Domain model → Governance: owns · Namespace, review, promotion, report, and audit workflows
- Domain model → Social: owns · Ratings and stars live as a separate bounded context
- Domain model → Users: owns · User account and profile management rules
- API app → Auth module: depends on · Application layer uses auth/session/token services
- API app → Search module: depends on · Application layer queries and updates search services
- API app → Notification module: depends on · Application layer publishes and reads notifications
- API app → Storage module: depends on · Upload, storage, and deletion flows use storage abstractions
- API app → Infra module: depends on · Infrastructure adapters are wired into the app
- Search module → PostgreSQL: indexes · Search persists documents and rebuild state in PostgreSQL
- Notification module → PostgreSQL: persists · Notifications and preferences are stored relationally
- Auth module → Redis: sessions/tokens · Redis supports auth session and token flows
- API app → Redis: rate limits · Redis backs streams and request throttling
- Storage module → Object storage: stores blobs · Package files are written to local disk or S3-compatible storage
- API app → Scanner: scans packages · Upload and publish flows can trigger security scanning
- Skills → PostgreSQL: persists · Skill aggregates and version data are stored in PostgreSQL
- Governance → PostgreSQL: persists · Governance state and audit records are stored in PostgreSQL
- Users → PostgreSQL: persists · User profiles and moderation data are stored in PostgreSQL
- Social → PostgreSQL: persists · Ratings and stars are stored in PostgreSQL
