# thvnhtai/grab-bootcamp-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/thvnhtai/grab-bootcamp-frontend
- Repository: https://github.com/thvnhtai/grab-bootcamp-frontend

## Overview

##### Project type and purpose
- This is a single-page frontend application (“Grab Bootcamp Frontend”) built with React + Vite + TypeScript.
- Its purpose is to let users upload a food image, identify the dish via image analysis, and then fetch & display restaurants serving that dish. It also supports user authentication and shows restaurant details (menus, reviews, location).

##### File structure
- Top-level files: index.html, vite.config.ts (Vite config), package.json, .env.example, netlify.toml (deployment to Netlify).
- src/ directory:
- assets/ (images, SVGs)
- components/ (UI components organized by domain: common, forms, layout, restaurant, static, utility)
- constants/, enums/
- hooks/ (custom React hooks: useAuth, useRestaurant, etc.)
- layouts/ (BaseLayout, MainLayout)
- pages/ (Auth, Home, Search, SearchResult, Error pages)
- providers/ (AppProvider, AuthProvider, NotificationProvider, ContextProvider)
- redux/ (Redux Toolkit store, slices, transformer, hooks)
- services/ (API calls: recommendation.service.ts, restaurant.service.ts)
- utils/ (api.ts wraps axios, mapper, navigate, common helpers)
- No backend code here—this is purely the front end calling external REST/image APIs.

##### README for additional insights
- Features section confirms image-based search, restaurant details, user authentication, responsive design, modern UI with Ant Design + Emotion, state management with Redux Toolkit.
- “Technologies Used” lists all major frameworks and libraries.
- README’s Project Structure matches the file layout.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Layer
    subgraph "Infrastructure"
        Netlify["Netlify CDN"]:::infra
    end

    %% Client Layer
    Browser["User Browser"]:::external
    Netlify -->|Hosts Static Assets| Browser

    %% React SPA Entry
    Entry["main.tsx"]:::frontend
    click Entry "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/main.tsx"
    Browser -->|Loads SPA| Entry

    App["App.tsx"]:::frontend
    click App "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/App.tsx"
    Entry --> App

    %% Providers Layer
    subgraph "Context Providers"
        direction TB
        AppProv["AppProvider"]:::state
        AuthProv["AuthProvider"]:::state
        NotifProv["NotificationProvider"]:::state
        CtxProv["ContextProvider"]:::state
    end
    click AppProv "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/providers/AppProvider.tsx"
    click AuthProv "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/providers/AuthProvider.tsx"
    click NotifProv "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/providers/NotificationProvider.tsx"
    click CtxProv "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/providers/ContextProvider.tsx"
    App --> AppProv
    AppProv --> AuthProv
    AuthProv --> NotifProv
    NotifProv --> CtxProv

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        subgraph "Pages"
            direction TB
            AuthPage["AuthPage"]:::frontend
            click AuthPage "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/pages/auth/AuthPage.tsx"
            HomePage["HomePage"]:::frontend
            click HomePage "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/pages/home/HomePage.tsx"
            SearchPage["SearchPage"]:::frontend
            click SearchPage "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/pages/search/SearchPage.tsx"
            ResultsPage["SearchResultPage"]:::frontend
            click ResultsPage "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/pages/search-result/SearchResultPage.tsx"
            ErrorPage["ErrorPage"]:::frontend
            click ErrorPage "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/pages/errors/ErrorPage.tsx"
            ForbiddenPage["ForbiddenPage"]:::frontend
            click ForbiddenPage "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/pages/errors/ForbiddenPage.tsx"
            NotFoundPage["NotFoundPage"]:::frontend
            click NotFoundPage "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/pages/errors/NotFoundPage.tsx"
        end
        subgraph "Components"
            direction TB
            CommonComp["Common Components"]:::frontend
            click CommonComp "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/components/common"
            FormComp["Form Components"]:::frontend
            click FormComp "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/components/forms"
            LayoutComp["Layout Components"]:::frontend
            click LayoutComp "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/components/layout"
            RestComp["Restaurant Components"]:::frontend
            click RestComp "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/components/restaurant"
            StaticComp["Static Assets"]:::frontend
            click StaticComp "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/components/static"
            UtilComp["Utility Components"]:::frontend
            click UtilComp "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/components/utility"
        end
    end

    CtxProv --> Pages
    Pages -->|Dispatch Actions / Select State| ReduxStore
    Pages -->|Render UI| Components

    %% State Layer - Redux
    subgraph "State Layer"
        direction TB
        ReduxStore["Store (store.ts)"]:::state
        click ReduxStore "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/redux/store.ts"
        Slices["Slices"]:::state
        click Slices "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/redux/slices"
        HooksRTK["Redux Hooks"]:::state
        click HooksRTK "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/redux/hooks.ts"
        UtilsSlice["createAppSlice & transformer"]:::state
        click UtilsSlice "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/redux/createAppSlice.ts"
        click UtilsSlice "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/redux/transformer.ts"
    end
    Components -->|useDispatch/useSelector| ReduxStore
    ReduxStore --> Slices
    Slices --> HooksRTK

    %% Business Logic Layer - Hooks & Services
    subgraph "Business Logic"
        direction TB
        subgraph "Custom Hooks"
            direction TB
            HookAuth["useAuth"]:::service
            click HookAuth "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/hooks/useAuth.ts"
            HookRest["useRestaurant"]:::service
            click HookRest "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/hooks/useRestaurant.ts"
            HookNotif["useNotification"]:::service
            click HookNotif "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/hooks/useNotification.ts"
            HookUtil["Utility Hooks"]:::service
            click HookUtil "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/hooks/useDebounce.ts"
            click HookUtil "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/hooks/useWindowSize.ts"
        end
        subgraph "Service APIs"
            direction TB
            RecService["recommendation.service.ts"]:::service
            click RecService "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/services/recommendation.service.ts"
            RestService["restaurant.service.ts"]:::service
            click RestService "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/services/restaurant.service.ts"
            ServicesIndex["services/index.ts"]:::service
            click ServicesIndex "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/services/index.ts"
        end
    end
    HooksAuth --> RecService
    HooksRest --> RestService
    Pages -->|useHooks| HookAuth
    Pages -->|useHooks| HookRest
    Pages -->|useHooks| HookNotif

    %% Transport Layer
    AxiosClient["API Client (api.ts)"]:::transport
    click AxiosClient "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/utils/api.ts"
    RecService --> AxiosClient
    RestService --> AxiosClient
    HookAuth --> AxiosClient

    %% Utilities & Types
    subgraph "Utilities & Types"
        direction TB
        Mapper["mapper.ts"]:::util
        click Mapper "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/utils/mapper.ts"
        Navigate["navigate.ts"]:::util
        click Navigate "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/utils/navigate.ts"
        Helpers["common.ts"]:::util
        click Helpers "https://github.com/thvnhtai/grab-bootcamp-frontend/blob/main/src/utils/common.ts"
        Constants["constants"]:::util
        click Constants "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/constants"
        Enums["enums"]:::util
        click Enums "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/enums"
        Types["types"]:::util
        click Types "https://github.com/thvnhtai/grab-bootcamp-frontend/tree/main/src/types"
    end
    AxiosClient --> Mapper
    Mapper --> ReduxStore
    Navigate --> Pages
    Helpers --> Pages

    %% External APIs
    subgraph "External Services"
        direction TB
        ImageAPI["Image Analysis Service"]:::external
        AuthAPI["Authentication API"]:::external
        RestaurantAPI["Restaurant Data API"]:::external
    end
    AxiosClient -->|POST /analyze-image| ImageAPI
    AxiosClient -->|POST /signin, /signup| AuthAPI
    AxiosClient -->|GET /restaurants?dishId=| RestaurantAPI

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085;
    classDef state fill:#d4edda,stroke:#155724;
    classDef service fill:#fff3cd,stroke:#856404;
    classDef transport fill:#e2e3e5,stroke:#6c757d;
    classDef util fill:#d1ecf1,stroke:#0c5460;
    classDef external fill:#f8d7da,stroke:#721c24;
    classDef infra fill:#d6d8d9,stroke:#1b1e21;
```
