MiniX is an agent-friendly, runtime-zero-dependency application kernel for Mini Programs and H5.
It is designed for multi-app product matrices such as education tools, utility apps, and information-management apps, where many capabilities repeat across products:
- authentication and session management
- user profile and preferences
- request pipeline and API access
- storage and state recovery
- telemetry and monitoring
- page shells and layout presets
- platform capability detection
- routing abstraction
- page model reuse
MiniX does not aim to be a full cross-platform rendering framework like uni-app or Taro.
Instead, MiniX follows this model:
- shared business kernel
- explicit platform adapters
- reusable page protocols
- thin per-platform view implementations
MiniX must provide:
- Runtime zero dependencies
- Shared business kernel across mini program and H5
- Explicit platform adaptation boundaries
- Agent-friendly code organization
- Stable interfaces for repeated app generation
- Strong control over authentication, requests, telemetry, and layouts
MiniX does not aim to provide:
- full view-layer unification across all platforms
- a template compiler or DSL
- a huge UI component ecosystem
- all platform-specific advanced capability abstractions
- magic runtime behavior that hides platform boundaries
Runtime code must depend only on:
- official mini program APIs
- standard browser Web APIs
- MiniX internal source code
Development-time tools may exist, but they are excluded from runtime.
MiniX shares:
- data and state models
- request/auth/session logic
- telemetry model
- page protocols
- layout contracts
- capability contracts
MiniX does not force shared source code for:
- view templates
- style implementations
- complex interactive components
Shared business code must not call raw host APIs directly.
Forbidden in shared packages and business/domain code:
wx.*tt.*my.*- direct
window.*platform assumptions
Platform adapters own reusable host integration under packages/platform-*. Host apps may still contain host-only bootstrap, rendering, and shell code, but shared behavior should move to packages/features/* or packages/core.
Stable contracts are preferred over implicit conventions and magic APIs.
MiniX is built around explicit interfaces such as:
- RequestAdapter
- StorageAdapter
- AuthAdapter
- RouterAdapter
- LifecycleAdapter
- TelemetryAdapter
- CapabilityAdapter
- UIAdapter
All modules must return a shared Result<T> type or a normalized AppError.
Business services should not throw uncontrolled platform-native exceptions.
Repository and module structure must stay stable so that agents can:
- locate modules deterministically
- patch only the right files
- generate new modules from templates
- validate adapter contracts
MiniX uses the package layers that exist in the current workspace:
packages/contractsShared route ids, backend-facing request/response types, and canonical domain output shapes.packages/coreShared ports, runtime orchestration, page protocols, store primitives, error handling, and common runtime types.packages/features/*Platform-agnostic business controllers, state projection, feature manifests, and feature-owned defaults.packages/platform-h5andpackages/platform-wechatReusable browser and WeChat adapters that satisfy core ports.apps/*Host bootstrap, manifest source, page registrations, rendering glue, and generated host shell output.apps/apiSample backend app with explicit HTTP, composition, and domain slices.
New platform families, UI frameworks, or top-level shared packages are outside the current release line unless a task explicitly records that scope decision.
The repository is now frozen to the v1.0.0 sample surface:
apps/apiapps/host-h5apps/host-wechatapps/novel-h5apps/novel-wechat
The goal is to keep these samples reliable under one explicit kernel contract. MiniX is not expanding into a broader rendering framework or new platform family in the current release line.
packages/contracts owns:
- backend request and response shapes
- route ids and route maps
- canonical domain output shapes
- shared page and capability contracts
When a domain surface changes across more than one host, change the contract first instead of adapting one caller locally.
packages/core owns:
src/ports/*: adapter-facing contractssrc/runtime/*: shared orchestration and service compositionsrc/store/*: shared page models and state containerssrc/error/*andsrc/types/*: runtime primitives
Cross-feature runtime helpers belong here, not inside one feature package.
packages/features/* owns:
- normalized controller state
- cross-host route synchronization
- action lifecycle
- feature-owned defaults and host-facing manifests
Feature packages may depend on contracts and core, but not on platform packages or host apps.
When continuing an existing capability:
- prefer extending the existing feature package over creating a sibling package
- reuse canonical domain outputs instead of adding feature-local wrappers
- reuse shared page protocols before inventing bespoke loading, detail, or form state
Platform-specific code lives only in:
packages/platform-wechat/src/adapters/*packages/platform-h5/src/adapters/*
Adapters translate host APIs into stable core contracts. Shared code must not call wx.* or window.* directly.
Capability health should be exposed back to shared code as normalized snapshots. Runtime adapters still own the raw host API checks, but shared controllers should consume one additive snapshot shape for payment, share, upload, clipboard, and location instead of building host-local diagnostic branches.
Host apps own enablement and host-only policy, not shared business behavior.
Editable source of truth:
apps/*/src/manifest/page-definitions.ts
Derived outputs:
src/manifest/app.manifest.tssrc/manifest/page-manifest.tssrc/manifest/page-config.tssrc/registrations/page-registry.ts- WeChat shell outputs
Change the source manifest, then regenerate derived files. Do not patch generated host files manually.
The sample API under apps/api/src follows the same explicit-boundary rule.
Use these layers:
app.ts: app creation and top-level middleware onlyapp-composition*.ts: route-group and top-level wiringhttp/*: shared request, auth-header, CORS, and response helpersdomains/*/routes.ts: domain entry and assemblydomains/*/routes.*.ts: domain-internal route slices
Practical rules:
app.tsand composition layers stay thinroutes.tsstays an assembly file- business handlers and workflow shaping live in the domain slices
- cross-domain business derivation stays in domain modules, not back in
app.ts
When continuing feature or code completion work, prefer closing the whole shared slice rather than patching a single host.
Core rules:
- Normalize outputs to the canonical domain envelopes documented in
docs/BACKEND_CONTRACT.md. - Keep route restore, selection restore, unauthorized return, and shared action state inside shared controllers when the behavior is cross-host.
- Treat account and settings as summary workspaces; do not force them into fake list/detail shells.
- Keep provider posture explicit. If production behavior still depends on operator rollout, fail closed in production mode and document the remaining operator step.
- Record intentional exceptions or remaining rollout gaps in
docs/DOMAIN_COMPLETENESS_MATRIX.mdinstead of burying them in host copy or controller drift. - Future content and discover growth must extend the existing shared discover, content, upload, and feedback stack additively before any new route family is justified.
- Future user and relationship growth must extend the shared account workspace additively before any dedicated user-detail surface is justified.
- Capability UX hardening should improve normalized shared capability summaries first; runtime-specific branching still belongs in
packages/platform-*. - Capability health snapshots should stay in shared controller state and reuse the same snapshot vocabulary across features before any host-visible diagnostics copy is added.
MiniX prefers shared page protocols over feature-local state machines.
Current posture:
- list-like surfaces should use the shared list protocol
- detail-like surfaces should use the shared detail protocol
- workflow and submit surfaces should use the shared form protocol
- account and settings remain explicit summary-workspace exceptions
- reader remains an explicit immersive-runtime exception
- auth login and identity handoff remain provider-aware workflow exceptions
If a feature starts duplicating list/detail/form state by hand, the architecture expectation is to stop and move that behavior back onto the shared protocol surface.
The repository distinguishes between:
- release-complete shared behavior and official-host coverage
- operator-owned external setup such as real provider credentials, WeChat allowlists, and Cloudflare resource ids
That split is intentional. v1.0.0 is a defensible official-sample system, not a credentials-in-repo turnkey deployment.
For exact release readiness and operator setup, use docs/PRODUCTION_READINESS.md and docs/RELEASE_RUNBOOK.md.
Architecture changes are only acceptable when all of the following remain true:
- shared layers do not directly reference host globals
- platform differences stay in adapters or host manifests
- services and expected business failures stay on
Result<T>or normalized app errors - route selection stays manifest-driven through route ids and host metadata
- new shared behavior does not require hand-maintained duplicate route maps or generated-file edits
- validation continues to pass through
pnpm verifyand any relevant scoped feature or host checks