How almhtrf111312/hyperpos-companion works
1. Overall shape
- This is a cross-platform POS / inventory / accounting-style application built as a React + TypeScript front end, with native packaging for Android (Capacitor) and Windows desktop (Electron).
- The repo also includes a Supabase backend for authentication, persistence, and serverless business actions.
2. Presentation layer
- src/pages/* holds the route-level screens such as POS, Dashboard, Products, Purchases, Reports, Settings, Login, and admin-oriented pages like BossPanel.
- src/components/* contains reusable UI and feature components, split into clear feature areas: auth, license, layout, POS, barcode/camera, dashboard, reports, settings, onboarding, and setup.
- src/components/ui/* is the shared design-system layer, based on shadcn-style primitives and Tailwind.
3. Application shell and navigation
- src/App.tsx, src/main.tsx, and src/components/layout/MainLayout.tsx define the top-level app shell, navigation, and page composition.
- Layout concerns are centralized in sidebar, notification, sync, and network-status components, which suggests a persistent shell around many feature pages rather than isolated page apps.
4. Domain/data layer
- The business data model is mostly implemented in src/lib/*-store.ts modules such as products, invoices, customers, debts, expenses, partners, cashbox, profits, and maintenance.
- This points to a local domain-store approach where features read/write through dedicated store modules instead of accessing the backend directly from UI components.
5. Offline-first persistence and synchronization
- The presence of indexeddb-cache, safe-storage, secure-storage, transaction-lock, sync-queue, sync-history, and local-auto-backup shows an explicit offline-capable client architecture.
- src/providers/CloudSyncProvider.tsx, src/hooks/use-cloud-sync.tsx, and src/hooks/use-realtime-sync.tsx appear to coordinate local writes, queued outbound sync, and remote reconciliation.
- The src/lib/cloud/* modules split sync by business entity, so cloud writes are organized by domain object rather than by generic CRUD.
6. Backend and server-side boundary
- Supabase is the main backend boundary: src/integrations/supabase/client.ts, generated types, supabase/migrations/*, and supabase/functions/*.
- The edge functions cover license and user administration, account creation, password changes, device login/reset, activation validation, trial start, and help assistant flows.
- This means some business rules are enforced server-side, especially around access control, licensing, and user/device lifecycle.
7. Authentication, roles, device binding, and licensing
- The app has a dedicated auth and security layer with use-auth, use-user-role, use-device-binding, ProtectedRoute, RoleGuard, and device-blocked screens.
- Licensing is treated as a first-class subsystem: LicenseGuard, activation screens, trial banners, offline protection, and encrypted-data messaging imply the app can restrict features or lock access based on license state.
- This is important for diagramming because auth/licensing sits between navigation and business pages, not as an afterthought.
8. Native and hardware integrations
- Barcode scanning is abstracted behind multiple implementations: web scanning, offline scanning, and native ML Kit scanning.
- Camera support is similarly split between inline web camera and native preview.
- There are also native helpers for printing and sharing, which indicates the app relies on platform-specific capabilities for core workflows like POS checkout and document output.
9. Reporting and document generation
- src/components/reports/* and src/lib/reports/dataset-builder.ts suggest reports are built from shared datasets and then rendered into different report views.
- Export/output utilities include PDF, Excel, file download, print helpers, and localized font support, so reporting is not just screen-based; it feeds external documents and printable artifacts.
10. Settings, administration, and maintenance
- src/components/settings/* and pages like Settings, Cash Shifts, Warehouses, and Help show the app includes operational administration, not just transactional sales.
- Backup, archive, reset, diagnostics, themes, language, profile, and license management are all centralized in the settings area, which is likely where system-level workflows are surfaced.
11. Platform packaging
- Android packaging lives under android/ with Capacitor integration, while Electron packaging lives under electron/ with its own main process and error page.
- The repo also includes PWA-related assets like public/offline.html, which suggests a third delivery mode in the browser.
- This makes the architecture “single web codebase, multiple runtime shells.”
12. Build and release pipeline
- GitHub Actions workflows build APKs and Windows artifacts.
- Versioning and release files (version.json, version.txt, version bump scripts) imply a managed release process across app shells and backend-compatible clients.
- The repo therefore has both application architecture and packaging/release architecture that are worth showing separately in a diagram.
Main entry points: App.tsx App Root · products-store.ts Domain Stores · MainLayout.tsx Main Layout · main.tsx App Entry
Components 22
App Shell & UI
Route screens, shared layout, and reusable presentation components.
- App Entry · Bootstraps the web app and global providers.
src/main.tsx - App Root · Top-level routing and application composition.
src/App.tsx - Main Layout · Persistent sidebar, status, sync, and notification chrome.
src/components/layout/MainLayout.tsx - Pages · Major screens for POS, dashboard, catalog, accounting, admin, and settings.
src/pages/POS.tsx - Auth UI · Login, signup, reset, route protection, role and device gating.
src/components/auth/ProtectedRoute.tsx - License UI · Activation, trial, and encrypted-data access restrictions.
src/components/license/LicenseGuard.tsx - POS UI · Cart, scanning, product dialogs, and checkout helpers.
src/components/pos/CartPanel.tsx - Reports UI · Report shell, filters, charts, and operational reports.
src/components/reports/ReportShell.tsx - Settings UI · Profile, backup, theme, language, diagnostics, and license settings.
src/components/settings/LicenseManagement.tsx - UI Kit · Shared shadcn-style primitives and app-level UI building blocks.
src/components/ui/button.tsx
Domain & Offline Data
Local business stores, sync orchestration, and client persistence.
- Cloud Sync · Coordinates local writes, queued sync, and realtime reconciliation.
src/providers/CloudSyncProvider.tsx - Domain Stores · Products, invoices, customers, debts, expenses, partners, cashbox, and related state stores.
src/lib/products-store.ts - Offline Cache · IndexedDB, secure storage, locks, queue/history, and local backup.
src/lib/indexeddb-cache.ts - Report Data · Assembles reusable reporting datasets from the business model.
src/lib/reports/dataset-builder.ts
Supabase Backend
Auth, database boundary, and edge functions for licensing and admin actions.
- Supabase Client · Frontend client and generated types for Supabase access.
src/integrations/supabase/client.ts - Edge Functions · License, user, device, and help workflows enforced server-side.
supabase/functions/check-license/index.ts - Migrations · Supabase schema and data model migrations.
supabase/migrations/20260113225837_15aafe59-1e02-46fa-9124-b89c8de0425c.sql
Platform Shells
Native packaging and desktop/mobile runtime wrappers.
- Android Shell · Native Android wrapper and activity host.
android/app/src/main/java/com/flowpos/pro/MainActivity.java - Electron Shell · Desktop runtime main process and error page.
electron/main.js - PWA Assets · Offline page and browser delivery assets.
public/offline.html
Build & Release
Automation and versioning for cross-platform delivery.
- CI Build · GitHub Actions workflows for APK and Windows artifacts.
.github/workflows/build-apk.yml - Versioning · Version files and bump script used across builds and shells.
scripts/bump-version.js
Connections 25
- App Entry → App Root: mounts · Bootstraps routing and global app composition.
- App Root → Main Layout: wraps · Places major screens inside the persistent application shell.
- App Root → Pages: routes to · Route-level pages are the main screen layer.
- App Root → Auth UI: guards · Authentication and role/device access control protect routes.
- App Root → License UI: restricts · License state can block or gate access to features.
- Main Layout → POS UI: hosts · POS workflow lives inside the shared shell.
- Main Layout → Reports UI: hosts · Reporting screens use the common layout and chrome.
- Main Layout → Settings UI: hosts · Operational admin screens are surfaced in settings.
- POS UI → Domain Stores: reads/writes · Checkout and product workflows operate through domain stores.
- Pages → Domain Stores: uses · Business pages bind to the local store layer instead of direct backend CRUD.
- Cloud Sync → Domain Stores: syncs · Synchronizes local domain changes with the cloud boundary.
- Cloud Sync → Offline Cache: queues · Uses offline persistence, locks, and queue/history for resilient sync.
- Domain Stores → Offline Cache: persists · Stores read and write through local offline-capable storage.
- Reports UI → Report Data: renders · Report screens consume shared datasets.
- Report Data → Domain Stores: aggregates · Report datasets are derived from the business stores.
- Supabase Client → Migrations: accesses · Frontend client talks to the Supabase schema.
- Supabase Client → Edge Functions: invokes · Client calls edge functions for privileged server actions.
- Auth UI → Supabase Client: authenticates · Login and session flows depend on the backend client.
- License UI → Edge Functions: validates · License activation and checks are enforced by serverless actions.
- Android Shell → App Entry: hosts · Android wraps the same web app entry point.
- Electron Shell → App Entry: hosts · Electron desktop shell launches the shared web codebase.
- PWA Assets → App Entry: falls back to · Browser delivery includes offline-friendly assets.
- CI Build → Android Shell: builds · CI produces mobile artifacts for Android.
- CI Build → Electron Shell: builds · CI produces desktop artifacts for Windows/Electron.
- Versioning → CI Build: feeds · Version metadata and bump scripts support release automation.