Files
inventree-stock-tool/web/deploy/README.md
T
grabowski 379ed232df feat: Add SvelteKit web app with scan sessions and import queue
Replaces the Flask/Alpine web app with a SvelteKit 2 + Svelte 5 rewrite
under web/, built on adapter-node and Tailwind v4. Same shape as the
reference b4l budget app — no auth, stateless pass-through to InvenTree.

New "scan session" flow groups mass scans into a session with live
counters (scanned / succeeded / pending / failed). Unknown parts in
import mode are fed to a worker pool that spawns inventree-part-import
(IMPORT_CONCURRENCY, default 3, with 3-retry). Anything that can't be
resolved automatically — parse errors, missing qty, invalid location,
API errors, or imports that exhaust retries — drops into a Failures
panel with a per-item Fix dialog (edit fields / search existing part /
retry import). CSV export on the failure list.

Layout is two-column on lg+: scanner + activity on the left, pending
imports + failures on the right. Light-theme default. SSE on
/api/events streams session and import events to the client.

Barcode parser ported from the Python/JS versions and hardened for
Digi-Key MH10.8.2 barcodes both with and without GS separators (old
parser greedy-matched Q's digits and read "Q6" + "11ZPICK" as 611).
Import worker also now treats a subprocess failure followed by a
successful findPart as a success, so partial imports (part created but
a duplicate parameter trips the DB constraint) no longer land in the
Failures panel.

Deploy artifacts: systemd unit, nginx example (SSE-friendly), and a
step-by-step deploy/README. Requires inventree-part-import >= 1.9.2 on
the server for InvenTree 1.x API compatibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 15:58:57 +07:00

2.6 KiB
Raw Blame History

Deployment

Deploy target: Linux server, Node 20+, nginx fronting adapter-node on 127.0.0.1:3000, systemd managing the process. Python 3.10+ with inventree-part-import installed alongside Node — we shell out to it for unknown parts.

One-time setup

sudo adduser --system --group --home /opt/inventree-stock-tool stock-tool
sudo chown -R stock-tool:stock-tool /opt/inventree-stock-tool

# As the service user:
sudo -u stock-tool -H bash
cd /opt/inventree-stock-tool

# Python side
python3 -m venv .venv
source .venv/bin/activate
pip install "inventree-part-import>=1.9.2"   # 1.9.2+ required for InvenTree 1.x API
# configure inventree-part-import's suppliers at
# ~/.config/inventree-part-import/  (Digi-Key, Mouser, LCSC API keys)

# Node side — pushed via git or rsync into /opt/inventree-stock-tool
npm ci --omit=dev
npm run build

# Env
cp .env.example .env
$EDITOR .env

.env must contain at minimum INVENTREE_HOST, INVENTREE_TOKEN, and INVENTREE_PART_IMPORT_BIN=/opt/inventree-stock-tool/.venv/bin/inventree-part-import.

systemd

sudo cp deploy/inventree-stock-tool.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now inventree-stock-tool
sudo systemctl status inventree-stock-tool
journalctl -u inventree-stock-tool -f

Adjust User=, Group=, WorkingDirectory= in the unit file to match your setup. The unit pins INVENTREE_PART_IMPORT_BIN via .env — the PATH= line in the unit is a fallback for when the binary is on a regular bin directory.

nginx

sudo cp deploy/nginx.conf.example /etc/nginx/sites-available/stock-tool
sudo ln -s /etc/nginx/sites-available/stock-tool /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Then issue a cert:

sudo certbot --nginx -d stock-tool.your-domain.example.com

Updating

# on build server / laptop:
rsync -az --delete --exclude=node_modules --exclude=build \
  ./web/ stock-tool@host:/opt/inventree-stock-tool/

# on server:
sudo -u stock-tool -H bash
cd /opt/inventree-stock-tool
npm ci --omit=dev
npm run build
exit
sudo systemctl restart inventree-stock-tool

Tuning

  • IMPORT_CONCURRENCY (default 3) — number of concurrent inventree-part-import subprocesses. Bump up only if supplier APIs aren't rate-limiting you and InvenTree handles concurrent category/manufacturer writes cleanly. 34 is typically the sweet spot; higher values tend to produce 429s rather than speedups.
  • IMPORT_TIMEOUT_SEC (default 60) — per-attempt timeout. Raise if your supplier API is slow or the server cold-starts imports.