# ronaldkwan93/cafe_on_click architecture

> Architecture diagram of the GitHub repository ronaldkwan93/cafe_on_click, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ronaldkwan93/cafe_on_click
- Repository: https://github.com/ronaldkwan93/cafe_on_click

## Overview

##### Project type and purpose
- This is a single‐page e-commerce frontend built with React.js (via Vite) and styled with SASS modules.
- It has no separate backend service; instead it uses Firebase/Firestore as a BaaS (Backend-as-a-Service).

##### File structure
- Top level:
- vite.config.js, package.json, eslint.config.js – build and linting configs
- firebase.js – initializes Firebase SDK (Firestore)
- src folder:
- components/ – reusable UI pieces (CartItem, CartModal, FeatureSection, Footer, InputBar, Menu, NavBar, ProductCard, ProductModal)
- pages/ – page‐scoped views (Main page, Cart page)
- context/CartContext.jsx – React Context for cart state & actions
- services/CafeServiceProvider.js – abstraction over Firestore reads/writes
- App.jsx + main.jsx – root setup (<App> wrapped in CartContext provider)

##### README for additional insights
- Describes core features (product modal, cart modal and page, favorites).

##### Elements
- Blue for client‐side components
- Green for service/data layer
- Orange for external/third‐party (Firestore, Hosting)

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["Browser (User)"]:::external

    subgraph "React SPA (Vite)"
        Root["React SPA Root"]:::frontend
        subgraph "UI Components"
            CartItem["CartItem"]:::frontend
            CartModal["CartModal"]:::frontend
            FeatureSection["FeatureSection"]:::frontend
            Footer["Footer"]:::frontend
            InputBar["InputBar"]:::frontend
            Menu["Menu"]:::frontend
            NavBar["NavBar"]:::frontend
            ProductCard["ProductCard"]:::frontend
            ProductModal["ProductModal"]:::frontend
        end
        subgraph "Pages"
            MainPage["Main Page"]:::frontend
            CartPage["Cart Page"]:::frontend
        end
        CartCtx["CartContext"]:::frontend
        Service["CafeServiceProvider"]:::service
    end

    Firestore["Firebase/Firestore (Database)"]:::external
    Hosting["Static Hosting (CDN)"]:::external
    ViteConfig["Build & Lint Configs"]:::frontend

    User -->|"loads SPA"| Root
    Root -->|"bootstraps UI"| NavBar
    NavBar -->|"navigate"| MainPage
    MainPage -->|"renders"| FeatureSection
    FeatureSection -->|"displays"| ProductCard
    ProductCard -->|"addToCart()"| CartCtx
    InputBar -->|"search()"| Service
    CartModal -->|"dispatch cart actions"| CartCtx
    CartPage -->|"view cart"| CartCtx
    CartCtx -->|"getProducts(), updateCart()"| Service
    Service -->|"read/write"| Firestore
    Firestore -->|"respond data"| Service
    ViteConfig -->|"deploy artifacts"| Hosting

    click Root "https://github.com/ronaldkwan93/cafe_on_click/blob/main/index.html"
    click Root "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/main.jsx"
    click Root "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/App.jsx"
    click Root "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/App.css"
    click CartCtx "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/context/CartContext.jsx"
    click Service "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/services/CafeServiceProvider.js"
    click CartItem "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/CartItem/CartItem.jsx"
    click CartModal "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/CartModal/CartModal.jsx"
    click FeatureSection "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/FeatureSection/FeatureSection.jsx"
    click Footer "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/Footer/Footer.jsx"
    click InputBar "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/InputBar/InputBar.jsx"
    click Menu "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/Menu/Menu.jsx"
    click NavBar "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/NavBar/NavBar.jsx"
    click ProductCard "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/ProductCard/ProductCard.jsx"
    click ProductModal "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/components/ProductModal/ComponentModal.jsx"
    click MainPage "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/pages/main/Main.jsx"
    click CartPage "https://github.com/ronaldkwan93/cafe_on_click/blob/main/src/pages/cart/Cart.jsx"
    click ViteConfig "https://github.com/ronaldkwan93/cafe_on_click/blob/main/vite.config.js"
    click ViteConfig "https://github.com/ronaldkwan93/cafe_on_click/blob/main/package.json"
    click ViteConfig "https://github.com/ronaldkwan93/cafe_on_click/blob/main/eslint.config.js"

    classDef frontend fill:#AED6F1,stroke:#1F618D,color:#1B2631
    classDef service fill:#A9DFBF,stroke:#196F3D,color:#145A32
    classDef external fill:#F5CBA7,stroke:#B9770E,color:#7D6608
```
