Project Structure Specification
This document mainly describes the development specification for projects and the standard specification for finished build artifacts.
Project development specification
During project development a sound engineering structure is essential: it helps developers locate problems quickly, lowers project complexity, and improves development efficiency.
Frontend development specification
When developing the frontend, follow the directory structure below. All frontend project files must be placed in the web directory under the project root:
web/
├── index.html # Main entry HTML file
└── build.sh # Build scriptweb/
├── index.html # Main entry HTML file
├── package.json # Project dependencies and script configuration
├── public/ # Static asset directory
├── src/ # Source code directory
│ ├── assets/ # Static asset directory
│ ├── components/ # Component directory
│ ├── App.vue # Root component
│ ├── main.js # App entry file
│ └── style.css # Global stylesheet
├── vite.config.js # Vite configuration file
├── yarn.lock # Yarn package manager lock file
└── build.sh # Build scriptweb/
├── index.html # Main entry HTML file
├── public/ # Public asset folder
│ └── vite.svg # Vite icon
├── src/ # Source code directory
│ ├── assets/ # Static asset directory
│ ├── components/ # Component directory
│ ├── App.jsx # Root component
│ ├── main.jsx # App entry file
│ └── style.css # Global stylesheet
├── vite.config.js # Vite configuration file
├── yarn.lock # Yarn package manager lock file
└── build.sh # Build scriptBackend development specification
When developing the backend, follow the Go project directory structure below. All backend project files go in the backend directory:
backend/
├── main.go # Program entry: parse the socket path, create and start the RPC Server
├── Makefile # Backend compile, run, and cross-compilation packaging scripts
├── config.json # Environment configuration (test/prod environments, logging and runtime options)
├── go.mod / go.sum # Go dependency management files
├── i18n/ # Internationalization language files
│ ├── zh-CN.ini # Chinese translation pack
│ └── en.ini # English translation pack
├── internal/ # Core business code (strict one-way layering, reverse dependencies forbidden)
│ ├── common/ # Shared app constants (AppName, OrgName, GMSSH path rules, error codes)
│ ├── core/adapter/ # External adapters (database drivers, external services, or low-level command wrappers)
│ ├── dto/ # Data transfer objects (XxxReq / XxxResp, input bound and validated automatically)
│ ├── handler/rpc/ # Access layer: RPC route registration (server.go) and method handlers
│ ├── model/ # Business data models and entity definitions
│ └── service/ # Core business logic layer (NewXxxService factory pattern)
├── pkg/ # Shared utility libraries
│ ├── files/ # Safe file operation wrapper (with built-in path traversal checks)
│ └── rpcutil/ # RPC request deserialization and i18n language context binding utilities
├── data/ # Runtime data directory (created automatically for local debugging and packaging)
├── logs/ # Runtime log directory (created automatically for local debugging and packaging)
└── tmp/ # Runtime temporary file directory (where the local debugging socket lives)Mandatory layering and call rules
handler (access layer) ← receives RPC requests, parses parameters, returns responses
↓ calls
service (business logic) ← core business implementation, orchestrates model and adapter
↓ calls
model (data model layer) ← business entity definitions
↓ uses
core/adapter (infrastructure) ← external service wrappers (DB, low-level commands, etc.)- Upper layers call lower layers; reverse dependencies are strictly forbidden.
common/anddto/are the shared contract layer and may be referenced by any layer. - Handlers hold no complex business logic, and services never handle low-level RPC request objects directly.
Complete project structure
A micro-app keeps frontend and backend code in one Git repository. The standard repository layout is:
my-gmssh-app/
├── web/ # Frontend directory
│ ├── index.html # Main entry HTML file (or the Vue / React source project)
│ ├── build.sh # Frontend automated build and packaging script
│ └── README.md # Frontend notes
├── backend/ # Go backend project directory
│ ├── main.go # Backend service entry
│ ├── Makefile # Backend compile and cross-build scripts
│ ├── config.json # Environment configuration file
│ ├── go.mod / go.sum # Module dependencies
│ ├── i18n/ # Multi-language files
│ ├── internal/ # Internal business logic (layered architecture)
│ └── pkg/ # Shared utility function libraries
├── install.sh # App install/initialization script (optional; the platform calls it on deployment)
├── makefile # Root build orchestration script
└── README.md # Project documentationBuild artifact specification
To keep apps consistent and standardized, the build output must be organized into a micro-app package (ZIP) as described below when you run a build:
Build artifact deployment specification
After the build script runs, the artifacts are all placed inside the app package:
- Backend artifact: compiled into a static binary and placed in the
app/bin/directory; the main executable must be namedmain - Frontend artifact: placed in the
app/www/directory after packaging; the main entry file must be namedindex.html - Socket file rules: the socket file created by the backend must be placed in the
tmp/directory and namedapp.sock; platform health checks and frontend requests are routed to this path automatically.
app install directory/
├── app/ # Application directory
│ ├── bin/ # Executable directory
│ │ └── main # Linux binary produced by the Go build (no dependencies)
│ └── www/ # Web static asset directory
│ └── index.html # Frontend entry page and static assets
├── config/ # Runtime configuration directory (contains config.json)
├── data/ # Data storage directory
├── logs/ # Log file directory (logs split by day)
└── tmp/ # Temporary file directory (contains the app.sock socket file)App deployment and data separation
Inside GM Desktop, micro-apps are installed and run directly on the target Linux server. For standardized management and system security, GM Desktop uses /.__gmssh as the root workspace.
On top of that, GM Desktop enforces strict physical separation of programs and data:
/.__gmssh/
├── plugin/{组织名}/{应用名}/ # [App install directory] holds the binary, frontend code, templates, and the temporary socket
└── data/plugin/{组织名}/{应用名}/ # [App data directory] holds persistent app data (such as SQLite, user files, persistent caches)Why separate programs from data?
- Protect user data: if the data or database a user generates is stored in the app install directory, uninstalling or upgrading the micro-app clears that directory and the data is lost by accident.
- Smooth upgrades and rollbacks: when a micro-app is updated, the platform only needs to safely overwrite the program files in the install directory while the user data directory stays intact, so upgrades really are lossless.
- Ready out of the box: the Go backend scaffold already exposes the data directory path constant through
common.DataAppPathininternal/common/constant.go. When you write code that persists data locally, make sure the data is written under that path.
- App install directory:
/.__gmssh/plugin/{组织名}/{应用名}/ - App data directory:
/.__gmssh/data/plugin/{组织名}/{应用名}/ - Socket communication path:
/.__gmssh/plugin/{组织名}/{应用名}/tmp/app.sock
