Back to Cherry Studio

Application

src/main/core/application/README.md

2.0.01.9 KB
Original Source

Application

Application is the top-level orchestrator that ties together the lifecycle system and the Electron app.

Full documentation has moved to docs/references/lifecycle/. This file is a quick-reference pointer.

Import

Main-process code imports the singleton via the @application path alias, which resolves directly to Application.ts (not a directory barrel) — so importing the locator never drags in the whole service registry:

ts
import { application } from '@application'

The service registry (serviceList / services) is bootstrap-internal; import it directly from its file when wiring startup:

ts
import { serviceList } from '@main/core/application/serviceRegistry'

The alias is configured in tsconfig.node.json (compilerOptions.paths) and electron.vite.config.ts (main.resolve.alias). Vitest inherits the Vite alias automatically.

TopicReference Doc
Application architecture & bootstrap flowApplication Overview
Lifecycle internals (phases, hooks, states)Lifecycle Overview
Full usage guideUsage Guide
Migrating old servicesMigration Guide

File Structure

application/
├── Application.ts      # Application singleton + lazy proxy — the `@application` alias target
└── serviceRegistry.ts  # Central service registry (add services here); imported directly, not via a barrel

No index.ts barrel: the two files are independent (the locator vs the bootstrap manifest), so each is imported directly by its consumers rather than bundled behind a door (per Naming §6.4).