# hotwax/inventory-count architecture

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

- Interactive diagram: https://gitdiagram.com/hotwax/inventory-count
- Repository: https://github.com/hotwax/inventory-count

## Overview

##### Project type and purpose
- This is a cross‐platform inventory‐counting application built with Ionic Framework (Vue) that runs as:
- A Progressive Web App (Ionic serve / PWA)
- Native Android app via Capacitor
- Native iOS app via Capacitor
- It communicates with a remote backend (RESTful API) and supports offline usage with local storage/indexedDB.

##### File structure
- Top level: configuration files (.env, firebase.json, capacitor.config.json), mobile platforms (android/, ios/), public assets, and the core source under src/.
- src/ contains:
- views/ & components/ – UI layer (Ionic Vue components)
- router/ – Vue Router for navigation
- store/ – Vuex modules (count, product, user, util) implementing state management (Flux/MVVM pattern)
- services/ – TypeScript classes wrapping HTTP calls to the backend API
- adapter/, api/ – abstraction layers for API endpoints
- offline-helper/ – logic handling offline data sync
- event-bus/ – Vue event bus for cross‐component communication
- i18n/ & locales/ – internationalization
- utils/, logger/ – utility functions and logging
- android/ and ios/ hold the native wrappers generated by Capacitor, linking the web assets to platform projects.
- Configuration for CI/CD: GitHub workflows (.github/workflows) and Firebase Hosting (firebase.json).

##### README for insights
- The README confirms:
- Firebase CLI + Hosting is used for web deployments
- Ionic/Cordova CLI is used for builds
- vue-cli-service builds for different modes (staging, production)
- Capacitor performs “copy” into native projects
- Contribution & release processes use GitHub Actions.

##### Major components and their relationships
a. Frontend (Ionic Vue):
– UI Views & Components (views/, components/)
– Router (router/)
– Vuex Store (store/)
– Services & Adapters (services/, adapter/, api/)
– Offline Helper & Event Bus (offline-helper/, event-bus/)
– i18n & Logger (i18n.ts, logger/)
b. Native Platforms (Capacitor wrappers):
– Android project (android/)
– iOS project (ios/)
– Capacitor runtime bridges web code to native APIs
c. External Backend API:
– REST endpoints consumed by services (CountService, ProductService, etc.)
– Authentication & Authorization (authorization/)
d. Data Stores:
– Remote DB (behind backend API)
– Local storage/indexedDB for offline caching (offline-helper/)
– Vuex in‐memory store for app state
e. Deployment & CI/CD:
– GitHub Actions → build & test → Firebase Hosting
– Ionic/Cordova CLI for local builds → Capacitor copy → deploy to app stores

##### Architectural patterns & design principles
- MVVM / Flux: Views ↔ Vuex Store ↔ Services
- Modular state: store/modules per domain (count, product, user, util)
- Layered API abstraction: adapter → api → services → store → UI
- Offline‐first: offline-helper manages sync between local and remote
- Platform‐agnostic UI: Ionic Components for both web & native

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Web App Layer
    subgraph "Web App (Ionic Vue)"
        direction TB
        subgraph "Frontend UI" 
            direction TB
            Views["Views"]:::frontend
            Components["Components"]:::frontend
            Router["Router"]:::frontend
        end
        subgraph "State Management"
            direction TB
            StoreRoot["Vuex Store (Root)"]:::frontend
            subgraph "Store Modules"
                direction TB
                CountModule["count module"]:::frontend
                ProductModule["product module"]:::frontend
                UserModule["user module"]:::frontend
                UtilModule["util module"]:::frontend
            end
        end
        subgraph "Business Logic"
            direction TB
            Services["Services"]:::frontend
            Adapter["Adapter Layer"]:::frontend
            API["API Abstraction"]:::frontend
        end
        subgraph "Offline & Events"
            direction TB
            OfflineHelper["Offline Helper"]:::frontend
            EventBus["Event Bus"]:::frontend
        end
        subgraph "Utilities & Config"
            direction TB
            I18n["i18n"]:::frontend
            Logger["Logger"]:::frontend
            Utils["Utils"]:::frontend
            Authz["Authorization"]:::frontend
        end
    end

    %% Data Stores
    LocalDB["Local IndexedDB"]:::datastore
    RemoteDB["Remote Database"]:::datastore

    %% External Services
    BackendAPI["Backend API"]:::external
    FirebaseHost["Firebase Hosting"]:::external

    %% Native Shell
    subgraph "Native Shell"
        direction TB
        Capacitor["Capacitor Bridge"]:::native
        Android["Android"]:::native
        iOS["iOS"]:::native
    end

    %% CI/CD
    subgraph "CI/CD Pipeline"
        direction TB
        GitHubActions["GitHub Actions"]:::ci
        FirebaseDeploy["Firebase Deploy"]:::ci
    end

    %% Connections
    Views -->|"renders"| StoreRoot
    Components -->|dispath actions| StoreRoot
    Router -->|navigates| Views

    StoreRoot -->|calls actions| CountModule
    StoreRoot -->|calls actions| ProductModule
    StoreRoot -->|calls actions| UserModule
    StoreRoot -->|calls actions| UtilModule

    CountModule -->|uses| Services
    ProductModule -->|uses| Services
    UserModule -->|uses| Services
    UtilModule -->|uses| Services

    Services -->|calls| Adapter
    Adapter -->|calls| API
    API -->|HTTP| BackendAPI

    OfflineHelper -->|sync| LocalDB
    StoreRoot -->|reads/writes| LocalDB
    OfflineHelper -->|sync| BackendAPI

    EventBus -->|events| Views
    EventBus -->|events| Components

    I18n -->|provides| Views
    Logger -->|logs| Services
    Utils -->|used by| Services
    Authz -->|secures| API

    BackendAPI -->|reads/writes| RemoteDB

    Capacitor -->|bridges| Views
    Capacitor -->|bridges| Components
    Capacitor --> Android
    Capacitor --> iOS

    GitHubActions -->|build & test| FirebaseDeploy
    FirebaseDeploy -->|deploys| FirebaseHost
    FirebaseHost -->|serves PWA| Views

    %% Click Events
    click Views "https://github.com/hotwax/inventory-count/tree/main/src/views/"
    click Components "https://github.com/hotwax/inventory-count/tree/main/src/components/"
    click Router "https://github.com/hotwax/inventory-count/blob/main/src/router/index.ts"
    click StoreRoot "https://github.com/hotwax/inventory-count/blob/main/src/store/index.ts"
    click CountModule "https://github.com/hotwax/inventory-count/tree/main/src/store/modules/count/"
    click ProductModule "https://github.com/hotwax/inventory-count/tree/main/src/store/modules/product/"
    click UserModule "https://github.com/hotwax/inventory-count/tree/main/src/store/modules/user/"
    click UtilModule "https://github.com/hotwax/inventory-count/tree/main/src/store/modules/util/"
    click Services "https://github.com/hotwax/inventory-count/tree/main/src/services/"
    click Adapter "https://github.com/hotwax/inventory-count/blob/main/src/adapter/index.ts"
    click API "https://github.com/hotwax/inventory-count/blob/main/src/api/index.ts"
    click OfflineHelper "https://github.com/hotwax/inventory-count/blob/main/src/offline-helper/index.ts"
    click EventBus "https://github.com/hotwax/inventory-count/blob/main/src/event-bus/index.ts"
    click I18n "https://github.com/hotwax/inventory-count/blob/main/src/i18n.ts"
    click Logger "https://github.com/hotwax/inventory-count/blob/main/src/logger/index.ts"
    click Utils "https://github.com/hotwax/inventory-count/blob/main/src/utils/index.ts"
    click Authz "https://github.com/hotwax/inventory-count/tree/main/src/authorization/"
    click Android "https://github.com/hotwax/inventory-count/tree/main/android/"
    click iOS "https://github.com/hotwax/inventory-count/tree/main/ios/"
    click GitHubActions "https://github.com/hotwax/inventory-count/tree/main/.github/workflows/"
    click FirebaseHost "https://github.com/hotwax/inventory-count/blob/main/firebase.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0066CC,color:#000;
    classDef datastore fill:#DFFFD0,stroke:#33CC00,color:#000;
    classDef external fill:#FFE8C0,stroke:#FF9900,color:#000;
    classDef native fill:#E0E0E0,stroke:#888888,color:#000;
    classDef ci fill:#F2D0F0,stroke:#C000C0,color:#000;
```
