mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-26 14:23:33 +08:00
65 lines
13 KiB
Markdown
65 lines
13 KiB
Markdown
# Architecture map
|
|
|
|
Ray Template is a pnpm workspace. The admin application owns host integration, the documentation site explains public usage, and shared packages own reusable implementations. Use the [task index](../llms.txt) to locate features. Use this page to identify ownership and trace calls across modules.
|
|
|
|
## Workspaces
|
|
|
|
| Directory | Responsibility and authoritative entry point |
|
|
| ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| [apps/admin](../apps/admin) | Ray Admin: application configuration, route registration, Pinia, providers, pages, demo data, and development mocks. This is Vite's application root. |
|
|
| [apps/docs](../apps/docs/README.md) | VitePress site: reader guides, APIs, migration instructions, and interactive examples consuming public shared-package entry points. |
|
|
| [packages](../packages) | Shared packages listed below. Each package's `package.json#exports` defines its root entry point and importable subpaths. |
|
|
| [Tests](../__test__) | Vitest regressions grouped by behavior rather than mirroring the source tree. Use [Harness scopes](../harness/scopes.json) to locate coverage. |
|
|
| [docs](./), [harness](../harness/README.md) | Maintainer conventions and cross-module explanations. Harness owns task navigation, targeted checks, and evidence. Reader-facing documentation belongs in `apps/docs`. |
|
|
| [scripts](../scripts), [vite-helper](../vite-helper), [unplugin](../unplugin) | Repository checks, Vite plugin helpers, and generated auto-import declarations. Build, type, and CI configuration remains at the root. |
|
|
|
|
| Shared package | Implementation ownership | Host boundary |
|
|
| --------------------------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| [@ray-template/utils](../packages/utils/package.json) | Precision, type checks, data/file utilities, and generic JSON storage | Callers supply Storage. Application keys, cache backends, and legacy AES formats stay in the application. |
|
|
| [@ray-template/composables](../packages/composables/package.json) | Vue composables and DOM, element, and scope utilities | Application-specific navigation, theme, and content-area hooks stay in the application. |
|
|
| [@ray-template/directives](../packages/directives/package.json) | Vue directives and registration | The host supplies copy notifications and decides when to register. |
|
|
| [@ray-template/icons](../packages/icons/package.json) | SVG files, manifests, icon-name types, and lookups | The build generates spritemaps. The host supplies icon-resolution services. |
|
|
| [@ray-template/ui](../packages/ui/package.json) | Shared components, themes, and UI service interfaces | The admin application injects translation, theme, storage, and other services. Application component entry points re-export shared components. |
|
|
| [@ray-template/http](../packages/http/package.json) | Independent HTTP clients, interceptors, and cancellation | The application supplies request configuration and interceptors, and wraps business APIs. |
|
|
| [@ray-template/api-contracts](../packages/api-contracts/package.json) | Business/demo API types, runtime schemas, and OpenAPI | Independent of browsers and mocks. The application, mocks, and integrating backends share the protocol. |
|
|
| [@ray-template/routing](../packages/routing/package.json) | Route configuration validation, expansion, and menu traversal | The application owns the view registry, configuration sources, roles, sessions, and guards. |
|
|
| [@ray-template/admin-shell](../packages/admin-shell/package.json) | Layout shell, settings, transitions, and cached-page rendering | The host supplies route state, preferences, navigation, and content slots. |
|
|
|
|
Application `@/components`, `@/hooks`, and `@/utils` include compatibility entry points. Follow actual exports to determine ownership. Shared packages must not depend on application aliases or relative imports across workspaces. The [package-boundary check](../scripts/check-package-boundaries.mjs) validates dependency declarations, public entry points, and cycles.
|
|
|
|
## Key runtime flows
|
|
|
|
| Flow | Call order and boundaries | Continue with |
|
|
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
|
|
| Admin bootstrap | [index.html](../apps/admin/index.html) → [main.ts](../apps/admin/src/main.ts) → Pinia → internationalization → Router → Day.js → directives and autocomplete settings → mount [App.tsx](../apps/admin/src/App.tsx). Standalone and Wujie modes share plugin registration order. | [Layout and bootstrap](../harness/context/layout.md) |
|
|
| Navigation and caching | [Router initialization](../apps/admin/src/router/index.ts) loads the source → [application route modules](../apps/admin/src/router/app-route-modules.ts) expand configuration → guards and pages are registered → application menu stores and layouts consume routes. The application maintains the cache allowlist; the shared shell renders transitions and KeepAlive. | [Routing](../harness/context/routing.md), [layout](../harness/context/layout.md) |
|
|
| Requests and demo data | [API](../apps/admin/src/api) → [application Axios instance](../apps/admin/src/axios/instance.ts) → [shared client](../packages/http/src/client.ts). Development and static online demos share HTTP mocks. Users, sessions, and routes are read/written through APIs; integrating backends own real sessions and resource authorization. | [API](../harness/context/api.md) |
|
|
| Documentation examples | Documentation can consume shared packages directly. When application context is required, [AdminExample.vue](../apps/docs/examples/AdminExample.vue) embeds [example.html](../apps/admin/example.html) with isolated bootstrap, restricted routes, and in-memory caching. | [Documentation and examples](../harness/context/docs.md) |
|
|
| Application configuration | [Vite](../vite.config.ts) injects `__APP_CFG__` and `__DEV__`; [application configuration](../apps/admin/src/app-config) is grouped by design, requests, routing, and caching. | [Build and toolchain](../harness/context/toolchain.md) |
|
|
|
|
Maintain guides and runnable examples for public behavior changes through [application/documentation coordination](docs-handoff.md). See [visual and layout guidance](ui-design.md) for page design and [comment style](comment-style.md) for code comments.
|
|
|
|
## TypeScript project configuration
|
|
|
|
The [root configuration](../tsconfig.json) references four projects. Strict mode, module resolution, and type-checking aliases live in the [shared configuration](../tsconfig.base.json). When changing aliases, check [Vite](../vite.custom.config.ts) and [Vitest](../vitest.config.ts) as well.
|
|
|
|
| Configuration | Coverage |
|
|
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| [Application](../tsconfig.app.json) | Admin `apps/admin/src`, Vue JSX, and generated declarations. |
|
|
| [Node](../tsconfig.node.json) | Root build/test configuration, `vite-helper`, and build helpers. |
|
|
| [Tests](../tsconfig.test.json) | `__test__` and referenced source, loading Vitest and Node types. Vitest configuration and individual test files determine the runtime environment. |
|
|
| [Shared packages](../tsconfig.packages.json) | `packages/*/src`, without inheriting application aliases or auto-import declarations. |
|
|
| [Documentation site](../apps/docs/tsconfig.json) | Independent documentation-example checks, run by `pnpm docs:check`. |
|
|
|
|
`pnpm typecheck` first validates icon synchronization, then runs `vue-tsc --build` for the four projects referenced by the root configuration. Incremental caches live in `node_modules/.cache/ray-template/`. Use `pnpm exec vue-tsc -p <configuration-file>` for an individual project.
|
|
|
|
## Deployment and search discovery
|
|
|
|
`pnpm build` produces admin output in `dist/production`; `pnpm docs:build` produces `apps/docs/.vitepress/dist`. `pnpm pages:build` combines them in `dist/pages`, with documentation under `docs/`. The default admin base is `/ray-template/`; the documentation base is `/ray-template/docs/`. For root hosting or another subpath, align the [admin base](../vite.custom.config.ts), [documentation base](../apps/docs/.vitepress/config.mts), and [legacy redirect targets](../scripts/assemble-pages.mjs).
|
|
|
|
After main-branch checks pass, [CI](../.github/workflows/ci.yaml) publishes the combined output to the `dist` branch. The [admin public .nojekyll file](../apps/admin/public/.nojekyll) is copied into the output. Preserve it when deploying manually to Pages so assets with underscore prefixes can load.
|
|
|
|
For public builds, set `RAY_TEMPLATE_SITE_ORIGIN` to the actual site origin; the base supplies the path. Without it, admin production builds emit `noindex`. The public admin landing page generates canonical metadata, sharing previews, and `sitemap.xml`; authenticated hash routes are not listed as public pages. Domain-level crawling rules belong in `/robots.txt` at the site root. [VitePress mappings](../apps/docs/.vitepress/legacy.mts) generate legacy in-site links. When a site origin is configured, the assembly script also generates `dist/legacy-docs` for migrating the old site.
|
|
|
|
Establish implementation behavior from tracked source and configuration. Generated artifacts, dependencies, caches, and `.harness-local/` reports are useful for inspecting build and verification results.
|