# mayromyller/fidelizi-test-mobile architecture

> Architecture diagram of the GitHub repository mayromyller/fidelizi-test-mobile, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mayromyller/fidelizi-test-mobile
- Repository: https://github.com/mayromyller/fidelizi-test-mobile

## Overview

##### Main Components
a. Mobile Runtime
- Expo / React-Native Engine
- Platform Bridges (iOS / Android native modules)
b. App Container
- App.tsx (entry point)
- Providers (AuthContextProvider, ReStyle ThemeProvider, Zustand store)
- Metro bundler
c. Navigation Layer
- Root Navigator (src/routes/index.ts)
- Auth Stack (SignInScreen)
- App Stack (Home → AmountSpent → ContactUser → RegisterUser → StampEarn)
d. Presentation Layer (Screens & UI Components)
- Screens (src/screens/…)
- Shared UI Components (src/components/ui/**)
e. Business-Logic Layer (Features / Vertical Slices)
- Auth Feature (authTypes, useAuthSignIn, useAuthSignOut, useAuthStorage)
- User Feature (useSetUser, useSetPhone, userPersistService, Zustand store)
- Stamp Feature (parseCurrencyToNumber, formatValueToCurrency, useCalculateStamp)
f. Infrastructure / Persistence
- Storage Interface (src/storage/storage.ts)
- AsyncStorage Implementation (src/storage/implementations/async-storage.ts)
- UserPersistService
g. External Services & Tools
- AsyncStorage Native Module
- Expo Go App / Developer Tools

##### Relationships & Data Flow
- App.tsx loads Providers
- AuthContextProvider initializes auth state (reads from AsyncStorage via storage interface)
- Navigation renders either Auth Stack or App Stack based on auth state
- Screens invoke Feature hooks (e.g. useAuthSignIn calls Auth infra → Storage)
- Business logic returns results to screens
- Screens dispatch updates to User/Stamp stores (Zustand)
- Stores persist changes through infrastructure layer

##### Architectural Patterns
- Vertical Slice: each feature bundle contains types, application hooks, infra adapters
- Unidirectional Data Flow: Screens → Feature Hooks → Infra → Persistence → Store → Screens
- Context / Provider Pattern for cross-cutting concerns (AuthContextProvider)
- State Management via Zustand for user / stamp data
- Theming with @shopify/restyle

##### Essential Elements Checklist
– Arrowheads for data/control flow
– Group boundaries for folders or subsystems
– Callouts for external dependencies (Expo, Native Modules)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mobile Runtime
    subgraph "Mobile Runtime"
        direction TB
        ExpoEngine["Expo / React-Native Engine"]:::native
        PlatformBridges["iOS / Android Native Modules"]:::native
    end

    %% App Container
    subgraph "App Container"
        direction TB
        AppTsx["App.tsx"]:::app
        AuthContextProvider["AuthContextProvider"]:::app
        ThemeProvider["ReStyle ThemeProvider"]:::app
        ZustandStore["Zustand Store"]:::app
        MetroBundler["Metro Bundler"]:::config
    end

    %% Navigation Layer
    subgraph "Navigation Layer"
        direction TB
        NavigationIndex["src/routes/index.ts"]:::nav
        AuthStack["Auth Stack"]:::nav
        AppStack["App Stack"]:::nav
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        SignInScreen["SignInScreen"]:::frontend
        HomeScreen["HomeScreen"]:::frontend
        AmountSpentScreen["AmountSpentScreen"]:::frontend
        ContactUserScreen["ContactUserScreen"]:::frontend
        RegisterUserScreen["RegisterUserScreen"]:::frontend
        StampEarnScreen["StampEarnScreen"]:::frontend
        UIComponents["UI Components"]:::frontend
        AssetsIcons["Assets: Icons"]:::frontend
        AssetsImages["Assets: Images"]:::frontend
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        subgraph "Auth Feature"
            authTypes["authTypes.ts"]:::business
            useAuthSignIn["useAuthSignIn"]:::business
            useAuthSignOut["useAuthSignOut"]:::business
            useAuthStorage["useAuthStorage"]:::business
        end
        subgraph "User Feature"
            userTypes["userTypes.ts"]:::business
            useSetUser["useSetUser"]:::business
            useSetPhone["useSetPhone"]:::business
            userPersistServiceFeature["userPersistService"]:::business
        end
        subgraph "Stamp Feature"
            parseCurrency["parseCurrencyToNumber"]:::business
            formatValue["formatValueToCurrency"]:::business
            useCalculateStamp["useCalculateStamp"]:::business
        end
    end

    %% Infrastructure / Persistence
    subgraph "Infrastructure / Persistence"
        direction TB
        StorageInterface["storage.ts"]:::infra
        AsyncStorageImpl["async-storage.ts"]:::infra
    end

    %% External Services & Tools
    subgraph "External Services & Tools"
        direction TB
        ExternalMock["AsyncStorage Native Module"]:::native
        ExpoConfig["eas.json / app.json"]:::config
    end

    %% Data Flow & Relations
    ExpoEngine -->|runs| AppTsx
    PlatformBridges -->|bridges| AsyncStorageImpl
    AppTsx -->|wraps| AuthContextProvider
    AppTsx -->|wraps| ThemeProvider
    AppTsx -->|provides| ZustandStore
    AppTsx -->|bundles| MetroBundler

    AuthContextProvider -->|uses| useAuthStorage
    useAuthStorage -->|implements| StorageInterface
    StorageInterface -->|impl| AsyncStorageImpl
    AsyncStorageImpl -->|native module| ExternalMock

    AppTsx -->|renders| NavigationIndex
    NavigationIndex -->|routes| AuthStack
    NavigationIndex -->|routes| AppStack

    AuthStack -->|screen| SignInScreen
    AppStack -->|screen| HomeScreen
    AppStack -->|screen| AmountSpentScreen
    AppStack -->|screen| ContactUserScreen
    AppStack -->|screen| RegisterUserScreen
    AppStack -->|screen| StampEarnScreen

    SignInScreen -->|calls| useAuthSignIn
    SignInScreen -->|calls| useAuthSignOut

    HomeScreen -->|reads/writes| useSetUser
    AmountSpentScreen -->|reads/writes| useSetPhone
    StampEarnScreen -->|calls| useCalculateStamp

    useAuthSignIn --> authTypes
    useAuthSignOut --> authTypes
    useAuthStorage --> authTypes

    useSetUser --> userTypes
    useSetPhone --> userTypes
    userPersistServiceFeature --> useSetUser
    userPersistServiceFeature --> useSetPhone

    parseCurrency --> formatValue
    useCalculateStamp --> parseCurrency
    useCalculateStamp --> formatValue

    ZustandStore -->|persists| userPersistServiceFeature
    userPersistServiceFeature -->|uses| StorageInterface

    ExpoConfig -->|configures| MetroBundler

    %% Click Events
    click AppTsx "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/App.tsx"
    click AuthContextProvider "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/context/auth/AuthContextProvider.tsx"
    click ThemeProvider "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/theme/index.ts"
    click MetroBundler "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/metro.config.js"
    click NavigationIndex "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/routes/index.ts"
    click AuthStack "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/routes/auth/auth.stack.route.tsx"
    click AppStack "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/routes/app/app.stack.routes.tsx"
    click SignInScreen "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/screens/auth/SignInScreen.tsx"
    click HomeScreen "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/screens/app/home-screen/HomeScreen.tsx"
    click AmountSpentScreen "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/screens/app/amount-spent-screen/AmountSpentScreen.tsx"
    click ContactUserScreen "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/screens/app/contact-user-screen/ContactUserScreen.tsx"
    click RegisterUserScreen "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/screens/app/register-user-screen/RegisterUserScreen.tsx"
    click StampEarnScreen "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/screens/app/stamp-earn-screen/StampEarnScreen.tsx"
    click UIComponents "https://github.com/mayromyller/fidelizi-test-mobile/tree/main/src/components/ui"
    click AssetsIcons "https://github.com/mayromyller/fidelizi-test-mobile/tree/main/src/assets/icons"
    click AssetsImages "https://github.com/mayromyller/fidelizi-test-mobile/tree/main/src/assets/images"
    click authTypes "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/auth/authTypes.ts"
    click useAuthSignIn "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/auth/application/useAuthSignIn.ts"
    click useAuthSignOut "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/auth/application/useAuthSinOut.ts"
    click useAuthStorage "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/auth/infra/useAuthStorage.ts"
    click userTypes "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/user/userTypes.ts"
    click useSetUser "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/user/application/useSetUser.ts"
    click useSetPhone "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/user/application/useSetPhone.ts"
    click userPersistServiceFeature "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/user/infra/userPersistService.ts"
    click parseCurrency "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/stamp/application/parseCurrencyToNumber.ts"
    click formatValue "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/stamp/application/formatValueToCurrency.ts"
    click useCalculateStamp "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/features/stamp/application/useCalculateStamp.ts"
    click StorageInterface "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/storage/storage.ts"
    click AsyncStorageImpl "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/src/storage/implementations/async-storage.ts"
    click ExternalMock "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/__mocks__/@react-native-async-storage/async-storage.js"
    click ExpoConfig "https://github.com/mayromyller/fidelizi-test-mobile/blob/main/eas.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0288D1,stroke-width:1px
    classDef business fill:#E6F4EA,stroke:#2E7D32,stroke-width:1px
    classDef infra fill:#FFE8CC,stroke:#EF6C00,stroke-width:1px
    classDef native fill:#EEEEEE,stroke:#757575,stroke-width:1px
    classDef app fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px
    classDef nav fill:#E3F2FD,stroke:#039BE5,stroke-width:1px
    classDef config fill:#F5F5F5,stroke:#9E9E9E,stroke-width:1px
```
