# sadeeabdullah/bistro-boss-client architecture

> Architecture diagram of the GitHub repository sadeeabdullah/bistro-boss-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sadeeabdullah/bistro-boss-client
- Repository: https://github.com/sadeeabdullah/bistro-boss-client

## Overview

##### Main Components
- Frontend (React SPA): The entire client-side code lives in the src directory. Identify key segments such as:
- Pages: Separated by functionality (Home, Menu, Order, Login, SignUp, Dashboard with AdminHome, UserHome, Payment, etc.).
- Components: Reusable UI parts like FoodCard, ChefRecommend, Intro, SectionTitle, and shared components (Navbar, Footer, Cover, etc.).
- Layouts: Main and Dashboard layouts, governing the overall structure and routing.
- Business Logic and State Management: Custom hooks (useAdmin, useAuth, useAxiosPublic, useCart, etc.) and Providers (like AuthProvider) handle authentication, API calls, and local state.
- External Services:
- Firebase: For authentication, hosting, and possibly real-time database or storage (as shown by firebase.json, .firebase folder, and firebase.config.js).
- Payment Gateway: The Payment pages and step file hint at some integration with payment processing (even if the specific API isn’t detailed in the file tree).
- Routing and Security:
- Routes: The routing components (Routes.jsx, AdminRoute.jsx, PrivateRoute.jsx) define access control and navigation within the SPA.

##### Relationships and Interactions
- The React Application (Frontend) consumes data via custom Axios hooks that interact with secure and public APIs.
- AuthProvider, wrapping the application, integrates with Firebase to handle login, sign up, and possibly user roles.
- PrivateRoute and AdminRoute components manage access, ensuring that only authenticated users or admins access the dashboard areas.
- Dashboard pages are subdivided into functionality areas such as Manage Items, Cart, Payment, and Payment History.
- The UI is driven by components that display data fetched from static JSON files (e.g., menu.json, reviews.json in the public folder) and possibly dynamic data coming from Firebase.

##### Architectural Patterns and Principles
- Component-Based Architecture: The separation of UI elements into reusable React components.
- Separation of Concerns: Clear division between UI, business logic (hooks), and configuration (firebase settings, route protection).
- Modular Routing: The use of Routing files allows for clear segmentation between public pages and protected (dashboard) pages.
- External Service Integration: Using Firebase and possibly third-party APIs (payment gateways) reinforces a micro-services style integration point.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend UI Layer
    subgraph "Frontend UI Layer"
        subgraph "Pages"
            Home["Home Page"]:::ui
            Menu["Menu Page"]:::ui
            Order["Order Page"]:::ui
            Login["Login Page"]:::ui
            SignUp["SignUp Page"]:::ui
            Dashboard["Dashboard Pages"]:::ui
        end

        subgraph "Reusable UI Components"
            FoodCard["FoodCard Component"]:::ui
            ChefRec["ChefRecommend Component"]:::ui
            Intro["Intro Component"]:::ui
            SectionTitle["SectionTitle Component"]:::ui
            SocailLogin["SocialLogin Component"]:::ui
        end

        subgraph "Layouts"
            MainLayout["Main Layout"]:::ui
            DashboardLayout["Dashboard Layout"]:::ui
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        CustomHooks["Custom Hooks (useAdmin, useAuth, useAxiosPublic, useAxiosSecure, useCart, useMenu)"]:::logic
        AuthProvider["Auth Provider"]:::logic
    end

    %% Routing & Security Layer
    subgraph "Routing & Security"
        Routes["Routes Component"]:::routing
        PrivateRoute["PrivateRoute Component"]:::routing
        AdminRoute["AdminRoute Component"]:::routing
    end

    %% External Services
    subgraph "External Services"
        Firebase["Firebase (Auth, Hosting, Config)"]:::external
        PaymentGateway["Payment Integration"]:::external
        PublicData["Public Data (menu.json, reviews.json)"]:::external
    end

    %% Connections from UI Layer to Business Logic
    Home -->|"DataFetch"| CustomHooks
    Menu -->|"DataFetch"| CustomHooks
    Order -->|"OrderState"| CustomHooks
    Login -->|"UserAuth"| AuthProvider
    SignUp -->|"UserRegister"| AuthProvider
    Dashboard -->|"SecureAccess"| PrivateRoute

    %% Connections within UI Components
    Home -->|"renders"| FoodCard
    Home -->|"renders"| Intro
    Menu -->|"renders"| SectionTitle
    Login -->|"renders"| SocailLogin

    %% Connections from Business Logic to External Services
    AuthProvider -->|"AuthRequest"| Firebase
    CustomHooks -->|"FetchData"| PublicData

    %% Routing & Security Connections
    Routes -->|"protects"| PrivateRoute
    Routes -->|"protects"| AdminRoute
    PrivateRoute -->|"validateUser"| AuthProvider
    AdminRoute -->|"validateAdmin"| AuthProvider

    %% Layout usage (implicit in routing)
    Routes -->|"wraps"| MainLayout
    Routes -->|"wraps"| DashboardLayout

    %% Payment Integration Connection
    Dashboard -->|"initPayment"| PaymentGateway

    %% Class Definitions for styling
    classDef ui fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef routing fill:#D5F5E3,stroke:#52BE80,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;

    %% Click Events for Frontend Pages
    click Home "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Pages/Home"
    click Menu "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Pages/Menu"
    click Order "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Pages/Order"
    click Login "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Pages/Login"
    click SignUp "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Pages/SignUp"
    click Dashboard "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Pages/Dashboard"

    %% Click Events for Reusable UI Components
    click FoodCard "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Component/FoodCard/FoodCard.jsx"
    click ChefRec "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Component/ChefRecommend/ChefRecommend.jsx"
    click Intro "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Component/Intro/Intro.jsx"
    click SectionTitle "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Component/SectionTitle/SectionTitle.jsx"
    click SocailLogin "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Component/SocailLogin/GoogleLogin.jsx"

    %% Click Events for Layouts
    click MainLayout "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Layout/Main.jsx"
    click DashboardLayout "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Layout/Dashboard.jsx"

    %% Click Events for Business Logic and State Management
    click CustomHooks "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Hooks"
    click AuthProvider "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Providers/AuthProvider.jsx"

    %% Click Events for Routing and Security
    click Routes "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Routes/Routes.jsx"
    click PrivateRoute "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Routes/PrivateRoute.jsx"
    click AdminRoute "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Routes/AdminRoute.jsx"

    %% Click Events for External Services
    click Firebase "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/src/Config/firebase/firebase.config.js"
    click PaymentGateway "https://github.com/sadeeabdullah/bistro-boss-client/tree/main/src/Pages/Dashboard/Payment"
    click PublicData "https://github.com/sadeeabdullah/bistro-boss-client/blob/main/public/menu.json"
```
