# greyn1/capstone-project architecture

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

- Interactive diagram: https://gitdiagram.com/greyn1/capstone-project
- Repository: https://github.com/greyn1/capstone-project

## Overview

##### Project type and purpose
- This is a single-page e-commerce storefront built with Create React App.
- It provides shopping features (browse categories, add to cart, checkout) entirely in the browser.
- State is managed via React Context APIs; data and authentication are handled by Firebase.

##### File structure
- Top-level:
- public/ – static assets and entry HTML (index.html, manifest.json, redirects for hosting).
- src/ – application source code.
- package.json / package-lock.json – dependencies and scripts.
- src/Contexts – three context providers: CartContext, CategoriesContext, UserContext.
- src/Routes – six route modules mapping URL paths to page components.
- src/components – reusable UI components (Button, CartIcon, ProductCard, forms, spinner).
- src/Utils/Firebase.js – wrapper for Firebase SDK calls (auth, Firestore).
- src/Styles & global.styles.js – SCSS and styled-component definitions.
- Entry point: src/index.js → ReactDOM.render(App) with context providers and React Router.

##### README for additional insights
- Bootstrapped with CRA; standard scripts (start, build, test, eject).
- No mention of custom backend—Firebase is the external service.

##### Detail
- Context as a separate element.
- Firebase util module as a centralized service connector.
- Style layers (SCSS + styled components) as a side strand, injected into components.
- Don’t hesitate to break UI into its smallest reusable parts—better granularity will aid understanding.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Browser["Browser / Client"]:::external
    CDN["Hosting / CDN (Netlify/Vercel)"]:::external
    Public["public (static assets & index.html)"]:::static
    Redirects["_redirects"]:::static

    Browser --> CDN
    CDN --> Public
    Public --> Redirects

    %% React Application Core
    subgraph "React Application"
        Entry["src/index.js\n(Entry & Context setup)"]:::react
        App["src/App.js\n(App Container)"]:::react
    end

    CDN --> Entry
    Entry --> App

    %% Context Providers
    subgraph "Contexts"
        CartCtx["CartContext"]:::react
        CatsCtx["CategoriesContext"]:::react
        UserCtx["UserContext"]:::react
    end

    Entry --> CartCtx
    Entry --> CatsCtx
    Entry --> UserCtx
    CartCtx --> App
    CatsCtx --> App
    UserCtx --> App

    %% Routing Layer
    subgraph "Routing Layer"
        Navigation["Navigation (Routes)"]:::react
        Home["Home Page"]:::react
        Shop["Shop Page"]:::react
        CatsPrev["CategoriesPreview"]:::react
        Category["Category Page"]:::react
        Checkout["Checkout Page"]:::react
        AuthPage["Authentication Page"]:::react
    end

    App --> Navigation
    Navigation --> Home
    Navigation --> Shop
    Navigation --> CatsPrev
    Navigation --> Category
    Navigation --> Checkout
    Navigation --> AuthPage

    %% UI Components
    subgraph "UI Components"
        Button["Button"]:::react
        CartIcon["CartIcon"]:::react
        CartDropdown["CartDropdown"]:::react
        CartItem["CartItem"]:::react
        Directory["Directory"]:::react
        DirItem["DirectoryItem"]:::react
        CatPreview["CategoryPreview"]:::react
        ProductCard["ProductCard"]:::react
        FormInput["FormInput"]:::react
        SignIn["SignInForm"]:::react
        SignUp["SignUpForm"]:::react
        CheckoutItem["CheckoutItem"]:::react
        Spinner["Spinner"]:::react
    end

    Home --> Directory
    Directory --> DirItem
    Shop --> CatPreview
    CatPreview --> ProductCard
    CartIcon --> CartDropdown
    CartDropdown --> CartItem
    Checkout --> CheckoutItem
    AuthPage --> SignIn
    AuthPage --> SignUp

    %% Styles Layer
    subgraph "Styles"
        SCSS[".scss files"]:::static
        StyledComp["styled-components"]:::static
        GlobalStyle["global.styles.js"]:::static
    end

    SCSS --> Button
    SCSS --> CartIcon
    SCSS --> CartDropdown
    SCSS --> CartItem
    SCSS --> Directory
    SCSS --> DirItem
    SCSS --> CatPreview
    SCSS --> ProductCard
    SCSS --> FormInput
    SCSS --> SignIn
    SCSS --> SignUp
    SCSS --> CheckoutItem
    SCSS --> Spinner

    StyledComp --> Button
    StyledComp --> CartIcon
    StyledComp --> CartDropdown
    StyledComp --> CartItem
    StyledComp --> Directory
    StyledComp --> DirItem
    StyledComp --> CatPreview
    StyledComp --> ProductCard
    StyledComp --> FormInput
    StyledComp --> SignIn
    StyledComp --> SignUp
    StyledComp --> CheckoutItem
    StyledComp --> Spinner

    %% Utils & External Services
    subgraph "Service Abstraction"
        FirebaseUtil["Firebase.js"]:::react
    end

    App --> FirebaseUtil
    Button --> FirebaseUtil
    CartIcon --> FirebaseUtil
    CartDropdown --> FirebaseUtil
    CartItem --> FirebaseUtil
    Directory --> FirebaseUtil
    DirItem --> FirebaseUtil
    CatPreview --> FirebaseUtil
    ProductCard --> FirebaseUtil
    FormInput --> FirebaseUtil
    SignIn --> FirebaseUtil
    SignUp --> FirebaseUtil
    CheckoutItem --> FirebaseUtil
    Spinner --> FirebaseUtil

    subgraph "Firebase Services"
        FirebaseAuth["Firebase Auth"]:::external
        Firestore["Firestore DB"]:::external
    end

    FirebaseUtil --> FirebaseAuth
    FirebaseUtil --> Firestore

    %% Build & Config
    subgraph "Build & Config"
        Pkg["package.json"]:::static
        Tests["App.test.js, setupTests.js, reportWebVitals.js"]:::static
    end

    Entry --> Tests
    Entry --> Pkg
    CDN --> Pkg

    %% Click Events
    click Public "https://github.com/greyn1/capstone-project/tree/main/public/"
    click Redirects "https://github.com/greyn1/capstone-project/tree/main/public/_redirects"
    click Entry "https://github.com/greyn1/capstone-project/blob/main/src/index.js"
    click App "https://github.com/greyn1/capstone-project/blob/main/src/App.js"
    click CartCtx "https://github.com/greyn1/capstone-project/blob/main/src/Contexts/CartContext.js"
    click CatsCtx "https://github.com/greyn1/capstone-project/blob/main/src/Contexts/CategoriesContext.js"
    click UserCtx "https://github.com/greyn1/capstone-project/blob/main/src/Contexts/UserContext.js"
    click Navigation "https://github.com/greyn1/capstone-project/blob/main/src/Routes/Navigation.js"
    click Home "https://github.com/greyn1/capstone-project/blob/main/src/Routes/Home.js"
    click Shop "https://github.com/greyn1/capstone-project/blob/main/src/Routes/Shop.js"
    click CatsPrev "https://github.com/greyn1/capstone-project/blob/main/src/Routes/CategoriesPreview.js"
    click Category "https://github.com/greyn1/capstone-project/blob/main/src/Routes/Category.js"
    click Checkout "https://github.com/greyn1/capstone-project/blob/main/src/Routes/Checkout.js"
    click AuthPage "https://github.com/greyn1/capstone-project/blob/main/src/Routes/Authentication.js"
    click Button "https://github.com/greyn1/capstone-project/blob/main/src/components/Button.js"
    click CartIcon "https://github.com/greyn1/capstone-project/blob/main/src/components/CartIcon.js"
    click CartDropdown "https://github.com/greyn1/capstone-project/blob/main/src/components/CartDropdown.js"
    click CartItem "https://github.com/greyn1/capstone-project/blob/main/src/components/CartItem.js"
    click Directory "https://github.com/greyn1/capstone-project/blob/main/src/components/Directory.js"
    click DirItem "https://github.com/greyn1/capstone-project/blob/main/src/components/DirectoryItem.js"
    click CatPreview "https://github.com/greyn1/capstone-project/blob/main/src/components/CategoryPreview.js"
    click ProductCard "https://github.com/greyn1/capstone-project/blob/main/src/components/ProductCard.js"
    click FormInput "https://github.com/greyn1/capstone-project/blob/main/src/components/FormInput.js"
    click SignIn "https://github.com/greyn1/capstone-project/blob/main/src/components/SignInForm.js"
    click SignUp "https://github.com/greyn1/capstone-project/blob/main/src/components/SignUpForm.js"
    click CheckoutItem "https://github.com/greyn1/capstone-project/blob/main/src/components/CheckoutItem.js"
    click Spinner "https://github.com/greyn1/capstone-project/blob/main/src/components/spinner/Spinner.js"
    click SCSS "https://github.com/greyn1/capstone-project/tree/main/src/Styles/"
    click StyledComp "https://github.com/greyn1/capstone-project/blob/main/src/Styles/*.styles.js"
    click GlobalStyle "https://github.com/greyn1/capstone-project/blob/main/src/global.styles.js"
    click FirebaseUtil "https://github.com/greyn1/capstone-project/blob/main/src/Utils/Firebase.js"
    click Pkg "https://github.com/greyn1/capstone-project/blob/main/package.json"
    click Tests "https://github.com/greyn1/capstone-project/blob/main/src/App.test.js"

    %% Styles
    classDef react fill:#B0E0E6,stroke:#333,stroke-width:1px
    classDef external fill:#98FB98,stroke:#333,stroke-width:1px
    classDef static fill:#D3D3D3,stroke:#333,stroke-width:1px
```
