# chenpig3100/offline-inventory-management architecture

> Architecture diagram of the GitHub repository chenpig3100/offline-inventory-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chenpig3100/offline-inventory-management
- Repository: https://github.com/chenpig3100/offline-inventory-management

## Overview

##### Project type and purpose
- This is a React Native mobile application built with Expo.
- Its primary features include user authentication, announcement fetching, inventory management (with offline-first support), settings, and data synchronization between local storage and a backend API.

##### File structure
- Top-level entry points:
- index.js & App.js – bootstrap the Expo/React-Native app.
- app.json & package.json – configuration and dependencies.
- src/views – “screens” or “pages” (Login, Dashboard, Announcements, Inventory, Settings, etc.).
- src/components – reusable UI pieces (e.g., HintOverlay, NavSwitchBar).
- src/context – React Context for global state (AuthContext).
- src/hooks – custom hooks (useNetworkSync monitors connectivity and triggers sync).
- src/modules – domain logic (e.g., product.js defines business rules for inventory items).
- src/services – data access and synchronization (announcementApi.js for remote fetch, sync.js to reconcile local <> remote).
- src/constants & src/data – styling constants and static datasets (categories, countries).
- Native storage: expo-sqlite for relational storage, @react-native-async-storage/async-storage for key-value.

##### README for additional insights
- Dependencies: axios for HTTP, expo-sqlite + async-storage for persistence, community/netinfo for connectivity, image-picker, gesture-handler, reanimated, dropdown-picker.
- Deployment: uses EAS (Expo Application Services) for over-the-air updates.

##### Detail without over-compartmentalizing
- Separate hooks and Context from generic components.
- Both synchronous (screen → service) and asynchronous flows (background sync).
- Asset loading (image-picker) only if it factors into the core flow (e.g., product image upload).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Points
    subgraph "Entry Points"
        EI["index.js"]:::entry
        EA["App.js"]:::entry
    end

    %% UI Layer
    subgraph "UI Layer"
        V["Views"]:::ui
        C["Components"]:::ui
    end

    %% State Layer
    subgraph "State Layer"
        AC["AuthContext"]:::state
        NH["useNetworkSync"]:::state
    end

    %% Domain Layer
    subgraph "Domain Layer"
        P["Product Module"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        AA["Announcement API Service"]:::data
        SS["Sync Service"]:::data
    end

    %% Storage
    subgraph "Local Storage"
        SQ["SQLite DB"]:::storage
        AS["AsyncStorage"]:::storage
    end

    %% External Services
    subgraph "External Services"
        API["Announcement REST API"]:::external
        EAS["EAS Update Service"]:::external
    end

    %% Connections
    EI --> V
    EA --> V
    V --> C
    C --> AC
    C --> NH
    AC --> P
    NH --> SS
    P --> AA
    P --> SS
    AA --> API
    SS --> SQ
    SS --> AS
    API --> AA
    EAS --> EI

    %% Click Events
    click EI "https://github.com/chenpig3100/offline-inventory-management/blob/main/index.js"
    click EA "https://github.com/chenpig3100/offline-inventory-management/blob/main/App.js"
    click V "https://github.com/chenpig3100/offline-inventory-management/tree/main/src/views/"
    click C "https://github.com/chenpig3100/offline-inventory-management/tree/main/src/components/"
    click AC "https://github.com/chenpig3100/offline-inventory-management/blob/main/src/context/AuthContext.js"
    click NH "https://github.com/chenpig3100/offline-inventory-management/blob/main/src/hooks/useNetworkSync.js"
    click P "https://github.com/chenpig3100/offline-inventory-management/blob/main/src/modules/product.js"
    click AA "https://github.com/chenpig3100/offline-inventory-management/blob/main/src/services/announcementApi.js"
    click SS "https://github.com/chenpig3100/offline-inventory-management/blob/main/src/services/sync.js"
    click SQ "https://github.com/chenpig3100/offline-inventory-management/tree/main/src/constants/"
    click AS "https://github.com/chenpig3100/offline-inventory-management/tree/main/src/data/"
    click EAS "https://github.com/chenpig3100/offline-inventory-management/tree/main/src/assets/"

    %% Styles
    classDef entry fill:#f0f8ff,stroke:#333,stroke-width:1px
    classDef ui fill:#cce5ff,stroke:#1f78b4,stroke-width:2px
    classDef state fill:#d4edda,stroke:#28a745,stroke-width:2px
    classDef domain fill:#ffe5b4,stroke:#ff8c00,stroke-width:2px
    classDef data fill:#e0bbff,stroke:#800080,stroke-width:2px
    classDef storage fill:#f0f0f0,stroke:#808080,stroke-width:1px
    classDef external fill:#ffffff,stroke:#aaaaaa,stroke-width:1px,stroke-dasharray: 5 5
```
