# haradakouta/life-pwa-react architecture

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

- Interactive diagram: https://gitdiagram.com/haradakouta/life-pwa-react
- Repository: https://github.com/haradakouta/life-pwa-react

## Overview

##### Project type and purpose
- This is a full-stack Progressive Web App:
- Front-end: React + TypeScript single-page application built with Vite, served as static assets (GitHub Pages or Firebase Hosting).
- Back-end: Firebase services (Authentication, Firestore, Storage) plus Cloud Functions for transactional email.
- External integrations: AI (Gemini API), barcode/product lookup APIs (Rakuten, JAN Code, Open Food Facts), Web Notifications.
- Purpose: A life-management app combining health tracking, expense tracking, inventory/shopping lists, social features, and AI-powered advice.

##### File structure
- Top-level “src/” holds all UI code:
- api/ – wrappers for Gemini, Rakuten, etc.
- components/ – 15+ feature folders (dashboard, meals, stock, shopping, recipe, expense, report, social, auth, settings, layout, common, barcode, badges).
- store/ – Zustand stores for each domain (intake, expense, stock, shopping, recipe, settings, badge).
- config/firebase.ts – Firebase SDK initialization.
- utils/ – helpers for auth, Firestore, health advisor logic, error logging, image upload, notification, etc.
- main.tsx + App.tsx – application entry, router, top-level layout.
- “functions/” – Firebase Cloud Functions (email via Nodemailer).
- Config/deployment files: firebase.json, firestore.rules, .firebaserc, vite.config.ts, tsconfig*.json, package.json.
- CI/CD: GitHub Actions deploy workflow.

##### README
- Confirms architecture: React + TS + Vite PWA → Firebase Auth/Firestore/Storage + Cloud Functions → External AI & product APIs.
- Describes features (barcodes, AI health advisor, offline support, notifications, badges, social timeline, real-time sync).
- Lists tech stack used in each layer.

##### Diagramming conventions
- “GET/SET” between React App and Firestore
- “Publish/Subscribe” for real-time streams
- “HTTP Request” to external APIs
- “Trigger” from Firebase Authentication/Login
- “Client (Browser/PWA)”
- “Serverless Backend (Firebase + Functions)”
- “Third-Party Services”

##### Detail
- Service worker caching strategy (Asset Cache vs. Runtime Cache).
- Detail the Cloud Function trigger (HTTP callable or Firestore trigger).
- Data schema pointers (collections: users, posts, inventory, recipes, notifications).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Hosting Layer
    Hosting["Hosting/CDN\n(Firebase Hosting/GitHub Pages)"]:::hosting

    %% Client (Browser/PWA)
    subgraph "Client (Browser/PWA)"
        SW["Service Worker"]:::client
        ReactApp["React App"]:::client
        UIComponents["UI Components"]:::client
        StateMgmt["State Management\n(Zustand Stores)"]:::client
        LocalCache["localStorage"]:::client
        APIClient["API Layer\n(External & Firebase SDK)"]:::client
        Notify["Web Notifications"]:::client
    end

    %% Serverless Backend
    subgraph "Serverless Backend (Firebase + Functions)"
        Auth["Firebase Authentication"]:::firebase
        Firestore["Firestore Database"]:::firebase
        Storage["Firebase Storage"]:::firebase
        Functions["Cloud Functions"]:::functions
    end

    %% External APIs
    subgraph "Third-Party Services"
        Gemini["Google Gemini API"]:::external
        Rakuten["Rakuten Barcode API"]:::external
        OpenFood["Open Food Facts / JAN Code"]:::external
        ZXing["ZXing Barcode Scanner"]:::external
    end

    %% Connections - Hosting to Client
    Hosting --> SW
    Hosting --> ReactApp

    %% Service Worker flows
    SW --> ReactApp
    SW --> LocalCache

    %% Client flows
    ReactApp --> Auth
    ReactApp --> Firestore
    ReactApp --> Storage
    ReactApp --> APIClient
    ReactApp --> LocalCache
    ReactApp --> Notify

    APIClient --> Gemini
    APIClient --> Rakuten
    APIClient --> OpenFood

    ZXing --> APIClient

    Firestore --> ReactApp
    Auth --> Functions
    Firestore --> Functions
    Functions --> Auth

    %% Click Events for component mapping
    click ReactApp "https://github.com/haradakouta/life-pwa-react/blob/main/src/main.tsx"
    click ReactApp "https://github.com/haradakouta/life-pwa-react/blob/main/src/App.tsx"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/dashboard"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/meals"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/stock"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/shopping"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/recipe"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/expense"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/report"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/social"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/auth"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/settings"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/barcode"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/badges"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/common"
    click UIComponents "https://github.com/haradakouta/life-pwa-react/tree/main/src/components/layout"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/index.ts"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/useIntakeStore.ts"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/useExpenseStore.ts"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/useStockStore.ts"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/useShoppingStore.ts"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/useRecipeStore.ts"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/useBadgeStore.ts"
    click StateMgmt "https://github.com/haradakouta/life-pwa-react/blob/main/src/store/useSettingsStore.ts"
    click APIClient "https://github.com/haradakouta/life-pwa-react/blob/main/src/api/gemini.ts"
    click APIClient "https://github.com/haradakouta/life-pwa-react/blob/main/src/api/rakuten.ts"
    click APIClient "https://github.com/haradakouta/life-pwa-react/blob/main/src/api/vision.ts"
    click Auth "https://github.com/haradakouta/life-pwa-react/blob/main/src/config/firebase.ts"
    click Notify "https://github.com/haradakouta/life-pwa-react/blob/main/src/utils/notification.ts"
    click Functions "https://github.com/haradakouta/life-pwa-react/blob/main/functions/src/index.ts"
    click Functions "https://github.com/haradakouta/life-pwa-react/blob/main/functions/lib/index.js"
    click Hosting "https://github.com/haradakouta/life-pwa-react/blob/main/firebase.json"
    click Hosting "https://github.com/haradakouta/life-pwa-react/blob/main/firestore.rules"
    click Hosting "https://github.com/haradakouta/life-pwa-react/blob/main/.firebaserc"
    click Hosting "https://github.com/haradakouta/life-pwa-react/blob/main/vite.config.ts"
    click Hosting "https://github.com/haradakouta/life-pwa-react/blob/main/tsconfig.json"
    click Hosting "https://github.com/haradakouta/life-pwa-react/blob/main/package.json"
    click Hosting "https://github.com/haradakouta/life-pwa-react/blob/main/.github/workflows/deploy.yml"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef firebase fill:#D6F5D6,stroke:#333,stroke-width:1px
    classDef external fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef functions fill:#E3D4F5,stroke:#333,stroke-width:1px
    classDef hosting fill:#D0F0C0,stroke:#333,stroke-width:1px
```
