# dawydangcode/cakestore-microservice-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/dawydangcode/cakestore-microservice-frontend
- Repository: https://github.com/dawydangcode/cakestore-microservice-frontend

## Overview

##### Project type and purpose
- This is a single‐page React frontend (“cakestore-microservice-frontend”) built with Create React App.
- It provides user-facing pages (home, search, product, cart, checkout), authentication flows (login, signup, forgot password, logout), admin dashboards (categories, orders, chat), and a chat widget, all communicating with a set of backend microservices.

##### File structure
- Top-level: public/ (static assets), src/ (application code), package.json, uml.puml.
- src/api: centralized Axios client for all HTTP calls (base URL, interceptors).
- src/auth & src/context: AuthService/AuthContext for JWT handling; CartContext for shopping-cart state.
- src/components & subfolders: reusable UI components organized by domain (login, products, orders, admin, chat, layout).
- src/pages: route components corresponding to URL paths.

##### Key insights from README
- Standard CRA setup; no explicit architecture notes.
- Implied deployment: static bundle served by a CDN or webserver; all dynamic behavior relies on REST/WebSocket calls to external APIs.

- Entry point (index.js) → App.js → Routes → Pages → Components
- Context Providers wrapped around App
- axiosClient configured once (base URL, interceptors)
- Microservice endpoint your frontend calls (e.g., /api/auth, /api/products, /api/orders, /api/categories, /api/chat).
- Flow of JWT tokens from AuthService to axiosClient headers.
- WebSocket handshake from ChatWidget to the Chat Service.
- Separation of concerns and scalability points (each microservice can deploy independently).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Zone
    subgraph "Client (Browser)"
        direction TB
        Entry["index.js"]:::client
        App["App.js"]:::client
        IndexHTML["public/index.html"]:::client
        PlantUML["uml.puml"]:::client

        subgraph "Contexts & API Layer"
            direction TB
            AuthCtx["AuthContext.js"]:::client
            CartCtx["CartContext.js"]:::client
            AxClient["axiosClient.js"]:::client
            AuthService["authService.js"]:::client
            AuthUtils["auth.js"]:::client
        end

        subgraph "UI Components"
            direction TB
            Navbar["Navbar.js"]:::client
            Login["Login.js"]:::client
            SignUp["SignUp.js"]:::client
            ForgotPwd["ForgotPassword.js"]:::client
            LogoutBtn["LogoutButton.js"]:::client
            ProductList["ProductList.js"]:::client
            ProductDetail["ProductDetail.js"]:::client
            AddToCart["AddToCartModal.js"]:::client
            OrderList["OrderList.js"]:::client
            OrderDetail["OrderDetail.js"]:::client
            ChatWidget["ChatWidget.js"]:::client
            AdminLayout["AdminLayout.js"]:::client
            AdminHome["AdminDashboard.js"]:::client
            AdminCat["AdminCategories.js"]:::client
            AdminOrders["AdminOrders.js"]:::client
            AdminChat["AdminChat.js"]:::client
        end

        subgraph "Pages (Routes)"
            direction TB
            HomePage["Home.js"]:::client
            SearchPage["SearchPage.js"]:::client
            ProductPage["ProductPage.js"]:::client
            CartPage["CartPage.js"]:::client
            CheckoutPage["Checkout.js"]:::client
            DashboardRoute["Dashboard.js"]:::client
        end
    end

    %% Backend Zone
    subgraph "Backend Microservices"
        direction TB
        AuthMS["Auth Service (REST)"]:::backend
        ProdMS["Product Service (REST)"]:::backend
        CartOrderMS["Cart/Order Service (REST)"]:::backend
        CatMS["Category Service (REST)"]:::backend
        ChatMS["Chat Service (WebSocket)"]:::backend
    end

    subgraph "Databases"
        direction TB
        AuthDB["Auth DB"]:::db
        ProdDB["Product DB"]:::db
        OrderDB["Order DB"]:::db
        CatDB["Category DB"]:::db
        ChatDB["Chat DB"]:::db
    end

    %% Third-party
    Pay["Payment Gateway"]:::thirdparty

    %% Client relationships
    Entry --> App
    App --> AuthCtx
    App --> CartCtx
    App --> Navbar
    App --> HomePage
    App --> SearchPage
    App --> ProductPage
    App --> CartPage
    App --> CheckoutPage
    App --> DashboardRoute

    AuthCtx --> AxClient
    CartCtx --> AxClient
    AuthService --> AxClient
    AuthUtils --> AuthService
    AxClient --> AuthMS
    AxClient --> ProdMS
    AxClient --> CartOrderMS
    AxClient --> CatMS

    HomePage --> ProductList
    SearchPage --> ProductList
    ProductPage --> ProductDetail
    ProductPage --> AddToCart
    CartPage --> CartCtx
    CheckoutPage -->|REST| CartOrderMS
    CheckoutPage -->|REST| ProdMS
    DashboardRoute --> AdminLayout
    AdminLayout --> AdminHome
    AdminLayout --> AdminCat
    AdminLayout --> AdminOrders
    AdminLayout --> AdminChat

    ChatWidget -->|WebSocket| ChatMS

    %% Backend relationships
    AuthMS --> AuthDB
    ProdMS --> ProdDB
    CartOrderMS --> OrderDB
    CatMS --> CatDB
    ChatMS --> ChatDB

    CartOrderMS -->|calls| Pay

    %% Click Events
    click Entry "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/index.js"
    click App "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/App.js"
    click IndexHTML "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/public/index.html"
    click PlantUML "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/uml.puml"
    click AuthCtx "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/context/AuthContext.js"
    click CartCtx "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/context/CartContext.js"
    click AxClient "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/api/axiosClient.js"
    click AuthService "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/auth/authService.js"
    click AuthUtils "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/auth/auth.js"
    click Navbar "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/layout/Navbar.js"
    click Login "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/Login.js"
    click SignUp "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/SignUp.js"
    click ForgotPwd "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/ForgotPassword.js"
    click LogoutBtn "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/LogoutButton.js"
    click ProductList "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/products/ProductList.js"
    click ProductDetail "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/products/ProductDetail.js"
    click AddToCart "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/products/AddToCartModal.js"
    click OrderList "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/orders/OrderList.js"
    click OrderDetail "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/orders/OrderDetail.js"
    click ChatWidget "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/chat/ChatWidget.js"
    click AdminLayout "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/admin/AdminLayout.js"
    click AdminHome "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/admin/AdminDashboard.js"
    click AdminCat "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/admin/AdminCategories.js"
    click AdminOrders "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/admin/AdminOrders.js"
    click AdminChat "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/components/admin/AdminChat.js"
    click HomePage "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/pages/home/Home.js"
    click SearchPage "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/pages/SearchPage.js"
    click ProductPage "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/pages/ProductPage.js"
    click CartPage "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/pages/CartPage.js"
    click CheckoutPage "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/pages/Checkout.js"
    click DashboardRoute "https://github.com/dawydangcode/cakestore-microservice-frontend/blob/main/src/pages/Dashboard.js"

    %% Style definitions
    classDef client fill:#ccf,stroke:#333,stroke-width:1px
    classDef backend fill:#cfc,stroke:#333,stroke-width:1px
    classDef db fill:#fcf,stroke:#333,stroke-width:1px
    classDef thirdparty fill:#eee,stroke:#666,stroke-dasharray: 2 2
```
