This document is the master plan for creating a self-service vending machine and checkout system. It serves as the single source of truth for the project's design, architecture, and implementation plan.
The project consists of three interconnected components: a Server, a Manage App (for the store owner), and a Kiosk App (for customer self-checkout). The system is designed to run within a local network.
The primary goal is to enable a small supermarket to streamline product price input and allow customers to perform self-checkout by scanning barcodes and completing payments via QR codes.
- Product Management: The store owner must be able to easily add, update, and manage product information (barcode, name, price).
- Payment QR Code: The owner must be able to upload their store's payment QR code.
- Self-Checkout: Customers must be able to scan product barcodes, see a running total, and be presented with the QR code for payment.
- Transaction Confirmation: The owner must have a secure way to confirm that a customer's payment has been received.
- Local Network: All components must operate reliably on a local Wi-Fi network.
- Hardware & OS:
- The Kiosk App is primarily for a large Samsung OLED tablet running Android 11.
- The UI must be optimized to conserve the lifespan of the OLED screen (e.g., dark mode).
- The Flutter apps must support
armv7aandarmv8aarchitectures.
The system is a three-part client-server architecture operating on a local network.
graph TD
subgraph "Local Network"
A[Kiosk App<br>(Samsung OLED Tablet)] <--> C(Server<br>(Rust / actix-web))
B[Manage App<br>(Owner's Device)] <--> C
end
C --> D[External Product API<br>(e.g., Barcode Lookup)]
- Technology: Rust with the
actix-webframework. This provides a high-performance, safe, and concurrent backend. - Role: Acts as the central data hub and business logic processor.
- Data Storage: SQLite database accessed via the
rusqlitecrate for robust, transactional SQL capabilities. - API Endpoints:
/products(GET, POST, PUT): For managing product data./products/{barcode}(GET): Retrieves a single product by its barcode./payment_qr(GET, POST): For retrieving and uploading the store's payment QR code.
- External API Integration: Will handle calling external product lookup APIs using the
reqwestcrate. - Data Models (Rust):
use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] struct Product { barcode: String, name: String, price: f64, last_updated: i64, // Unix timestamp } #[derive(Serialize, Deserialize)] struct PaymentQrCode { id: String, data: String, // Base64 encoded image last_updated: i64, // Unix timestamp }
- Technology: Flutter.
- Role: Allows the store owner to manage product data.
- Features:
- Barcode Scanning: Uses
mobile_scannerto scan product UPCs. - Product Management: Sends product data to the server and allows manual input/price updates.
- QR Code Management: Allows the owner to upload their payment QR code image to the server.
- Local Caching: Uses
hivefor local caching of settings.
- Barcode Scanning: Uses
- Technology: Flutter (optimized for Android 11).
- Role: Customer-facing self-checkout interface.
- Features:
- Continuous Scanning: Uses
mobile_scannerfor continuous barcode detection. The app must remain in the foreground for camera access. - UI: OLED-optimized dark theme. Displays a list of scanned items and a running total.
- Payment Flow: A "Pay" button transitions to a screen that displays the store's QR code (fetched from the server) using the
qr_flutterpackage. - Admin Confirmation: A hidden, PIN-protected area for the owner to confirm payment and reset the transaction.
- Local Caching: Uses
hiveto cache product data for performance and resilience.
- Continuous Scanning: Uses
- Bluetooth Sync vs. Central Server: A central server was chosen over Bluetooth for data synchronization due to its superior reliability, scalability, and simplicity for data exchange using standard HTTP protocols.
- Direct Payment vs. QR Code: Displaying a merchant QR code was chosen over direct payment terminal integration to dramatically reduce complexity, cost, and PCI compliance overhead.
This section will be updated chronologically after each phase to log actions, learnings, and deviations.
After completing a task, if you added any TODOs to the code or didn't fully implement anything, make sure to add new tasks to this plan so that you can come back and complete them later.
- Server: Create a new binary Rust project in the
Server/directory usingcargo new Server --bin. - Manager App: Create a new, empty Flutter project in the
Manager/directory usingflutter create --template=app --empty. - Kiosk App: Create a new, empty Flutter project in the
Kiosk/directory usingflutter create --template=app --empty. - Update Project Metadata:
- For
ManagerandKioskapps, updatepubspec.yaml(description,version: 0.1.0). - For the
Server, updateCargo.tomlwithdescriptionandversion = "0.1.0".
- For
- Update
README.md: For all three projects, update theREADME.mdfile with a short placeholder description. - Create
CHANGELOG.md: For all three projects, create aCHANGELOG.mdfile with an initial entry for version0.1.0. - Initial Commit: Commit the initial empty shell of all three projects to the current branch (
feat/vending-machine-app).
- Dependencies: Add
actix-web,serde(withderivefeature),rusqlite, andreqwestto theServer'sCargo.toml. - Data Models: Define the Rust data models (
Product,PaymentQrCode) using structs and deriveSerialize/Deserialize. - Database Setup: Create a module to handle the SQLite database connection using
rusqliteand initialize tables. - API Endpoints: Implement the API endpoints (
/products,/products/{barcode},/payment_qr) usingactix-web. - External API Logic: Implement logic to call an external product lookup API using
reqwest. - Unit Tests: Write basic unit tests for the API endpoint handlers.
- Dependencies: Add
mobile_scanner,http, andhiveto theManagerapp'spubspec.yaml. - API Service: Create a service class to handle all HTTP communication with the
Server. - UI: Build screens for listing products, adding/editing products (with barcode scanning), and uploading the payment QR code.
- Local Caching: Use
hiveto cache product data locally.
- Dependencies: Add
mobile_scanner,qr_flutter,http, andhiveto theKioskapp'spubspec.yaml. - OLED Theme: Implement an OLED-friendly dark theme.
- API Service: Create a service class for server communication.
- UI: Implement the main scanning screen, the payment QR code display screen, and the hidden admin PIN/confirmation functionality.
-
README.md: Create a comprehensiveREADME.mdfile for each of the three projects. -
GEMINI.md: Create aGEMINI.mdfile in the project's root describing the overall application and architecture. - Final Review: Ask for a final review from the user.
At the end of each phase, perform the following steps:
- Create/modify unit tests for the code added or modified.
- For Flutter: Run
dart fix --applyandflutter analyze. - For Rust: Run
cargo fixandcargo check/cargo clippy. - Run any automated tests (
flutter testorcargo test). - For Flutter: Run
dart format .. - For Rust: Run
cargo fmt. - Re-read this
constitution.mdfile to check for deviations. - Update this
constitution.mdfile (Journal, checkboxes). - Use
git diffto verify changes and create a suitable commit message for user approval. - Wait for approval before committing.
- After committing, use
hot_reloadif applicable.
- Rust Web Server: actix-web, rusqlite
- Flutter Barcode Scanning: mobile_scanner
- Flutter Local Database: Hive
- Flutter Permissions: permission_handler
- Flutter QR Code Display: qr_flutter