# Build an Inventory System in Lovable

- Tool: Lovable Prompts
- Last updated: June 2026

## TL;DR

Paste the starter prompt into Lovable Build mode and get a staff-only inventory tracker with SKUs, multi-location stock, a movement ledger, atomic stock decrements via a Postgres RPC, and color-coded low-stock badges. Build time is roughly one day. Expected credit burn is 100–180 credits on a Pro $25/mo plan.

## Frequently asked questions

### Why store a qty column separately from movements instead of always computing SUM(delta)?

Computing SUM(delta) for every product+location on every page load requires scanning the full movements table — fine at 1,000 rows, very slow at 1 million. The stock table with a materialized qty is your fast read path: O(1) lookup for current stock. The movements table is your audit trail and source of truth for reconciliation. The record_movement() RPC keeps both in sync atomically — you never compute from movements in the UI, you just display stock.qty.

### How do I prevent negative stock when two users sell the same SKU simultaneously?

The CHECK (qty >= 0) constraint on the stock table is your primary defense. When two concurrent sells of the last unit both reach record_movement(), the PostgreSQL row-level lock inside the UPSERT serializes them: one succeeds and the other hits the CHECK constraint with a 23514 error. Catch that error code in your UI and show 'Out of stock — this item was just sold by another team member'. Do not remove the constraint and do not rely solely on client-side checks.

### Can I use a barcode scanner from my phone?

Yes — follow-up #4 adds a /movements/quick-receipt route using @zxing/library that activates your phone's camera, decodes QR or 1D barcodes, looks up the SKU, and pre-fills a receipt form. Open the published app (not the preview) from your phone browser — the camera permission dialog appears on first use. On desktop, a text input fallback lets you type or paste SKU codes. No app install required.

### How do I import my existing inventory from a spreadsheet?

Follow-up #2 adds a CSV import route. Export your spreadsheet as CSV with columns: sku, name, unit, reorder_point, location_name, qty. Go to /import, drop in the file, review the per-row validation preview (green = valid, red = error with explanation), then click Confirm. The Edge Function validates all rows first, and only imports if every row passes — if row 47 fails, nothing is imported and you get a specific error for that row to fix.

### What if I have stock across 5 or more warehouses?

The schema handles unlimited locations from day one — the stock table is keyed by (product_id, location_id), so you can add a third, fourth, or tenth location from /locations and immediately record movements at that location. The /stock page's location filter pill lets you scope the view to a single location. The transfer follow-up (follow-up #3) adds an atomic transfer flow between any two locations.

### Should I sync this with Shopify or Square?

Follow-up #6 (in the brief) outlines a Shopify sync via the native Cloud App connector: an Edge Function polls Shopify inventory and reconciles each SKU via record_movement() with reason='adjustment'. This is appropriate when your online store sells the same physical SKUs as your Lovable system. For Square (POS), there's no native connector — you'd use the Square REST API from an Edge Function on a schedule. Both sync patterns work, but expect to spend 80–100 credits on the integration and ongoing maintenance when Shopify/Square change API formats.

### When should I upgrade to a real WMS like NetSuite or Fishbowl?

Upgrade when you need WMS-grade capabilities: pick paths, wave picking, multi-warehouse replenishment, lot/serial number tracking for FDA/ISO compliance, EDI integration with suppliers, or real-time POS integration across many terminals. At that point you're past $100K/year in inventory complexity and Lovable's 60-second Edge Function timeout and 500MB DB become real constraints. If your build outgrows this prompt kit and you need custom architecture, RapidDev builds production-grade Lovable apps at $13K-$25K — book a free 30-minute consultation at rapidevelopers.com.

---

Source: https://www.rapidevelopers.com/lovable-prompts/lovable-prompts-for-building-inventory-system
© RapidDev — https://www.rapidevelopers.com/lovable-prompts/lovable-prompts-for-building-inventory-system
