# Inventory PWA System Implementation Plan This document outlines the technical architecture for the unified Inventory System (FastAPI + PWA). ## Proposed Architecture ### 1. Backend Server (Linux / Docker) - **Framework:** Python + FastAPI - **Database:** SQLite (SQLAlchemy ORM) - **Key Modules:** - `Items / Interventions`: Standard CRUD logic. - `Audit`: Every payload that mutates data writes an immutable log row. - `AI-OCR`: Endpoint integrating Google Gemini Vision API (via Google AI Studio key) for complex label extraction onboarding. ### 2. Unified Web Application (PWA) - **Framework:** React + Next.js (or equivalent). - **Offline Engine:** Service Workers, IndexedDB local storage map. - **Desktop Mode:** Full width dashboard, management, and settings. - **Mobile Mode (Browser / Add to Homescreen):** Dedicated full-screen scanner using `html5-qrcode`. ### 3. AI Cost Strategy - **Routine Scans (Check-ins/Outs):** Client-side HTML5 barcode scanner. **Cost: $0.** - **Label Scanning (New Item):** Proxies a request to the Gemini API to parse the SFP label into JSON template fields. ## Implementation Phases - **Phase 1: Database & Backend Foundation** - SQLite schemas, User management, and Python API structures. - **Phase 2: Core Inventory API** - Endpoints to Add/Remove items, offline sync-merge logic, Audit triggers. - **Phase 3: The PWA Frontend** - PWA manifest, offline capabilities, UI scaffolding for Desktop/Mobile. - **Phase 4: Client-Side Scanning** - Integration of local JS barcode reading for routine stock scanning. - **Phase 5: Gemini AI Vision Integration** - Server-side Gemini API integration and the text-mapping frontend view.