¥99.90
One-time template price with installation and customization
One-click private deployment after purchase, details Live previewDeployment Guide
The CNC Equipment Inspection & Repair System · 精工巡修 (CnCInspect) is a single-container deployment: one Bun + ElysiaJS process serves both /api and the front-end build, and the only port it exposes is 8080. The default database is SQLite (a single file under /app/data in the container); MySQL 8 and PostgreSQL are supported too. The package already ships the build artifacts, so the image only runs them and never compiles.
1. Five-Minute Deployment
| Item | Requirement |
|---|---|
| Docker | 20.10 or later, with the docker compose subcommand |
| Resources | 0.5 CPU core / 1 GB memory / 20 GB disk |
| Port | Host port 8080 must be free |
| Replicas | Exactly 1 (single SQLite file) |
docker compose up -d
Open http://localhost:8080. The first start migrates the schema, creates the tables, creates the administrator, and — with an empty database — writes the demo data (3 workshops, 16 machines, 4 checklist standards, 12 inspection plans, and repair orders in every status). The demo owner admin@example.com / Admin@123456 is exactly the default of SUPER_ADMIN_EMAIL / SUPER_ADMIN_PASSWORD.
The first sign-in always forces a password change. The seeded administrator carries mustChangePassword=true, so admin@example.com lands on the change-password page and only reaches the workspace after setting a new password (once only). The real five-minute path is therefore: docker compose up -d → open 8080 → sign in with the default password → set a new one → workspace.
Equivalent without compose:
docker build -t cncinspect:1.1.0 .
docker run -d --name cncinspect --restart unless-stopped \
-p 8080:8080 -v cncinspect-data:/app/data \
-e JWT_SECRET='replace with 32 or more random characters' cncinspect:1.1.0
The host port may be remapped; inside the container it is always 8080. The -v mount of /app/data is mandatory — without it, deleting the container loses the data. Supply SUPER_ADMIN_* before the first start.
2. Container Responsibilities
| Container | Listens on | Public | Role |
|---|---|---|---|
app |
8080 |
yes (point the reverse proxy here) | ElysiaJS serves /api/* and hosts the front-end dist static site |
The image holds only four directories: /app/server (apps/api/out, started with bun server/index.js), /app/public (apps/web/dist, i.e. PUBLIC_DIR), /app/drizzle (apps/api/drizzle, i.e. MIGRATIONS_DIR) and /app/data (the mounted volume). The startup order is fixed: migrate first, then listen. The port comes from PORT (baked to 8080 in the image), the bind address from BIND_HOST (default 0.0.0.0).
3. How Front End and Back End Meet
The front end uses HashRouter (pages live under #/...), so a refresh only requests index.html and no deep-link fallback is needed; everything except /api/* and /config.js is served statically. The API mode is injected at runtime, not as a build-time constant. GET /config.js returns:
window.__IMX_CONFIG__ = {"apiMode":"http","apiBase":"/api"};
apiMode=httptalks to the real API, usingapiBaseas the prefix;apiMode=mockreturns themockDatain the code and sends no request at all (demo only).- Both values are decided by
PUBLIC_API_MODE(defaulthttp) andPUBLIC_API_BASE(default/api); restart the container after changing them. The response carriesno-store.
Why the front end cannot probe the back end to pick the mode: the mock branch sends no request, and without mockData it fails at once — the page drops into a blanket "failed to load" state rather than degrading to the real API. The server has to announce the mode; the front end only reads window.__IMX_CONFIG__.
Injection therefore happens at the request entry, before route matching; otherwise the static config.js in the build would be claimed by the static plugin first. index.html is no-store for the same reason: after a redeploy, old HTML would reference chunks that no longer exist, and the browser reports Failed to fetch dynamically imported module.
4. All Environment Variables
This table covers every variable the code actually reads (env.ts, index.ts, app.ts, db/migrate.ts, ai/config.ts); each default is the code's fallback.
| Variable | Default | Required | Description |
|---|---|---|---|
PORT |
3000 (local development only), 8080 inside the image |
no | Listening port |
BIND_HOST |
0.0.0.0 |
no | Bind address, injected by the platform per deployment |
NODE_ENV |
development, production inside the image |
no | Only production serves the front-end build |
JWT_SECRET |
dev-secret-change-me |
required in production | JWT signing secret; replace it with a strong random value |
DB_DRIVER |
sqlite |
no | sqlite / mysql (MySQL 8) / postgres |
DATABASE_URL |
./data/sqlite.db, /app/data/sqlite.db in the container |
no | SQLite path or connection string |
PUBLIC_DIR |
./public, /app/public in the container |
no | Front-end build directory |
CORS_ORIGIN |
* |
no | Allowed cross-origin origins |
SUPER_ADMIN_EMAIL |
admin@example.com |
recommended to change | Email of the first administrator |
SUPER_ADMIN_NAME |
Equipment Manager (seeded as the Chinese title) | no | Display name of the administrator |
SUPER_ADMIN_PASSWORD |
Admin@123456 |
must be changed in production | Initial administrator password |
DEMO_INSPECTOR_EMAIL |
inspector@example.com |
no | Demo inspector email |
DEMO_INSPECTOR_NAME |
Inspector Wang (seeded as a Chinese name) | no | Demo inspector display name |
DEMO_TECHNICIAN_EMAIL |
technician@example.com |
no | Demo technician email |
DEMO_TECHNICIAN_NAME |
Technician Li (seeded as a Chinese name) | no | Demo technician display name |
DEMO_PASSWORD |
Demo@123456 |
no | Password used when the demo accounts are created |
DEMO_SEED |
unset means it runs; only false turns it off |
no | Whether the business demo data is written |
MIGRATIONS_DIR |
apps/api/drizzle, /app/drizzle in the container |
no | Migration SQL directory |
PUBLIC_API_MODE |
http |
no | http (deployment) / mock (demo) |
PUBLIC_API_BASE |
/api |
no | Front-end request prefix, written into /config.js |
AI_PROVIDER |
openai |
no | Provider of the built-in assistant |
AI_API_KEY |
empty | no | Assistant key; when empty, the provider's own variable is read |
AI_BASE_URL |
empty | required in some cases | Custom gateway address; required for compatible |
AI_MODEL |
empty | required in some cases | Model name; required for openrouter / azure / gateway |
AI_CAPABILITIES |
empty | no | Overrides the default capabilities: text,image,file,tools |
OPENAI_BASE_URL |
empty | no | Fallback address used when AI_BASE_URL is empty |
There are 16 further per-provider key variables (AI_PROVIDER=openai reads OPENAI_API_KEY, the others follow the same pattern, e.g. DEEPSEEK_API_KEY); fill in only the one you enable.
JWT_SECRETmust be changed before going live, and then left alone — changing it invalidates every session already issued.SUPER_ADMIN_PASSWORDis used only when the account is first created; an existing account with that email is never overwritten.composepasses through only the variables underenvironment:, and this package already passes each one through:export JWT_SECRET=...on the host, or put it in the.envbesidedocker-compose.yml, anddocker compose up -dcarries it into the container (JWT_SECRET: ${JWT_SECRET:-dev-secret-change-me}; leave it unset and the source default applies). A platform deployment injects them from the manifestenv.- The image
ENVdeclares only what this template really reads (PORT/BIND_HOST/PUBLIC_DIR/DB_DRIVER/DATABASE_URL/MIGRATIONS_DIR) — no extraUPLOAD_DIR/LOG_LEVEL/STORAGE_DRIVER/MAIL_PROVIDER/SMS_PROVIDER. With noAI_*configured,POST /api/ai/streamreturns 503; everything else works.
5. Local Development (Not Deployment)
bun install
bun run dev
| Command | What it does |
|---|---|
bun run dev |
Starts both ends in parallel; the front end defaults to mock (.env.development) |
bun run dev:http |
Front end hits the real API (.env.http); pair it with bun run dev:api |
bun run dev:web / bun run dev:api |
Starts only one of the two ends |
bun test |
Unit tests (currently 123 passing, 421 assertions) |
bun run check |
Type checks plus the design / i18n / permission self-checks |
bun run db:generate |
Regenerates migrations after a schema change |
Development ports are api 3000 and web 5173 — local development only, never part of a deployment. Vite proxies /api and /upload to http://127.0.0.1:3000; if 3000 is taken, set VITE_API_PROXY and restart Vite. The back end serves the static build only when NODE_ENV=production, so locally you open 5173.
6. Data and Backups
- The default SQLite file is
/app/data/sqlite.dbinside the container, with WAL and foreign keys enabled;docker-compose.ymldeclares the named volumeapp-datamounted at/app/data, so a rebuilt container loses nothing; with a baredocker run, mount it yourself. - Migrations run automatically when the container starts, reading the
sqlite/mysql/postgresdirectories underMIGRATIONS_DIR, and are idempotent. - A backup is a copy of
/app/data; copying while stopped is safest:
docker compose stop app
docker cp "$(docker compose ps -aq app)":/app/data ./cncinspect-data-backup
docker compose start app
Restore: stop the container → copy the backup back over /app/data → start it (the startup migration fills in missing tables). The in-app "Backup and Export" only exports business data as JSON and cannot replace a full database backup.
Switching to MySQL 8 / PostgreSQL: set DB_DRIVER and an explicit DATABASE_URL. Each dialect's migrations are generated separately, so after a schema change run bun run db:generate into the matching dialect directory and ship it with the image; back up with mysqldump / pg_dump instead.
7. Reverse Proxy and HTTPS
Both ends share one domain, so location / forwards the pages and /api together to 8080; only the SSE endpoint /api/ai/stream needs its own block with buffering off:
server {
listen 443 ssl;
server_name cnc.example.com;
client_max_body_size 20m;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
}
# The assistant streams over SSE; buffering must be off or text arrives only at the end
location /api/ai/stream {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_buffering off;
proxy_read_timeout 600s;
}
}
Keep client_max_body_size generous (the assistant may carry attachments). HTTPS terminates at the proxy; inside the container it stays plain HTTP on 8080. index.html and /config.js must not be cached, while hashed assets/* can be cached for a long time.
8. Upgrading
docker compose stop app
docker cp "$(docker compose ps -aq app)":/app/data ./pre-upgrade-data # back up first
docker compose up -d --build
curl -s http://127.0.0.1:8080/api/health
The container must be restarted after the artifacts are replaced. The static file table is built once at startup (alwaysStatic); copy a new dist over /app/public without restarting and the process still looks things up in the old listing — a blank page and 404s on old chunks, not a broken build. On a platform deployment, replace the image or upload the package again.
9. Troubleshooting
| Symptom | Look at first | Cause | Fix |
|---|---|---|---|
8080 unreachable |
docker compose ps, logs app |
Not up / port taken / not built | Read the logs; remap the host port |
| healthcheck unhealthy | curl localhost:8080/api/health, migration logs |
Migration failed / /app/data not writable / wrong PUBLIC_DIR |
Fix DATABASE_URL and volume permissions; check /app/public |
| Pages open, no data | curl localhost:8080/config.js |
"apiMode":"mock" — wrong mode |
Remove PUBLIC_API_MODE=mock, restart |
| 401 after sign-in | Authorization header present; JWT_SECRET unchanged |
Token expired / secret changed / account disabled | Sign in again; pin JWT_SECRET; check the member's status |
| Still the old UI | startedAt, features in /api/health |
Not restarted, or an old image runs | docker compose restart app |
| Garbled document names | Encoding flag on names in the package | System tar writes names in the local code page without the UTF-8 flag |
Repack with the package's script; unpack as UTF-8 |
10. Packaging and Uploading
bun run pack:upload
It is equivalent to running check → check:i18n → test → build → check:dist → pack → verify:upload in order: test runs the unit tests (123 at the time of writing), build produces apps/api/out and apps/web/dist, check:dist must be http (it reads apiMode from apps/web/dist/.build-meta.json), pack assembles the package according to the upload rules (Python zipfile, so non-ASCII file names carry the UTF-8 flag), and verify:upload runs 35 in-package checks — only an all-green run may be uploaded.
The package must contain apps/web/dist (production build), apps/api/out/index.js, apps/api/drizzle, Dockerfile, docker-compose.yml, intematrix.deploy.json and docs/; it must not contain node_modules, data/, a real .env, logs or .db files.
11. Redeploying After Customization
| What changed | What to rerun |
|---|---|
| Front-end pages, styles or copy only | bun run check → bun run build → restart the container |
| Back-end endpoints or business rules only | bun run check → bun test → bun run build → restart the container |
| Database schema | bun run db:generate (generates into the DB_DRIVER dialect subdirectory of apps/api/drizzle/) → bun run build → restart (migrations run automatically; do not delete the volume) |
| Dependency versions | bun install on the build machine → bun run build → restart; the image installs no dependencies |
| Brand name or logo letter only | No rebuild: sign in and change it under System Settings → App Info |
Dockerfile / compose |
docker compose up -d --build |
One check proves it all: curl -s http://localhost:8080/api/health — is startedAt newer, and did features gain any capability?
12. Domain Conventions
- The same template gets deployed many times, so never hard-code a domain, callback address or absolute link in code or configuration.
- The platform assigns a domain per deployment id and injects
HOST(the public domain) andBIND_HOST(the bind address); this template reads onlyBIND_HOSTand uses relative public links. - The reverse proxy binds the domain with
server_name; the container always faces0.0.0.0:8080. On a same-domain deployment keepCORS_ORIGINat*.
13. Health Self-Report
curl -s http://localhost:8080/api/health
{"status":"ok","service":"api","version":"1.1.0",
"features":["auth.login","auth.me","… 22 in total …"],
"startedAt":"2026-01-01T00:00:00.000Z","timestamp":"2026-01-01T00:00:00.000Z"}
features is a hand-maintained list of 22 capabilities: auth.login, auth.me, auth.change-password, users.members, users.roles, users.reset-password, app.identity.read, app.identity.write, dashboard.summary, equipment.list, equipment.detail, equipment.write, inspection.plans, inspection.tasks, inspection.execute, repair.create, repair.dispatch, repair.handle, repair.accept, report.read, settings.dictionaries, ai.stream.
- On a 404, a blank page or a missing feature, look here first: the target capability name is absent → an old back end is running, redeploy; the name is there but the endpoint still 404s → only then is it a code problem.
startedAtis written once when the module loads and changes on every restart; when investigating "my change did not take effect", check whether it moved, then whetherfeaturesgained entries.- The platform probes liveness on
healthcheck.pathinintematrix.deploy.json(/api/health), timeout 60 seconds; in the container it runs every 30 seconds and is marked unhealthy after 3 consecutive failures.
Frequently asked questions
- What do I get after purchase?
- The full source code (web frontend + API backend), deployment documentation and an online preview. After purchase you can download it from "My Projects" and use it for your own product.
- Can it be deployed to my own server?
- The Web + API edition supports one-click private deployment, so data stays on your own infrastructure. Mini-program and App add-on packages are not one-click deployable.
- Can I get a refund?
- Orders whose code package has not been downloaded can request a refund through a support ticket. Once the code package has been downloaded, refunds are not supported.
- How do I reach support?
- Open "My Projects" and click "Support" to submit a ticket. Staff reply inside the ticket, and status changes are pushed as WeChat notifications.
