Project Architecture
This guide explains the architecture of the GxP Toolkit and how plugins are structured.
Overview
The GxP Toolkit has two main parts:
- Toolkit Package (
@gxp-dev/tools) - Installed innode_modules/ - Your Plugin Project - Your custom code and configuration
Your Project
├── Your Code (src/, theme-layouts/)
├── Configuration (app-manifest.json, .env)
└── node_modules/
└── @gxp-dev/tools/
├── Runtime files (loaded at runtime)
├── CLI tool (gxdev commands)
└── Browser extensions
Toolkit Directory Structure
@gxp-dev/tools/
├── bin/ # CLI Tool
│ ├── gx-devtools.js # Main entry point
│ └── lib/
│ ├── cli.js # Yargs command setup
│ ├── constants.js # Shared constants
│ ├── commands/ # CLI command implementations
│ │ ├── init.js # gxdev init
│ │ ├── dev.js # gxdev dev
│ │ ├── build.js # gxdev build
│ │ ├── datastore.js # gxdev datastore
│ │ ├── socket.js # gxdev socket
│ │ ├── assets.js # gxdev assets
│ │ ├── extensions.js # gxdev ext:*
│ │ ├── ssl.js # gxdev setup-ssl
│ │ └── publish.js # gxdev publish
│ ├── utils/ # Utility functions
│ └── tui/ # Interactive TUI (TypeScript/Ink)
│ ├── index.tsx
│ ├── App.tsx
│ ├── components/
│ └── services/
├── runtime/ # Runtime files (used from node_modules)
│ ├── PortalContainer.vue # Platform emulator
│ ├── gxpStringsPlugin.js # Vue directives plugin
│ ├── main.js # Dev entry point
│ ├── vite.config.js # Vite configuration
│ ├── index.html # Dev HTML template
│ ├── server.cjs # Socket.IO server
│ ├── stores/
│ │ └── gxpPortalConfigStore.js # Pinia store
│ └── dev-tools/ # In-browser dev tools
│ ├── DevToolsModal.vue
│ ├── StoreInspector.vue
│ ├── LayoutSwitcher.vue
│ ├── SocketSimulator.vue
│ └── MockDataEditor.vue
├── template/ # Files copied to projects
│ ├── src/
│ │ ├── Plugin.vue # Main plugin component
│ │ ├── DemoPage.vue # Example component
│ │ ├── DemoExperience.vue # Experience-flow teaching demo
│ │ └── stores/index.js # Store setup
│ ├── theme-layouts/ # Layout components
│ ├── app-manifest.json # Plugin configuration
│ ├── configuration.json # Additional config
│ └── ...
├── socket-events/ # Socket event templates
├── browser-extensions/ # Chrome/Firefox extensions
│ ├── chrome/
│ └── firefox/
├── scripts/ # Utility scripts
└── dist/ # Compiled TUI
Runtime vs Template
Understanding the difference between runtime and template files is crucial:
Runtime Files (runtime/)
- Normally remain in the selected toolkit installation - Supported publish targets can be copied locally
- Imported at runtime via
@gx-runtimealias - Versioned with the selected toolkit - Upgrade and lock the project dependency deliberately
- Customization is explicit - Publish supported files or use
vite.extend.js
Key runtime files:
| File | Purpose |
|---|---|
PortalContainer.vue | Platform emulator wrapper |
gxpPortalConfigStore.js | Central Pinia store |
gxpStringsPlugin.js | Vue directives |
main.js | Development entry point |
vite.config.js | Build configuration |
server.cjs | Socket.IO server |
dev-tools/*.vue | In-browser debugging tools |
Template Files (template/)
- Copied to your project during
gxdev init - Owned by you - Customize freely
- Existing files are preserved by default - An explicit overwrite during initialization can replace them
Key template files:
| File | Purpose |
|---|---|
src/Plugin.vue | Your main component |
src/DemoPage.vue | Example component |
theme-layouts/*.vue | Layout wrappers |
app-manifest.json | Plugin configuration |
.env | Environment variables |
Plugin Project Structure
After gxdev init, your project looks like:
my-plugin/
├── src/
│ ├── Plugin.vue # ← Your main entry point
│ ├── DemoPage.vue # ← Example (can delete)
│ ├── DemoExperience.vue # ← Experience-flow example (can delete)
│ ├── public/ # ← Default scaffold asset_dir
│ │ └── .gitkeep
│ └── stores/
│ └── index.js # ← Pinia setup
├── theme-layouts/
│ ├── PublicLayout.vue # ← Public layout wrapper
│ ├── PrivateLayout.vue # ← Authenticated layout
│ ├── SystemLayout.vue # ← Admin layout
│ └── AdditionalStyling.css # ← Extra CSS
├── socket-events/ # ← Socket event templates
├── scripts/
│ ├── launch-chrome.js # ← Chrome launcher
│ └── pack-chrome.js # ← Chrome ZIP packager
├── vite.extend.js # ← Vite configuration extension
├── vitest.config.js # ← Test configuration
├── app-manifest.json # ← Plugin configuration
├── configuration.json # ← Additional configuration
├── app-instructions.md # ← Plugin documentation
├── default-styling.css # ← Default CSS
├── .env # ← Environment variables
├── .env.example # ← Environment template
├── .gitignore
├── package.json
└── README.md
Vite Aliases
The toolkit configures these path aliases in vite.config.js:
| Alias | Points To | Usage |
|---|---|---|
@ | ./src/ | Your components |
@layouts | Project theme-layouts/, otherwise runtime fallback layouts | Layout components |
@gx-runtime | node_modules/.../runtime/ | Toolkit runtime |
Example imports:
import MyComponent from "@/components/MyComponent.vue"
import PublicLayout from "@layouts/PublicLayout.vue"
import { useGxpStore } from "@/stores/gxpPortalConfigStore"
Plugin Architecture
Component Hierarchy
┌─────────────────────────────────────────────────────────────┐
│ PortalContainer.vue (runtime) │
│ - Platform emulator │
│ - Provides mock router, theme, data │
│ - Passes mock router to Plugin │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Layout (PublicLayout/PrivateLayout/SystemLayout) │ │
│ │ - Layout wrapper │ │
│ │ - Header, footer, navigation │ │
│ │ │ │
│ │ ┌───────────────────────────────────────────────────┐ │ │
│ │ │ Plugin.vue (your code) │ │ │
│ │ │ - Your main component │ │ │
│ │ │ - Reads host-compatible store │ │ │
│ │ │ │ │ │
│ │ │ ┌───────────────────────────────────────────────┐ │ │ │
│ │ │ │ Your Components │ │ │ │
│ │ │ │ - DemoPage, forms, etc. │ │ │ │
│ │ │ └───────────────────────────────────────────────┘ │ │ │
│ │ └───────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Injected Props
The local PortalContainer.vue renders <Plugin :router="mockRouter" />. It does not pass the full store snapshot as plugin props. Read settings, strings, assets, dependencies, permission flags, and trigger state through the GxP Store, using the host-compatible import:
import { useGxpStore } from "@/stores/gxpPortalConfigStore"
const store = useGxpStore()
The build transform maps this exact import to the platform's window.useGxpStore contract. @gx-runtime is an internal toolkit-runtime alias; using it to import a store in plugin code bypasses that intended host-store import path. The local preview loads manifest-backed data, while production data and permissions come from the host platform. Validate production bindings separately.
Data Flow
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ app-manifest.json │────▶│ GxP Store │────▶│ Your Components │
└──────────────────┘ │ (Pinia) │ └──────────────────┘
│ │ │
│ - pluginVars │ │
│ - stringsList │ │
│ - assetList │ ▼
│ - triggerState │ ┌──────────────────┐
│ │ │ gxp-string │
└──────────────────┘ │ gxp-src │
│ │ directives │
│ └──────────────────┘
▼
┌──────────────────┐
│ Dev Tools │
│ (Ctrl+Shift+D) │
└──────────────────┘
Store Initialization
- Store created - Default values loaded
- Manifest fetched -
app-manifest.jsonloaded via HTTP - Store updated - Manifest values applied
- Directives update -
gxp-string/gxp-srcelements refresh - Hot reload - Changes to manifest trigger updates
Build Process
Development (gxdev dev)
Your Code Runtime Files
│ │
▼ ▼
┌─────────┐ ┌─────────────┐
│ Vite │◀──────────────│ vite.config │
│ Dev │ │ (runtime) │
│ Server │ └─────────────┘
└─────────┘
│
▼
┌─────────────────────────────────────┐
│ Development Server │
│ - Hot Module Replacement │
│ - Manifest hot-reload │
│ - Transformed source modules │
│ - Dev tools (Ctrl+Shift+D) │
└─────────────────────────────────────┘
Production (gxdev build)
src/Plugin.vue
│
▼
┌─────────┐ ┌── ───────────┐
│ Vite │────▶│ dist/build │
│ Build │ │ - plugin.es.js
└─────────┘ │ - style.css
│ - app-manifest.json
│ - assets/
└─────────────┘
│
▼
┌─────────────┐
│ .gxpapp │
│ (ZIP file) │
└─────────────┘
Build Output
dist/
├── build/
│ ├── plugin.es.js # Main bundle (ES module)
│ ├── style.css # Extracted styles
│ ├── app-manifest.json # Cleaned manifest
│ ├── assets/ # From manifest asset_dir (scaffold: src/public)
│ ├── appInstructions.md # Optional
│ ├── default-styling.css # Optional
│ └── configuration.json # Optional
└── my-plugin.gxpapp # Deployable package
The scaffold sets asset_dir to /src/public; the packager fallback when that value is absent is /src/assets/. Inspect your manifest before diagnosing missing assets.
The default CSS filename is style.css; additional emitted JS/CSS files can also be included. The archive stores JS/CSS and the cleaned manifest at its root, with package assets under assets/. The archive filename comes from the sanitized manifest name, falling back to the package name. Optional file references take precedence over inline values; a missing referenced file produces a warning, so inspect the archive rather than assuming it was included.
The packager rejects traversal, symlinks, nonregular entries, and asset directories containing the build directory. See Building for Platform for the hosted CI and publishing contract.
Socket.IO Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Your Plugin │────▶│ Socket.IO │◀────│ Socket Events │
│ (Browser) │ │ Server │ │ (JSON files) │
└─────────────────┘ │ (Node.js) │ └─────────────────┘
└─────────────────┘
│
▼
┌─────────────────┐
│ GxP Store │
│ socket methods │
└─────────────────┘
Socket Channels
Production dependency channels can use model identifiers such as the following. The local Socket.IO relay does not implement tenant or room isolation from this channel metadata; see Socket Events for its broadcast behavior. Do not use the local relay as evidence of production authorization.
Example channel shape:
private.{Model}.{identifier}
Example: private.AiInterface.ai_session_123
Customizing Runtime Files
To customize runtime files, use gxdev publish:
# Copy server.cjs to project root
gxdev publish server.cjs
# Copy store to src/stores/
gxdev publish gxpPortalConfigStore.js
# Customize Vite configuration by editing the project file
# vite.extend.js (merged with the toolkit configuration)
The supported publish names are main.js, index.html, server.cjs, gxpPortalConfigStore.js, and gxpFormStore.js. Unknown names, including vite.config.js and PortalContainer.vue, are rejected. Publishing the portal store also copies its companion form store when absent. Existing destination files prompt before overwrite.
Use vite.extend.js for Vite configuration changes. Published files are copies owned by your project; compare them with toolkit updates rather than assuming they update automatically. See Socket Events for the copied-server path and dependency limitations.
Extension Architecture
┌─────────────────────────────────────────────────────────────┐
│ Browser │
│ │
│ ┌───────────────────────┐ ┌──────────────────────────┐ │
│ │ DevTools Panel │ │ Your Plugin Page │ │
│ │ (panel.html) │ │ │ │
│ │ │ │ ┌──────────────────────┐ │ │
│ │ - Element inspector │◀───│ │ Injected inspector │ │ │
│ │ - Component viewer │ │ │ (inspector.js) │ │ │
│ │ - String extractor │ │ │ │ │ │
│ └───────────────────────┘ │ │ - DOM inspection │ │ │
│ │ │ │ - Vue detection │ │ │
│ ▼ │ │ - Highlighting │ │ │
│ ┌───────────────────────┐ │ └──────────────────────┘ │ │
│ │ Background Script │ └──────────────────────────┘ │
│ │ (background.js) │ │
│ └───────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
File Ownership Summary
| File/Directory | Owner | Customizable |
|---|---|---|
src/ | You | Yes |
theme-layouts/ | You | Yes |
app-manifest.json | You | Yes |
.env | You | Yes |
socket-events/ | You | Yes |
dev-assets/ | You | Yes |
PortalContainer.vue | Toolkit | Not a supported publish target |
gxpPortalConfigStore.js | Toolkit | Via publish |
vite.config.js | Toolkit | Extend using vite.extend.js |
server.cjs | Toolkit | Via publish |
| Browser extensions | Toolkit | Project overrides are command-specific; see Browser Extensions |
Best Practices
1. Don't Modify node_modules
Use gxdev publish for supported file copies and vite.extend.js for Vite changes. Avoid modifying installed toolkit files directly; those edits are not a reproducible project override.
2. Keep Plugin.vue Clean
Use Plugin.vue as a thin wrapper that imports your actual components:
<template>
<component :is="currentView" />
</template>
<script setup>
import { shallowRef } from "vue"
import WelcomeView from "@/views/WelcomeView.vue"
import CheckInView from "@/views/CheckInView.vue"
const currentView = shallowRef(WelcomeView)
</script>
3. Use the Store
Don't pass props through multiple components. Use the store directly:
<script setup>
import { useGxpStore } from "@/stores/gxpPortalConfigStore"
const store = useGxpStore()
</script>
4. Organize by Feature
src/
├── Plugin.vue
├── views/
│ ├── WelcomeView.vue
│ ├── CheckInView.vue
│ └── ConfirmationView.vue
├── components/
│ ├── forms/
│ ├── buttons/
│ └── cards/
└── composables/
└── useCheckIn.js
5. Keep Manifest Organized
Group related strings and settings:
{
"strings": {
"default": {
"checkin_title": "...",
"checkin_subtitle": "...",
"checkin_btn_submit": "...",
"welcome_title": "...",
"welcome_subtitle": "..."
}
}
}