# dezeriandroid/fruit-shop architecture

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

- Interactive diagram: https://gitdiagram.com/dezeriandroid/fruit-shop
- Repository: https://github.com/dezeriandroid/fruit-shop

## Overview

##### Project type and purpose
- This is a single-page application (SPA) written in TypeScript with React, built and served by Vite.
- It implements a simple “fruit shop” UI: browsing fruits, adding/removing items in a cart, placing orders, user registration, and theme toggling.

##### File structure
- Top level:
- index.html – SPA entry point
- vite.config.ts, tsconfig*.json, package.json – build/configuration
- public/ – static assets (404 page, favicon, etc.)
- src/ – all client-side code
- main.tsx – React DOM bootstrapping, wraps App in Context providers
- App.tsx + App.css – root component
- Components/ – UI screens and widgets (Header, Home, FruitList, Cart, Orders, Registration)
- Context/ – React Context providers for theme, error handling, fruit list data, cart/orders state, quantity, total price
- hooks/ – custom hooks (useCart, useFruitList, useOrders) encapsulating business logic and Context consumption

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build/Dev Tools
    subgraph "Build/Dev Tools"
        direction TB
        ViteConfig["vite.config.ts"]:::dev
        TsConfig["tsconfig.json"]:::dev
        TsApp["tsconfig.app.json"]:::dev
        TsNode["tsconfig.node.json"]:::dev
        ESLint["eslint.config.js"]:::dev
    end

    %% SPA Entry Point / Bootstrapping
    subgraph "Browser/Client"
        direction TB
        Index["index.html"]:::entry
        Main["main.tsx"]:::entry
        Index -->|loads| Main
    end

    %% React App Runtime
    subgraph "React App Runtime"
        direction TB
        App["App Component"]:::ui
        AppCSS["App.css"]:::ui
        Main -->|bootstraps| App

        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            Header["Header Component"]:::ui
            Home["Home Screen"]:::ui
            FruitList["Fruit List Screen"]:::ui
            Cart["Cart Screen"]:::ui
            Orders["Orders Screen"]:::ui
            Registration["Registration Screen"]:::ui
        end

        %% Hook Layer
        subgraph "Hook Layer"
            direction TB
            UseFruit["useFruitList Hook"]:::hook
            UseCart["useCart Hook"]:::hook
            UseOrders["useOrders Hook"]:::hook
        end

        %% State Management Layer
        subgraph "State Management Layer"
            direction TB
            ThemeCtx["ThemeContext Provider"]:::state
            ThemeDef["Theme.tsx"]:::state
            ErrorCtx["ErrorContext Provider"]:::state
            FruitCtx["ListFruitBasa Data Context"]:::state
            OrderCtx["OrderContext Provider"]:::state
            QtyCtx["QuantityContext Provider"]:::state
            PriceCtx["TotalPriceContext Provider"]:::state
            ContextExports["Combined Context Exports"]:::state
        end

        %% Data Sources
        subgraph "Data Sources"
            direction TB
            StaticData["Static JSON / In-Memory Fruit Catalog"]:::data
            Storage["Browser Storage / In-Memory Cart & Orders"]:::data
        end

        %% Interactions
        Header -->|user events| UseCart
        Home -->|user events| UseFruit
        FruitList -->|user events| UseCart
        Cart -->|user events| UseOrders
        Registration -->|user events| ErrorCtx
        Orders -->|user events| UseOrders

        UseFruit -->|consumes| FruitCtx
        UseCart -->|consumes| OrderCtx
        UseCart -->|consumes| QtyCtx
        UseCart -->|consumes| PriceCtx
        UseOrders -->|consumes| OrderCtx

        FruitCtx -->|provides state| FruitList
        OrderCtx -->|provides state| Cart
        OrderCtx -->|provides state| Orders
        QtyCtx -->|provides state| Cart
        PriceCtx -->|provides state| Cart
        ThemeCtx -->|provides state| App
        ErrorCtx -->|provides state| Registration

        StaticData -->|feeds| FruitCtx
        Storage -->|feeds| OrderCtx

        App -->|renders| Header
        App -->|renders| Home
        App -->|renders| FruitList
        App -->|renders| Cart
        App -->|renders| Orders
        App -->|renders| Registration
    end

    %% Build pipeline to browser
    ViteConfig -->|build/dev serve| Index
    TsConfig --> ViteConfig
    TsApp --> ViteConfig
    TsNode --> ViteConfig
    ESLint --> ViteConfig

    %% Click Events
    click ViteConfig "https://github.com/dezeriandroid/fruit-shop/blob/main/vite.config.ts"
    click TsConfig "https://github.com/dezeriandroid/fruit-shop/blob/main/tsconfig.json"
    click TsApp "https://github.com/dezeriandroid/fruit-shop/blob/main/tsconfig.app.json"
    click TsNode "https://github.com/dezeriandroid/fruit-shop/blob/main/tsconfig.node.json"
    click ESLint "https://github.com/dezeriandroid/fruit-shop/blob/main/eslint.config.js"
    click Index "https://github.com/dezeriandroid/fruit-shop/blob/main/index.html"
    click Main "https://github.com/dezeriandroid/fruit-shop/blob/main/src/main.tsx"
    click App "https://github.com/dezeriandroid/fruit-shop/blob/main/src/App.tsx"
    click AppCSS "https://github.com/dezeriandroid/fruit-shop/blob/main/src/App.css"
    click Header "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Components/Header.tsx"
    click Home "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Components/Home.tsx"
    click FruitList "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Components/FruitList.tsx"
    click Cart "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Components/Cart.tsx"
    click Orders "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Components/Orders.tsx"
    click Registration "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Components/Registration.tsx"
    click ThemeCtx "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/ThemeContext.tsx"
    click ThemeDef "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/Theme.tsx"
    click ErrorCtx "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/Error.tsx"
    click FruitCtx "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/ListFruitBasa.ts"
    click OrderCtx "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/OrderContext.tsx"
    click QtyCtx "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/Quantity.tsx"
    click PriceCtx "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/TotalPrice.tsx"
    click ContextExports "https://github.com/dezeriandroid/fruit-shop/blob/main/src/Context/Context.tsx"
    click UseFruit "https://github.com/dezeriandroid/fruit-shop/blob/main/src/hooks/useFruitList.tsx"
    click UseCart "https://github.com/dezeriandroid/fruit-shop/blob/main/src/hooks/useCart.tsx"
    click UseOrders "https://github.com/dezeriandroid/fruit-shop/blob/main/src/hooks/useOrders.tsx"

    %% Styles
    classDef dev fill:#ddd,stroke:#333,stroke-width:1px
    classDef entry fill:#eee,stroke:#333,stroke-width:1px
    classDef ui fill:#bbf,stroke:#333,stroke-width:1px
    classDef state fill:#bfb,stroke:#333,stroke-width:1px
    classDef hook fill:#fba,stroke:#333,stroke-width:1px
    classDef data fill:#ccc,stroke:#333,stroke-width:1px
```
