Local setup
Each application is an independent repo with its own dependencies. You generally don’t need all four running to work on one, but the API is a dependency of the other three.
API (dg_smart_pos_api)
Section titled “API (dg_smart_pos_api)”composer installphp artisan serve # API on :8000composer dev # server + queue workers + Reverb WebSocket togetherDatabase setup:
php artisan migrate # central DB onlyphp artisan tenants:migrate # all tenant DBsQueue workers, needed for background jobs (run the ones relevant to what you’re working on):
php artisan queue:work --tries=3 --timeout=90php artisan queue:work central --queue=backups --tries=3 --timeout=90 # backup jobsphp artisan queue:work redis --queue=inventory-import --tries=2 --timeout=200 # CSV stock importphp artisan queue:work --queue=platform-migrations --tries=1 --timeout=3600 # platform migration backfillsphp artisan reverb:start --debug # WebSocket serverLinting and tests:
./vendor/bin/pint # PHP linter / auto-fixerphp artisan test # PHPUnit / PestPOS frontend (dg_smart_pos_frontend)
Section titled “POS frontend (dg_smart_pos_frontend)”Uses pnpm, not npm or yarn.
pnpm installpnpm run dev # SPA dev server on :3001pnpm run build # production buildpnpm run lint # ESLint auto-fixpnpm run test # Vitestpnpm run electron # Electron dev app (wraps the SPA)Needs VITE_TITAN_API pointing at the API (e.g. http://localhost:8000/api/), plus VITE_REVERB_* vars if you need live WebSocket updates locally.
On first run you’ll hit the tenant setup screen: enter a client code for a tenant that already exists in your central DB.
Admin (dg_smart_pos_admin)
Section titled “Admin (dg_smart_pos_admin)”pnpm installpnpm run dev # admin dev server on :3000pnpm run buildpnpm run lintNeeds VITE_TITAN_API_URL pointing at the API (no trailing slash). No tenant setup step, admin never operates as a tenant.
Storefront (dg_smart_pos_storefront)
Section titled “Storefront (dg_smart_pos_storefront)”Astro + Preact + Tailwind, deployed to Cloudflare (see wrangler.toml).
pnpm installpnpm run devpnpm run buildStorefront theming is driven by a theme_key per website (electronics or organics today) rather than by env var, see Storefront for how that works.
Electron desktop build
Section titled “Electron desktop build”The desktop app wraps the POS frontend SPA. Entry point: dg_smart_pos_frontend/electron/main.js. Thermal printing goes through IPC (electron-pos-printer). Build with:
pnpm run electron-buildAuto-updates pull from https://download.dg-smartpos.co.ke.