# federicomoron/expense-tracker-app architecture

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

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

## Overview

##### Project Type & Purpose
- Spendly is a single-page, front-end web application (Angular 20) for tracking group and personal expenses.
- It integrates with external services (REST API backend, Google Authentication) and includes PWA capabilities (service worker, manifest).

##### High-Level Architectural Layers
a. Presentation Layer (Angular UI)
- Layouts: AppLayout, FullscreenLayout
- Feature Modules: Auth, Groups, Expenses, Account, Footer
- Shared UI Components: buttons, dialogs, selectors, pipes, theme toggles
b. Core Layer (Cross-Cutting Concerns)
- Services: HTTP, Auth, Group, Expense, User, SnackBar, Theme, I18n, PWA Install
- Interceptors: Auth-Token, Unauthorized
- Guards: AuthGuard, LoginGuard, GroupGuard
- Models & Constants
c. Infrastructure / External Integrations
- REST API endpoints (configured in api-endpoints.ts)
- Google Sign-In (OAuth provider)
- Browser storage (local/session via storage-keys.ts)
- PWA (ngsw-config.json, manifest.webmanifest)
d. Build & Deployment
- Angular CLI (angular.json, tsconfig.json)
- CI/CD (GitHub Actions ci.yml)
- Lint/format (ESLint, Prettier, Husky)

##### Main Components & Their Relationships
- User’s Browser (Chrome/Safari/Edge)
→ loads index.html → boots main.ts → instantiates root AppComponent
→ routing directs to AppLayout or FullscreenLayout
→ feature components render under layouts
- Feature Components
→ invoke Core Services via Angular DI
→ call HttpService → HTTP interceptors attach tokens → outbound requests to REST API
- Core Services
→ AuthService manages login/register via Google OAuth + backend token exchange
→ GroupService, ExpenseService wrap REST API calls
→ I18nService + Transloco load translations from assets/i18n
→ ThemeService toggles SCSS variables at runtime
- External Services
→ Backend REST API (CRUD for users, groups, expenses)
→ Google OAuth for authentication
- PWA Support
→ Service worker caches assets & API responses
→ PWAInstallService displays “install” prompt

##### Architectural Patterns & Design Principles
- Feature-Based Modularization: each domain (auth, groups, expenses) is its own folder with routes, components, services
- Clean Architecture: separation of concerns (core vs. shared vs. features)
- Dependency Injection: Angular DI for services, interceptors, guards
- Standalone Components & Angular Signals: modern Angular patterns for reusability & reactive state
- Cross-Cutting via Core Module: centralized handling of auth, HTTP, state management

##### Essential Details to Capture
- Module boundaries (core vs. shared vs. features)
- Cross-cutting interceptors & guards applied to HTTP & routes
- Data flow from user actions → components → services → API → back
- i18n asset loading (assets/i18n/*.json)
- Theme toggling via SCSS variables
- CI/CD badge & build scripts can be shown as side note (optional)

##### Final Checklist
- Clear labels for each layer and component
- Callouts for important configurations (e.g., ngsw-config.json, api-endpoints.ts)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser/Client Initialization
    subgraph "Client Initialization"
        Browser["User's Browser"]:::external
        Browser -->|"loads index.html"| IndexHtml["index.html"]:::presentation
        IndexHtml -->|"boots main.ts"| MainTs["main.ts"]:::presentation
        MainTs -->|"instantiates AppComponent"| AppComp["AppComponent"]:::presentation
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Layouts"
            AppLayout["AppLayout"]:::presentation
            FullscreenLayout["FullscreenLayout"]:::presentation
        end
        subgraph "Feature Modules"
            AuthMod["Auth Module"]:::presentation
            GroupsMod["Groups Module"]:::presentation
            ExpensesMod["Expenses Module"]:::presentation
            AccountMod["Account Module"]:::presentation
            FooterMod["Footer Module"]:::presentation
        end
    end

    %% Routing from AppComponent to Layouts and Modules
    AppComp --> AppLayout
    AppComp --> FullscreenLayout
    AppLayout --> AuthMod
    AppLayout --> GroupsMod
    AppLayout --> ExpensesMod
    AppLayout --> AccountMod
    AppLayout --> FooterMod

    %% Core Layer
    subgraph "Core Layer"
        HttpSrv["HttpService"]:::core
        AuthSrv["AuthService"]:::core
        GroupSrv["GroupService"]:::core
        ExpenseSrv["ExpenseService"]:::core
        UserSrv["UserService"]:::core
        I18nSrv["I18nService"]:::core
        ThemeSrv["ThemeService"]:::core
        SnackBarSrv["SnackBarService"]:::core
        PwaInstallSrv["PWA Install Service"]:::core
        LayoutSrv["LayoutService"]:::core
        ApiStatusSrv["API Status Service"]:::core
    end

    %% Interceptors & Guards
    AuthTokenInt["Auth-Token Interceptor"]:::interceptor
    UnauthInt["Unauthorized Interceptor"]:::interceptor
    AuthGuard["Auth Guard"]:::guard
    LoginGuard["Login Guard"]:::guard
    GroupGuard["Group Guard"]:::guard

    %% External Systems
    RESTApi["REST API"]:::externalSystem
    GoogleOAuth["Google OAuth"]:::externalSystem

    %% PWA Infrastructure
    subgraph "PWA Support"
        ServiceWorker["Service Worker"]:::pwa
        Manifest["manifest.webmanifest"]:::pwa
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        AngularCLI["angular.json / tsconfig.json"]:::tooling
        CICD[".github/workflows/ci.yml"]:::tooling
        LintFormat["ESLint / Prettier / Husky"]:::tooling
    end

    %% Data Flows
    AuthMod -->|DI| AuthSrv
    GroupsMod -->|DI| GroupSrv
    ExpensesMod -->|DI| ExpenseSrv
    AccountMod -->|DI| UserSrv
    AuthSrv -->|uses| HttpSrv
    GroupSrv -->|uses| HttpSrv
    ExpenseSrv -->|uses| HttpSrv
    UserSrv -->|uses| HttpSrv
    I18nSrv -->|loads assets| HttpSrv
    ThemeSrv -->|applies| LayoutSrv

    HttpSrv --> AuthTokenInt
    AuthTokenInt --> UnauthInt
    UnauthInt --> RESTApi
    AuthSrv --> GoogleOAuth

    ServiceWorker -->|caches assets| RESTApi
    ServiceWorker -->|uses| Manifest

    %% Click Events for Component Mapping
    click AppLayout "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/layouts/app-layout/app-layout.component.ts"
    click FullscreenLayout "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/layouts/fulllscreen-layout/fullscreen-layout.component.ts"
    click AuthMod "https://github.com/federicomoron/expense-tracker-app/tree/main/src/app/features/auth"
    click GroupsMod "https://github.com/federicomoron/expense-tracker-app/tree/main/src/app/features/groups"
    click ExpensesMod "https://github.com/federicomoron/expense-tracker-app/tree/main/src/app/features/expenses"
    click AccountMod "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/features/account/account.component.ts"
    click FooterMod "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/features/footer/footer.component.ts"
    click HttpSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/http.service.ts"
    click AuthSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/auth.service.ts"
    click GroupSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/group.service.ts"
    click ExpenseSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/expenses.service.ts"
    click UserSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/user.service.ts"
    click I18nSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/i18n.service.ts"
    click ThemeSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/theme.service.ts"
    click PwaInstallSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/pwa-install.service.ts"
    click SnackBarSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/snackbar.service.ts"
    click ApiStatusSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/api-status.service.ts"
    click LayoutSrv "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/services/layout.service.ts"
    click AuthTokenInt "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/interceptors/auth-token.interceptor.ts"
    click UnauthInt "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/interceptors/unauthorized.interceptor.ts"
    click AuthGuard "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/guards/auth.guard.ts"
    click LoginGuard "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/guards/login.guard.ts"
    click GroupGuard "https://github.com/federicomoron/expense-tracker-app/blob/main/src/app/core/guards/group.guard.ts"

    %% Styling
    classDef presentation fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef core fill:#DFFFE0,stroke:#28a745,color:#28a745;
    classDef interceptor fill:#FFEFD5,stroke:#ff8c00,color:#ff8c00;
    classDef guard fill:#FFEFD5,stroke:#ff8c00,color:#ff8c00;
    classDef externalSystem fill:#F3E5FF,stroke:#6f42c1,color:#6f42c1;
    classDef external fill:#F3E5FF,stroke:#6f42c1,color:#6f42c1;
    classDef pwa fill:#E2E3E5,stroke:#6c757d,color:#6c757d,stroke-dasharray: 5 5;
    classDef tooling fill:#FFF4E5,stroke:#ffc107,color:#856404;
    class AppComp,IndexHtml,MainTs presentation
```
