# kawaki0101/grocery_app architecture

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

- Interactive diagram: https://gitdiagram.com/kawaki0101/grocery_app
- Repository: https://github.com/kawaki0101/grocery_app

## Overview

##### Project Type and Purpose
- This is a React Native mobile application (“Grocery_app”) targeting both Android and iOS.
- It is structured as a client‐only front end that interacts with remote APIs (via AuthService, Axios interceptors, etc.), manages local state (Zustand + MMKV), and renders UI screens (features, components).

##### High-Level Architectural Components
a. Native Platforms
- Android (Java/Kotlin code under android/…)
- iOS (Swift/Objective-C under ios/…)
- Metro Bundler (JS bundler serving the JS bundle to device)
b. React Native Bridge
- Mediates between JS thread and native modules (UI views, native storage, device APIs)
c. JavaScript Layer
1. Entry Point
– index.js → registers App.tsx via AppRegistry
2. Navigation Layer
– src/navigation/Navigation.tsx uses React Navigation to wire up feature screens
3. Presentation Layer (Screens & Components)
– src/features/* (SplashScreen, CustomerLogin, DashBoard, DeliveryDashboard, etc.)
– src/components/global/ui (CustomButton, CustomInput, CustomText)
4. State Management
– src/state/authStore.tsx & mmkvStorageForZustand.ts for persisting auth (Zustand + MMKV)
5. Service Layer
– src/Service/AuthService.tsx (login/logout API calls)
– src/Service/apiInterceptors.tsx (Axios request/response interceptors)
– src/Service/config.tsx (base URLs, timeouts)
6. Utility and Assets
– src/utils (Constants, DateUtils, Themes, CustomMap, helper hooks)

##### External Systems
- Remote REST/GraphQL API servers for auth and grocery data
- Third-party services (e.g., maps, analytics) if any

##### Key Architectural Patterns & Design Principles
- Feature-based folder structure (each “feature” encapsulates its screen and related logic)
- Layered separation: Presentation ←→ State ←→ Service ←→ Network
- Unidirectional data flow (components dispatch actions → state updates → UI re-renders)
- Bridge pattern between JS and native modules

## Diagram (Mermaid)

```mermaid
graph TB
    %% Native Platforms Layer
    subgraph "Native Platforms"
        direction TB
        Android["Android"]:::native
        iOS["iOS"]:::native
    end

    %% Bridge
    subgraph "React Native Bridge"
        direction TB
        Bridge["RN Bridge"]:::bridge
    end

    %% JS Runtime
    subgraph "JS Runtime"
        direction TB
        Metro["Metro Bundler"]:::runtime
        Index["index.js"]:::entry
        App["App.tsx"]:::entry
    end

    %% Application Layers
    subgraph "Application Layer"
        direction TB

        subgraph NavigationLayer["Navigation"]
            Navigation["Navigation"]:::frontend
        end

        subgraph Presentation["UI / Presentation"]
            Splash["SplashScreen"]:::frontend
            CustLogin["CustomerLogin"]:::frontend
            DelivLogin["DeliveryLogin"]:::frontend
            ProdDash["ProductDashboard"]:::frontend
            DelivDash["DeliveryDashboard"]:::frontend
            CustomBtn["CustomButton"]:::frontend
            CustomInput["CustomInput"]:::frontend
            CustomText["CustomText"]:::frontend
            SafeArea["CustomSafeAreaView"]:::frontend
            Slider["ProductSlider"]:::frontend
        end

        subgraph State["State Management"]
            AuthStore["AuthStore (Zustand)"]:::state
            MMKVAdapter["MMKV Adapter"]:::state
            StorageWrapper["Storage Wrapper"]:::state
        end

        subgraph Service["Service Layer"]
            AuthService["AuthService"]:::service
            Interceptors["apiInterceptors"]:::service
            ConfigSvc["Service Config"]:::service
        end

        subgraph Network["Network"]
            Axios["Axios Instance"]:::service
        end
    end

    ExternalAPI["Remote API Servers"]:::external

    %% Connections
    Android -->|bridged via| Bridge
    iOS -->|bridged via| Bridge
    Metro -->|bundles JS| Bridge
    Bridge -->|executes JS bundle| Metro
    Metro -->|serves bundle to| Android
    Metro -->|serves bundle to| iOS

    Metro --> Index
    Index --> App
    App --> Navigation
    Navigation --> Splash
    Navigation --> CustLogin
    Navigation --> DelivLogin
    Navigation --> ProdDash
    Navigation --> DelivDash

    Splash --> AuthStore
    CustLogin --> AuthStore
    DelivLogin --> AuthStore
    ProdDash --> AuthStore
    DelivDash --> AuthStore

    AuthStore --> AuthService
    MMKVAdapter --> AuthStore
    StorageWrapper --> AuthStore

    AuthService --> Interceptors
    Interceptors --> ConfigSvc
    ConfigSvc --> Axios

    Axios -->|HTTP| ExternalAPI
    ExternalAPI -->|response| Axios
    Axios --> AuthStore
    AuthStore --> CustLogin
    AuthStore --> DelivDash

    %% Click events
    click Android "https://github.com/kawaki0101/grocery_app/tree/main/android/"
    click iOS "https://github.com/kawaki0101/grocery_app/tree/main/ios/"
    click Metro "https://github.com/kawaki0101/grocery_app/blob/main/metro.config.js"
    click Index "https://github.com/kawaki0101/grocery_app/blob/main/index.js"
    click App "https://github.com/kawaki0101/grocery_app/blob/main/App.tsx"
    click Navigation "https://github.com/kawaki0101/grocery_app/blob/main/src/navigation/Navigation.tsx"
    click Splash "https://github.com/kawaki0101/grocery_app/blob/main/src/features/auth/SplashScreen.tsx"
    click CustLogin "https://github.com/kawaki0101/grocery_app/blob/main/src/features/auth/CustomerLogin.tsx"
    click DelivLogin "https://github.com/kawaki0101/grocery_app/blob/main/src/features/auth/DeliveryLogin.tsx"
    click ProdDash "https://github.com/kawaki0101/grocery_app/blob/main/src/features/DashBoard/ProductDashboard.tsx"
    click DelivDash "https://github.com/kawaki0101/grocery_app/blob/main/src/features/delivery/DeliveryDashboard.tsx"
    click CustomBtn "https://github.com/kawaki0101/grocery_app/blob/main/src/components/global/ui/CustomButton.tsx"
    click CustomInput "https://github.com/kawaki0101/grocery_app/blob/main/src/components/global/ui/CustomInput.tsx"
    click CustomText "https://github.com/kawaki0101/grocery_app/blob/main/src/components/global/ui/CustomText.tsx"
    click SafeArea "https://github.com/kawaki0101/grocery_app/blob/main/src/components/global/CustomSafeAreaView.tsx"
    click Slider "https://github.com/kawaki0101/grocery_app/blob/main/src/components/global/login/ProductSlider.tsx"
    click AuthStore "https://github.com/kawaki0101/grocery_app/blob/main/src/state/authStore.tsx"
    click MMKVAdapter "https://github.com/kawaki0101/grocery_app/blob/main/src/state/mmkvStorageForZustand.ts"
    click StorageWrapper "https://github.com/kawaki0101/grocery_app/blob/main/src/state/Storage.tsx"
    click AuthService "https://github.com/kawaki0101/grocery_app/blob/main/src/Service/AuthService.tsx"
    click Interceptors "https://github.com/kawaki0101/grocery_app/blob/main/src/Service/apiInterceptors.tsx"
    click ConfigSvc "https://github.com/kawaki0101/grocery_app/blob/main/src/Service/config.tsx"

    %% Styles
    classDef native fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef bridge fill:#bbbbbb,stroke:#333,stroke-width:1px
    classDef runtime fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef entry fill:#e0f7fa,stroke:#006064,stroke-width:1px
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:1px
    classDef state fill:#ffe0b2,stroke:#e65100,stroke-width:1px
    classDef service fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef external fill:#fff9c4,stroke:#f9a825,stroke-width:1px,stroke-dasharray: 5 5
```
