# Inventory2026 Architecture

Inventory2026 is a self-hosted, local-first inventory application for 10,000+ parts across warehouses and trucks.

## Design decisions

- Committed stock is never allowed to go negative.
- Offline work is allowed as pending operations and validated when the device reconnects.
- The immutable inventory ledger is the audit source of truth.
- Current stock is stored in `inventory_balances` for fast mobile and desktop reads.
- Every multi-line operation is grouped by `operation_id`.
- Bills of materials are versioned so old assemblies keep their historical recipe.
- Weighted average cost is used for v1, while purchase lots are retained for future FIFO support.
- Barcodes are generated internally and stored as aliases.
- QuickBooks Online and Square are integration targets, but they are not inventory authorities.

## Services

- `apps/api`: Fastify API, PostgreSQL access, auth sessions, inventory operations, exports, sync, and integration stubs.
- `apps/web`: Next.js PWA with offline queue, scan-first mobile workflows, reports, and labels.
- `packages/shared`: Shared TypeScript schemas and constants.

## Deployment

The default deployment target is an InMotionHosting VPS running Docker Compose. Put Caddy or another reverse proxy in front of the app for HTTPS.
