# aysilsimgekaracan/smart-shopping-cart-system architecture

> Architecture diagram of the GitHub repository aysilsimgekaracan/smart-shopping-cart-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aysilsimgekaracan/smart-shopping-cart-system
- Repository: https://github.com/aysilsimgekaracan/smart-shopping-cart-system

## Overview

##### 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)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% On-Device Mobile App
    subgraph "On-Device (Mobile App)"
        direction TB
        MA["Mobile Application"]:::ondevice

        subgraph "UI Layer"
            direction TB
            Router["Router (React Navigation)"]:::ondevice
            Screens["Screens"]:::ondevice
            Components["Shared UI Components"]:::ondevice
        end

        subgraph "Business Logic Containers"
            direction TB
            Home["Home Container"]:::ondevice
            Cart["Cart Container"]:::ondevice
            Orders["Orders List Container"]:::ondevice
            OrderDetails["Order Details Container"]:::ondevice
            Payment["Payment Container"]:::ondevice
            OrderConfirmation["Order Confirmation Container"]:::ondevice
            Profile["Profile Container"]:::ondevice
            SignIn["Sign In Container"]:::ondevice
            SignUp["Sign Up Container"]:::ondevice
        end

        subgraph "Services & Utils"
            direction TB
            FirebaseConfig["Firebase Config"]:::ondevice
            Styles["Styles & Theme"]:::ondevice
            Hooks["Custom Hooks"]:::ondevice
            Assets["Assets (fonts, images)"]:::ondevice
        end

        MA --> Router
        Router --> Screens
        Router --> Components

        Screens --> Home
        Screens --> Cart
        Screens --> Orders
        Screens --> OrderDetails
        Screens --> Payment
        Screens --> OrderConfirmation
        Screens --> Profile
        Screens --> SignIn
        Screens --> SignUp

        Home -->|"read products"| FirebaseConfig
        Cart -->|"frame capture every 2s"| Cart
        Cart -->|"POST /detect"| Detection["Roboflow Detection Processor"]:::external
        Cart -->|"read product details"| FirebaseConfig
        Payment -->|"write orders, orderDetails"| FirebaseConfig
        SignIn -->|"authenticate"| FirebaseConfig
        SignUp -->|"authenticate"| FirebaseConfig
    end

    %% Cloud Services
    subgraph "Cloud Services"
        direction TB
        Auth["Firebase Authentication"]:::cloud
        Firestore["Firebase Cloud Firestore"]:::cloud
        Roboflow["Roboflow Hosted YOLOv5 API"]:::external
    end

    %% Relationships
    FirebaseConfig --> Auth
    FirebaseConfig --> Firestore
    Cart --> Roboflow
    Detection --> Roboflow
    Detection --> Cart

    %% Click Events
    click MA "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/tree/main/SmartCart/"
    click Screens "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/tree/main/SmartCart/src/screens/"
    click Router "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/Router.js"
    click Components "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/tree/main/SmartCart/src/components/"
    click Home "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/Home/Home.js"
    click Cart "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/Cart/Cart.js"
    click Orders "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/Orders/Orders.js"
    click OrderDetails "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/OrderDetails/OrderDetails.js"
    click Payment "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/Payment/Payment.js"
    click OrderConfirmation "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/OrderConfirmation/OrderConfirmation.js"
    click Profile "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/Profile/Profile.js"
    click SignIn "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/SignIn/SignIn.js"
    click SignUp "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/containers/SignUp/SignUp.js"
    click FirebaseConfig "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/configs/firebaseConfig.js"
    click Styles "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/tree/main/SmartCart/src/styles/"
    click Hooks "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/blob/main/SmartCart/src/hooks/useFonts.js"
    click Assets "https://github.com/aysilsimgekaracan/smart-shopping-cart-system/tree/main/SmartCart/src/assets/"

    %% Styles
    classDef ondevice fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef cloud fill:#D5F5E3,stroke:#28A745,stroke-width:1px
    classDef external fill:#FFF3CD,stroke:#E69500,stroke-width:1px,stroke-dasharray: 5 5
```
