# jago0710/savings-manager-deploy architecture

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

- Interactive diagram: https://gitdiagram.com/jago0710/savings-manager-deploy
- Repository: https://github.com/jago0710/savings-manager-deploy

## Overview

##### Project type and purpose
- This is a single‐page web application (SPA) built with React (via Vite) that helps users manage personal and shared savings, view metrics (income, withdrawals, loans), and collaborate in real time.
- There is no custom backend server—authentication and data persistence are handled via Firebase (Auth + Realtime Database/Firestore). The app is statically hosted (e.g., Vercel).

##### File structure
- src/
- App.jsx, main.jsx, index.css – SPA entry point and styling
- components/ – UI building blocks (cards, forms, charts)
- pages/ – routed views (Home, Dashboard, Accounts, Loans, Savings, Settings, plus auth pages)
- routes/RoutesOfNavigation.jsx – React Router setup
- context/ & hook/ – global state via Context API and custom hooks (LoginContext, useUser)
- firebase/ – Firebase client wrappers for auth and database
- database/data.js – any local seed data or mock data
- public/ – static assets (images for accounts, loans, dashboard) and landing page
- config: vite.config.js, vercel.json – build and deployment settings
- package.json – dependencies (React, Recharts, Firebase, etc.)

##### Key insights from README
- Core features: personal & shared savings, real‐time updates among multiple users, loan tracking, metrics/dashboard
- Uses Firebase—requires environment variables for credentials
- Deployed as a static site; runs locally with `npm run dev`

##### Main components
a. User’s Web Browser (Client Device)
b. Static Hosting Platform (e.g., Vercel / Netlify) serving:
- index.html + bundled JS/CSS (Vite build output)
- public/assets (images, landing page)
c. React SPA internals:
- React Router (pages & navigation)
- UI Components (cards, tables, forms)
- State Management (Context API, custom hooks)
- Data Visualization (Recharts)
d. Firebase Services (third‐party BaaS):
- Firebase Authentication
- Firebase Database (Firestore or Realtime DB)
e. Developer’s Environment (env vars for Firebase credentials)

##### Relationships & data flows
- On page load: Browser → Static Hosting → bundles → Boot React SPA
- SPA → Firebase Auth (sign-in/register)
- SPA → Firebase DB for reads/writes (accounts, transactions, loans)
- Real-time listeners push updates back to SPA → UI
- SPA internal: React Router drives which page component renders; Context provides auth/user state to all components; hooks encapsulate data access logic.

##### Architectural patterns/design principles
- Component-based UI (React)
- SPA with client-side routing (React Router)
- Global state via Context API + custom hooks for separation of concerns
- BaaS (Firebase) to offload auth & data persistence
- Static hosting + CI/CD (via vercel.json) for zero-server deployment

##### Essential elements to capture
- Client device loading static assets
- React SPA structure (Router, Context, Components)
- Firebase Auth & Database interactions (real-time)
- Deployment environment (static hosting)
- Environment variables injecting Firebase config

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Layer
    subgraph "Infrastructure" 
        direction TB
        StaticHosting["Static Hosting (Vercel)"]:::infra
        viteConfig["Build Config (Vite)"]:::infra
        vercelConfig["Deploy Config (vercel.json)"]:::infra
    end

    %% Client Browser
    UserBrowser["User's Web Browser"]:::frontend

    %% Static Hosting Assets
    StaticHosting -->|serves index.html & bundles| UserBrowser
    UserBrowser -->|requests bundles| StaticHosting
    StaticHosting -->|uses| viteConfig
    StaticHosting -->|uses| vercelConfig

    %% Client Side SPA
    subgraph "Client Side (React SPA)" 
        direction TB
        EntryPoints["Entry Points"]:::frontend
        subgraph "Entry Points"
            direction TB
            MainJS["main.jsx"]:::frontend
            AppJS["App.jsx"]:::frontend
            Styles["index.css"]:::frontend
        end

        Router["React Router"]:::frontend
        subgraph "UI Components"
            direction TB
            ComponentsDir["src/components/"]:::frontend
        end
        subgraph "Routed Pages"
            direction TB
            PagesDir["src/pages/"]:::frontend
        end
        subgraph "Global State"
            direction TB
            ContextDir["src/context/"]:::frontend
        end
        Hook["useUser (Custom Hook)"]:::frontend
        SeedData["Local Seed Data"]:::frontend
    end

    %% Firebase BaaS
    subgraph "Backend Services (Firebase)" 
        direction TB
        AuthService["Firebase Authentication"]:::backend
        DBService["Firebase Database"]:::backend
    end

    %% Flows
    UserBrowser -->|loads SPA| EntryPoints
    EntryPoints --> Router
    EntryPoints --> Styles
    Router --> ComponentsDir
    Router --> PagesDir
    ComponentsDir --> ContextDir
    PagesDir --> ContextDir
    ContextDir --> Hook
    Hook --> AuthService
    Router --> AuthService
    Router --> DBService
    DBService -->|real-time updates| Router

    %% Click Events
    click StaticHosting "https://github.com/jago0710/savings-manager-deploy/blob/main/vercel.json"
    click viteConfig "https://github.com/jago0710/savings-manager-deploy/blob/main/vite.config.js"
    click MainJS "https://github.com/jago0710/savings-manager-deploy/blob/main/src/main.jsx"
    click AppJS "https://github.com/jago0710/savings-manager-deploy/blob/main/src/App.jsx"
    click Styles "https://github.com/jago0710/savings-manager-deploy/blob/main/src/index.css"
    click Router "https://github.com/jago0710/savings-manager-deploy/blob/main/src/routes/RoutesOfNavigation.jsx"
    click ComponentsDir "https://github.com/jago0710/savings-manager-deploy/tree/main/src/components/"
    click PagesDir "https://github.com/jago0710/savings-manager-deploy/tree/main/src/pages/"
    click ContextDir "https://github.com/jago0710/savings-manager-deploy/tree/main/src/context/"
    click Hook "https://github.com/jago0710/savings-manager-deploy/blob/main/src/hook/useUser.jsx"
    click AuthService "https://github.com/jago0710/savings-manager-deploy/blob/main/src/firebase/auth.jsx"
    click DBService "https://github.com/jago0710/savings-manager-deploy/blob/main/src/firebase/database.jsx"
    click SeedData "https://github.com/jago0710/savings-manager-deploy/blob/main/src/database/data.js"
    click UserBrowser "https://github.com/jago0710/savings-manager-deploy/blob/main/index.html"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef infra fill:#ECEFF1,stroke:#455A64,color:#455A64;
```
