# lucsarruda/finance-challenge architecture

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

- Interactive diagram: https://gitdiagram.com/lucsarruda/finance-challenge
- Repository: https://github.com/lucsarruda/finance-challenge

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) built with Angular (v14), FuseTheme, TailwindCSS and Material Design.
- It’s a front-end client that displays finance data (transactions) and is hosted on Firebase. During development it uses an in‐browser mock API (Fuse Mock API), while in production it talks to the external “Moki-Api” service.

##### File structure
- Top‐level config: angular.json, tsconfig.json, firebase.json, transloco.config.js, tailwind.config.js.
- Core Angular app under /src/app:
- core module (auth, config, user, navigation, transloco)
- layout module (common UI widgets and layout variants)
- feature modules (e.g., transactions)
- mock‐api module under /src/app/mock-api for local data simulation
- shared module for re‐usable components/pipes/services
- Fuse library under /src/@fuse: reusable UI components, directives, services, styles and the mock‐api infrastructure.
- Environments: /src/environments for prod/dev configuration.

##### Readme insights
- Confirms front-end focus, dev instructions (ng serve), build (ng build → dist), unit tests (Karma), and e2e tests.
- Live link on Firebase (finance-challenge.web.app).

a. Main components
1. Browser SPA (Angular app)
2. FuseTheme UI library (packaged within the Angular build)
3. Feature modules (e.g., Transactions)
4. Core services (Auth, Config, User, Navigation, i18n loader)
5. Shared utilities (pipes, validators)
6. Mock API interceptor & handler (dev only)
7. External Moki-Api backend (production)
8. Hosting environment: Firebase Hosting
b. Relationships & interactions
- User interacts with the Browser SPA UI → UI components dispatch calls to Angular services
- AuthInterceptor attaches tokens to outbound HTTP calls
- LoadingInterceptor displays a global spinner during HTTP operations
- MockApiInterceptor intercepts HTTP calls in dev → routes them to local mock-api request handlers
- In production HTTP calls go to the external Moki-Api endpoints
- Transloco loader pulls i18n JSON from /assets/i18n
- Firebase Hosting serves the compiled JS/CSS bundles plus static assets
c. Architectural patterns & design principles
- Modular architecture: “Core”, “Shared”, “Layout”, “Feature” modules
- Layered separation: UI components → services → data layer (API)
- Dependency injection via Angular DI
- Feature modules are lazy‐loaded via app.routing.ts (if applicable)
- Environment‐based configuration (environment.ts vs environment.prod.ts)
- Mock API as a test‐double pattern for dev
d. Key technologies/frameworks/libraries
- Angular 14, Angular Material, TailwindCSS, FuseTheme
- Transloco for i18n
- Fuse Mock API module
- Firebase Hosting and configuration (firebase.json, .firebaserc)
- Karma + Jasmine for unit tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser SPA Container
    subgraph "Browser SPA" 
        direction TB
        subgraph "UI Components" 
            direction TB
            AppComponent["AppComponent"]:::ui
            AppRouting["AppRoutingModule"]:::ui
        end

        subgraph "Core Services" 
            direction TB
            AuthService["AuthService"]:::services
            ConfigService["AppConfig"]:::services
            UserService["UserService"]:::services
            NavService["NavigationService"]:::services
            I18nLoader["TranslocoHttpLoader"]:::services
            LoadingInt["LoadingInterceptor"]:::services
        end

        subgraph "Feature Modules"
            direction TB
            TransModule["TransactionsModule"]:::services
            TransComp["TransactionsComponent"]:::services
            TransForm["TransactionsFormComponent"]:::services
            TransService["TransactionsService"]:::services
        end

        subgraph "Shared Utilities"
            direction TB
            SharedModule["SharedModule"]:::services
        end

        subgraph "Fuse Library"
            direction TB
            FuseLib["@fuse Library"]:::services
        end

        subgraph "Mock API Layer (Dev Only)"
            direction TB
            MockInt["MockApiInterceptor"]:::data
            MockModule["MockApiModule"]:::data
            MockService["MockApiService"]:::data
            MockHandler["MockApiRequestHandler"]:::data
            LocalData["Mock Data Handlers"]:::data
        end
    end

    %% External and Hosting
    FirebaseHost["Firebase Hosting"]:::hosting
    StaticAssets["Static Assets CDN"]:::hosting
    MokiApi["Moki-Api Service"]:::external

    %% Data Flow - Development
    AuthService -->|attached token| LoadingInt
    LoadingInt -->|intercepts HTTP| MockInt
    MockInt -->|routes to| LocalData

    %% Data Flow - Production
    AuthService -->|attached token| LoadingInt
    LoadingInt -->|intercepts HTTP| MokiApi

    %% Assets & Hosting
    FirebaseHost -->|serves bundles| AppComponent
    FirebaseHost -->|serves assets| StaticAssets
    I18nLoader -->|fetch JSON| StaticAssets

    %% Feature interaction
    AppComponent -->|renders| TransModule
    TransModule -->|uses| TransService
    TransService -->|calls API| LoadingInt

    %% Click Events
    click AppComponent "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/app.component.ts"
    click AppRouting "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/app.routing.ts"
    click TransModule "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/modules/transactions/transactions.module.ts"
    click TransComp "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/modules/transactions/transactions.component.ts"
    click TransForm "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/modules/transactions/transactions-form.component.ts"
    click TransService "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/modules/transactions/transactions.service.ts"
    click AuthService "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/core/auth/auth.service.ts"
    click LoadingInt "https://github.com/lucsarruda/finance-challenge/blob/main/src/@fuse/services/loading/loading.interceptor.ts"
    click ConfigService "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/core/config/app.config.ts"
    click UserService "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/core/user/user.service.ts"
    click NavService "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/core/navigation/navigation.service.ts"
    click I18nLoader "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/core/transloco/transloco.http-loader.ts"
    click SharedModule "https://github.com/lucsarruda/finance-challenge/blob/main/src/app/shared/shared.module.ts"
    click FuseLib "https://github.com/lucsarruda/finance-challenge/tree/main/src/@fuse"
    click MockInt "https://github.com/lucsarruda/finance-challenge/blob/main/src/@fuse/lib/mock-api/mock-api.interceptor.ts"
    click MockModule "https://github.com/lucsarruda/finance-challenge/blob/main/src/@fuse/lib/mock-api/mock-api.module.ts"
    click MockService "https://github.com/lucsarruda/finance-challenge/blob/main/src/@fuse/lib/mock-api/mock-api.service.ts"
    click MockHandler "https://github.com/lucsarruda/finance-challenge/blob/main/src/@fuse/lib/mock-api/mock-api.request-handler.ts"
    click LocalData "https://github.com/lucsarruda/finance-challenge/tree/main/src/app/mock-api"
    click FirebaseHost "https://github.com/lucsarruda/finance-challenge/blob/main/firebase.json"
    click StaticAssets "https://github.com/lucsarruda/finance-challenge/tree/main/public/assets/"
    click MokiApi "https://github.com/lucsarruda/finance-challenge/tree/main/n/a"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef services fill:#D0FFD8,stroke:#333,stroke-width:1px
    classDef data fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef external fill:#FFCDD2,stroke:#333,stroke-width:1px
    classDef hosting fill:#F5F5F5,stroke:#333,stroke-width:1px
```
