# mychelgarzon/meatshop architecture

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

- Interactive diagram: https://gitdiagram.com/mychelgarzon/meatshop
- Repository: https://github.com/mychelgarzon/meatshop

## Overview

##### Project type and purpose
- This is a full-stack (serverless) e-commerce frontend application built in React (with Vite), backed by a single AWS Lambda (or Firebase Cloud Function) for order processing.
- Purpose: Allow users to browse premium meat products, add/remove/update items in a shopping cart (Redux), and submit orders via a serverless function.

##### File structure
- Top-level:
- src/ : React application source
- lambda-function/ : serverless function code
- cypress/ : end-to-end tests
- .github/workflows/main.yml : CI/CD pipeline
- firebase.json & .firebaserc : Firebase hosting & functions config
- src/ organization:
- components/ : reusable UI pieces (Banner, Cart, ProductCard, etc.)
- routes/ : page containers (Home, About, ShoppingCart, Success, etc.)
- store/ : Redux slices (cartSlice.ts, userSlice.ts) + store.ts
- data/, assets/, helpers/, hooks/, layout/ : static data, utilities, layout, custom hooks
- lambda-function:
- index.js: handler for HTTP calls (e.g., order submission)
- package.json: runtime dependencies

##### Key insights from README
- React + Redux for cart management
- Instructions focus on running the dev server and installing dependencies; no deep architectural docs in README

##### Main components
a. User’s Browser (Client)
b. React SPA (static assets + Vite server in dev; pre-built files in production)
– UI Components → Redux Store → UI updates
– Data Module (data.ts) for product catalog
c. Serverless Function (lambda-function/index.js)
– Exposes an HTTP endpoint (e.g., /submitOrder)
d. Hosting & Deployment
– Firebase Hosting (or AWS S3 + CloudFront) serves the SPA
– Firebase Functions (or AWS Lambda) runs the serverless code
– GitHub Actions CI/CD pipeline automates build & deploy
e. External Integrations (if any)

##### Relationships & interactions
- User clicks “Add to cart” → React Component dispatches Redux action → cartSlice updates state → UI re-renders
- User clicks “Place Order” → SPA calls serverless endpoint via fetch/Axios → Lambda processes order → returns success/failure
- CI/CD: On push to main → GitHub Actions builds React app → deploys to Firebase Hosting → deploys lambda-function

##### Architectural patterns & principles
- Single-Page Application (SPA) with component-based UI
- Unidirectional data flow (Redux)
- Serverless (Function as a Service) for backend logic
- Static hosting for frontend, separate runtime for API
- Automated CI/CD for consistency

##### Essential details to capture
- Redux store slices (cartSlice, userSlice) as part of the state layer
- Key directories (src/components, src/routes) to reflect component hierarchy
- Hosting & function deployment config (firebase.json)
- CI/CD workflow triggers (.github/workflows/main.yml)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        User["User"]:::external
        SPA["React SPA"]:::client
    end

    %% SPA Internal Structure
    subgraph "SPA Internal" 
        direction TB
        subgraph "UI Components" 
            direction TB
            Banner["Banner"]:::client
            CartComp["Cart"]:::client
            ProductCard["ProductCard"]:::client
            Filters["Filters"]:::client
            ConfirmModal["Confirmation Modal"]:::client
            PlusBtn["PlusButton"]:::client
            MinusBtn["MinusButton"]:::client
        end
        subgraph "Page Routes"
            direction TB
            Home["Home"]:::client
            About["About"]:::client
            ShoppingCart["Shopping Cart"]:::client
            Success["Success"]:::client
            Privacy["Privacy"]:::client
            Terms["Terms & Conditions"]:::client
            NotFound["404 Page Not Found"]:::client
        end
        subgraph "State Management"
            direction TB
            Store["Store"]:::logic
            CartSlice["cartSlice"]:::logic
            UserSlice["userSlice"]:::logic
        end
        Data["Data Module"]:::logic
        subgraph "Helpers & Hooks"
            direction TB
            FormatPrice["formatPrice/formatNumber"]:::logic
            UseDispatch["useAppDispatch"]:::logic
        end
        subgraph "Layout & Entry"
            direction TB
            RootLayout["Root Layout"]:::client
            MainEntry["main.tsx & App.tsx"]:::client
        end
        Assets["Static Assets"]:::external
    end

    %% Serverless Function
    subgraph "Serverless Function" 
        direction TB
        Lambda["lambda-function/index.js"]:::logic
    end

    %% CI/CD & Hosting
    subgraph "Deployment & CI/CD"
        direction TB
        GHActions["GitHub Actions"]:::ci
        FirebaseHost["Firebase Hosting"]:::ci
        FirebaseFunc["Firebase Functions"]:::ci
        Cypress["Cypress Tests"]:::ci
    end

    %% External Services Placeholder
    External["External Services\n(e-mail, DB, analytics)"]:::external

    %% Connections
    User -->|interacts with| SPA
    SPA -->|renders| Banner & CartComp & ProductCard & Filters & ConfirmModal & PlusBtn & MinusBtn
    Banner & CartComp & ProductCard & Filters & ConfirmModal & PlusBtn & MinusBtn -->|dispatch| CartSlice & UserSlice
    CartSlice & UserSlice -->|update| SPA
    SPA -->|fetch /submitOrder| Lambda
    Lambda -->|response| SPA
    GHActions -->|build & deploy| FirebaseHost & FirebaseFunc
    GHActions -->|run tests| Cypress
    SPA -->|served from| FirebaseHost
    Lambda -->|deployed to| FirebaseFunc
    Lambda -->|calls| External

    %% Click Events - SPA
    click SPA "https://github.com/mychelgarzon/meatshop/tree/main/src/"
    click Banner "https://github.com/mychelgarzon/meatshop/blob/main/src/components/banner/Banner.tsx"
    click CartComp "https://github.com/mychelgarzon/meatshop/blob/main/src/components/cart/Cart.tsx"
    click ProductCard "https://github.com/mychelgarzon/meatshop/blob/main/src/components/productCard/ProductCard.tsx"
    click Filters "https://github.com/mychelgarzon/meatshop/blob/main/src/components/filter/Filter.tsx"
    click ConfirmModal "https://github.com/mychelgarzon/meatshop/blob/main/src/components/confirmationModal/ConfirmationModal.tsx"
    click PlusBtn "https://github.com/mychelgarzon/meatshop/blob/main/src/components/minusPlusButton/PlusButton.tsx"
    click MinusBtn "https://github.com/mychelgarzon/meatshop/blob/main/src/components/minusPlusButton/MinusButton.tsx"

    %% Click Events - Routes
    click Home "https://github.com/mychelgarzon/meatshop/blob/main/src/routes/home/Home.tsx"
    click About "https://github.com/mychelgarzon/meatshop/blob/main/src/routes/about/About.tsx"
    click ShoppingCart "https://github.com/mychelgarzon/meatshop/blob/main/src/routes/shoppingCart/ShoppingCart.tsx"
    click Success "https://github.com/mychelgarzon/meatshop/blob/main/src/routes/success/Success.tsx"
    click Privacy "https://github.com/mychelgarzon/meatshop/blob/main/src/routes/privacy/Privacy.tsx"
    click Terms "https://github.com/mychelgarzon/meatshop/blob/main/src/routes/termsAndConditions/TermsAndConditions.tsx"
    click NotFound "https://github.com/mychelgarzon/meatshop/blob/main/src/routes/pageNotFound/PageNotFound.tsx"

    %% Click Events - Store & Data & Hooks & Layout & Entry
    click Store "https://github.com/mychelgarzon/meatshop/blob/main/src/store/store.ts"
    click CartSlice "https://github.com/mychelgarzon/meatshop/blob/main/src/store/cartSlice.ts"
    click UserSlice "https://github.com/mychelgarzon/meatshop/blob/main/src/store/userSlice.ts"
    click Data "https://github.com/mychelgarzon/meatshop/blob/main/src/data/data.ts"
    click FormatPrice "https://github.com/mychelgarzon/meatshop/blob/main/src/helpers/formatPrice.ts"
    click UseDispatch "https://github.com/mychelgarzon/meatshop/blob/main/src/hooks/useAppDispatch.tsx"
    click RootLayout "https://github.com/mychelgarzon/meatshop/blob/main/src/layout/Root.tsx"
    click MainEntry "https://github.com/mychelgarzon/meatshop/blob/main/src/main.tsx"
    click MainEntry "https://github.com/mychelgarzon/meatshop/blob/main/src/App.tsx"
    click Assets "https://github.com/mychelgarzon/meatshop/tree/main/src/assets/"

    %% Click Events - Serverless
    click Lambda "https://github.com/mychelgarzon/meatshop/blob/main/lambda-function/index.js"
    click Lambda "https://github.com/mychelgarzon/meatshop/blob/main/lambda-function/package.json"

    %% Click Events - CI/CD & Hosting
    click Cypress "https://github.com/mychelgarzon/meatshop/blob/main/cypress.config.ts"
    click Cypress "https://github.com/mychelgarzon/meatshop/blob/main/cypress/e2e/add-product.cy.js"
    click Cypress "https://github.com/mychelgarzon/meatshop/blob/main/cypress/e2e/home-page.cy.js"
    click Cypress "https://github.com/mychelgarzon/meatshop/blob/main/cypress/e2e/place-order.cy.js"
    click Cypress "https://github.com/mychelgarzon/meatshop/blob/main/cypress/e2e/use-filters.cy.js"
    click FirebaseHost "https://github.com/mychelgarzon/meatshop/blob/main/firebase.json"
    click FirebaseHost "https://github.com/mychelgarzon/meatshop/blob/main/.firebaserc"
    click GHActions "https://github.com/mychelgarzon/meatshop/blob/main/.github/workflows/main.yml"

    %% Styles
    classDef client fill:#AEDFF7,stroke:#0277BD,color:#000
    classDef logic fill:#C8E6C9,stroke:#2E7D32,color:#000
    classDef ci fill:#FFE0B2,stroke:#EF6C00,color:#000
    classDef external fill:#E0E0E0,stroke:#616161,color:#000
```
