How aysilsimgekaracan/smart-shopping-cart-system works
Project Type and Purpose
• This is a full-stack mobile application built with React Native (Expo), designed to provide a “smart shopping cart” experience by combining real-time object detection (YOLOv5 via Roboflow’s Hosted API) with Firebase backend services (Authentication and Cloud Firestore).
File Structure for Architectural Clues
• Top-level “SmartCart” directory contains platform folders (android/, ios/), JS/Expo config (App.js, index.js, babel.config.js, metro.config.js), and a src/ subdirectory.
• src/Router.js: defines navigation flow (React Navigation).
• src/components, src/containers, and src/screens follow a container/presentation pattern—business logic in containers, UI in screens/components.
• src/configs/firebaseConfig.js: initializes Firebase services.
• No custom backend server: app directly uses Firebase REST/SDK and calls Roboflow’s HTTP API.
README for Additional Insights
• Authentication: Firebase Auth for Sign In/Sign Up.
• Database: Cloud Firestore with three collections—products, orders, and orderDetails.
• Frame Detection: Expo Camera captures images every 2s, calls Roboflow Hosted API, maps detection results to Firestore product records.
Main Components
a. Mobile Application (React Native / Expo)
• UI Layer: Screens, Navigation Router, Components
• Business Logic Layer:
– Frame Capture Service (invokes Expo Camera)
– Detection Processor (packages frame, sends HTTP request)
– Firestore Client (CRUD operations on products, orders, orderDetails)
– Auth Client (interface to Firebase Auth)
b. External Detection Service
• Roboflow Hosted YOLOv5 API
c. Firebase Backend
• Firebase Authentication Service
• Firebase Cloud Firestore Database
d. (Optional) Device Hardware
Relationships and Data Flows
• On App Start:
1. User authenticates via Firebase Auth → Auth Token
2. Auth Token allows Firestore reads/writes
• Home Screen: Firestore read of products collection → populate product list
• Cart Screen (Frame Detection Loop):
a. Expo Camera capture → takePictureAsync()
c. For each detected class ID: Firestore read products/{id} → obtain name, price, image URL
d. Update Cart UI in real time
• Checkout Flow:
• On Payment confirmation: write new document to orders (general info) and batch write to orderDetails (line items)
Architectural Patterns and Principles
• Layered Architecture: Presentation → Business Logic → Service Adapters → External Services
• Separation of Concerns:
• UI screens vs container logic vs service modules
• Config vs code
• Event-driven / asynchronous flows in frame detection loop
• Client-driven backend (no custom server)