# luisacp27/expense-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/luisacp27/expense-tracker
- Repository: https://github.com/luisacp27/expense-tracker

## Overview

##### Project Type and Purpose
- This is a Progressive Web App (PWA) for personal finance management.
- It runs entirely in the browser (HTML/CSS/JS), provides offline-first functionality via localStorage + service worker, and syncs data to Firebase (Auth + Firestore).

##### File Structure Analysis
- Top‐level assets:
- HTML pages (index.html, settings.html, pin.html, etc.) – the PWA’s UI screens.
- css/ – global and per-page styles (styles.css).
- js/ – modular JavaScript sources:
– app.js (main UI orchestrator)
– storage-adapter.js (hybrid storage layer)
– storage.js (local wrapper)
– firebase-*.js (config, Auth, Firestore, debug)
– charts.js (Chart.js integration)
– security.js, settings.js, language.js, themes.js (cross-cutting features)
- manifest.json & service-worker.js – PWA configuration and offline caching.
- firebase.json, firestore.* – Firebase build/deploy and security rules.
- ARCHITECTURE.md – higher-level design.

##### README Insights
Frontend PWA → Storage Adapter → {Firestore ←→ localStorage}
- Key patterns: hybrid (online/offline) storage, modular JavaScript, event-driven updates, security via Web Crypto.

## Diagram (Mermaid)

```mermaid
flowchart TD
    direction TB

    subgraph "UI Layer" 
        UI_HTML["HTML Pages"]:::ui
        UI_CSS["CSS (styles.css)"]:::ui
        UI_App["app.js"]:::ui
        subgraph "Feature Modules"
            Charts["charts.js"]:::ui
            Themes["themes.js"]:::ui
            Language["language.js"]:::ui
            SecurityUI["security.js"]:::ui
            Settings["settings.js"]:::ui
        end
    end

    subgraph "PWA Assets" 
        Manifest["manifest.json"]:::ui
        ServiceWorker["service-worker.js"]:::ui
    end

    StorageAdapter["storage-adapter.js"]:::storage
    StorageJS["storage.js"]:::storage

    subgraph "Data Layer"
        LocalStore["localStorage"]:::storage
        Firestore["Firestore"]:::storage
        Auth["Firebase Auth"]:::external
    end

    Encryption["Web Crypto Module"]:::security

    External["Google Identity / Push Service"]:::external

    %% Connections
    UI_HTML -->|"load"| UI_App
    UI_CSS --> UI_HTML
    UI_App -->|"init"| Manifest
    UI_App -->|"registerSW()"| ServiceWorker
    UI_App -->|"invoke"| Charts
    UI_App -->|"invoke"| Themes
    UI_App -->|"invoke"| Language
    UI_App -->|"invoke"| SecurityUI
    UI_App -->|"invoke"| Settings
    UI_App -->|"getTransaction()"| StorageAdapter

    StorageAdapter -->|"read/write"| StorageJS
    StorageAdapter -->|"syncBatch()"| Firestore
    StorageAdapter -->|"fallback"| LocalStore
    StorageAdapter -->|"emitSyncEvent"| UI_App

    ServiceWorker -->|"intercept"| UI_HTML
    ServiceWorker -->|"cache-first"| UI_CSS
    ServiceWorker -->|"network-first"| StorageAdapter

    Firestore -->|"secured by rules"| Auth
    Auth -->|"signIn()"| External
    External -->|"authToken"| Auth

    Encryption -->|"encrypt/decrypt"| StorageAdapter
    Encryption -->|"encrypt at rest"| StorageJS

    %% Click Events
    click UI_HTML "https://github.com/luisacp27/expense-tracker/blob/main/index.html"
    click UI_CSS "https://github.com/luisacp27/expense-tracker/blob/main/css/styles.css"
    click UI_App "https://github.com/luisacp27/expense-tracker/blob/main/js/app.js"
    click Charts "https://github.com/luisacp27/expense-tracker/blob/main/js/charts.js"
    click Themes "https://github.com/luisacp27/expense-tracker/blob/main/js/themes.js"
    click Language "https://github.com/luisacp27/expense-tracker/blob/main/js/language.js"
    click SecurityUI "https://github.com/luisacp27/expense-tracker/blob/main/js/security.js"
    click Settings "https://github.com/luisacp27/expense-tracker/blob/main/js/settings.js"
    click Manifest "https://github.com/luisacp27/expense-tracker/blob/main/manifest.json"
    click ServiceWorker "https://github.com/luisacp27/expense-tracker/blob/main/service-worker.js"
    click StorageAdapter "https://github.com/luisacp27/expense-tracker/blob/main/js/storage-adapter.js"
    click StorageJS "https://github.com/luisacp27/expense-tracker/blob/main/js/storage.js"
    click Firestore "https://github.com/luisacp27/expense-tracker/blob/main/js/firebase-firestore.js"
    click Auth "https://github.com/luisacp27/expense-tracker/blob/main/js/firebase-config.js"
    click Auth "https://github.com/luisacp27/expense-tracker/blob/main/js/firebase-debug.js"
    click Authentication "https://github.com/luisacp27/expense-tracker/blob/main/auth.html"
    click External "https://github.com/luisacp27/expense-tracker/blob/main/firebase.json"
    click External "https://github.com/luisacp27/expense-tracker/blob/main/firestore.indexes.json"
    click External "https://github.com/luisacp27/expense-tracker/blob/main/firestore.rules"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085;
    classDef storage fill:#d4edda,stroke:#155724,color:#155724;
    classDef external fill:#ffe5b4,stroke:#e69500,color:#e69500;
    classDef security fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
