# mreckah/digitalbanking-front architecture

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

- Interactive diagram: https://gitdiagram.com/mreckah/digitalbanking-front
- Repository: https://github.com/mreckah/digitalbanking-front

## Overview

##### Project type and purpose
- This is a frontend application (DigitalBank-front) built with Angular 17, enhanced with Angular Universal for server-side rendering (SSR).
- Its purpose is to provide a responsive web UI for customer and account management, and to interact with a Spring Boot REST API (E-Bank backend) over HTTP, using JWT for authentication.

##### File structure
- Top-level files:
- angular.json, tsconfig*.json – Angular CLI configuration
- server.ts, main.server.ts – Node/Express SSR entry points
- main.ts – client bundle entry point
- src/app:
- app.module.ts, app.routes.ts / app.routes.server.ts – root NgModule and routing definitions (client/server)
- app.config.ts / app.config.server.ts – environment/config abstractions (client vs. SSR)
- feature folders: accounts/, customers/, customer-account/, navbar/, etc. – component sets for each screen/feature
- services/ – injectable wrappers around HttpClient: accounts.service.ts, customer.service.ts
- model/ – TypeScript interfaces/classes: customer.model.ts, account.model.ts
- public or assets/images – static assets served at runtime

##### README for additional insights
- Confirms Angular 17, Bootstrap 5, RxJS, HttpClient, Reactive Forms.
- Explains features: customer and account CRUD, transactions, JWT-based login.
- Specifies that the backend is a separate Spring Boot service at http://localhost:8080.

##### Main components & their interactions
a. Browser Client (SPA + Hydration)
- Loads index.html → Angular bootstraps (main.ts) → client-side router/app module.
- After first load (SSR), Angular hydrates the DOM for interactivity.
b. Node/Express SSR Server
- server.ts runs an Express server.
- Uses main.server bundle to render Angular templates on the server (Universal).
- Serves pre-rendered HTML to the browser for first-paint performance and SEO.
c. Angular Application Layers
- Angular Modules: AppModule (root), feature modules implicitly grouped by folder.
- Components: accounts.component, customers.component, navbar.component, etc.
- Services: AccountsService, CustomerService call external API.
- Routing: app.routes.ts (defines /customers, /accounts, /login, etc.).
- Configuration: app.config.ts picks API URL and other flags depending on environment.
d. External Systems
- E-Bank Backend (Spring Boot REST API)
- Exposes endpoints for /customers, /accounts, /transactions, /auth.
- Authentication Flow
- LoginComponent posts credentials → backend returns JWT → stored in browser (localStorage).
- Services attach JWT in HTTP Authorization header for subsequent calls.

##### Architectural patterns & design principles
- Component-Based UI: each feature (customers, accounts) encapsulated in its own folder with view, styles, tests.
- Service Layer: single-responsibility HttpClient wrappers for domain operations.
- Model Layer: strictly typed DTOs for data consistency.
- Separation of Concerns: UI vs. data vs. config vs. routing vs. SSR.
- Universal Rendering: server-side pre-rendering for performance/SEO.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Runtime Hosts
    subgraph "Browser (Angular Client)" 
        direction TB
        IndexHTML["index.html"]:::client
        MainTS["main.ts"]:::client
        AppModule["AppModule"]:::module
        ClientRoutes["app.routes.ts"]:::module
        AppConfigClient["app.config.ts"]:::module
        subgraph "Feature Modules & Components"
            direction TB
            AccountsModule["Accounts Module"]:::module
            CustomersModule["Customers Module"]:::module
            CustomerAccountComp["Customer-Account Component"]:::module
            NavbarComp["Navbar Component"]:::module
        end
        subgraph "Services"
            direction TB
            AccountsService["AccountsService"]:::service
            CustomerService["CustomerService"]:::service
        end
        subgraph "Models"
            direction TB
            AccountModel["account.model.ts"]:::model
            CustomerModel["customer.model.ts"]:::model
        end
        Stylesheet["styles.css"]:::client
    end

    subgraph "Node/Express SSR Server"
        direction TB
        ServerTS["server.ts"]:::server
        MainServerTS["main.server.ts"]:::server
        ServerRoutes["app.routes.server.ts"]:::module
        ServerConfig["app.config.server.ts"]:::module
    end

    subgraph "Spring Boot API"
        direction TB
        BackendAPI["E-Bank REST API"]:::backend
        DB["Database"]:::db
    end

    %% Interactions
    BrowserInit[/"Initial GET /"/]:::flow -->|"HTTP GET /"| ServerTS
    ServerTS -->|"Renders via main.server.ts"| MainServerTS
    MainServerTS -->|"HTML Response"| BrowserInit
    BrowserInit -->|"Loads index.html"| IndexHTML
    IndexHTML -->|"Bootstraps Angular via main.ts"| MainTS
    MainTS -->|"Initializes"| AppModule
    AppModule -->|"Uses routes"| ClientRoutes
    AppModule -->|"Loads config"| AppConfigClient
    AppModule -->|"Declares"| AccountsModule
    AppModule -->|"Declares"| CustomersModule
    AppModule -->|"Declares"| CustomerAccountComp
    AppModule -->|"Declares"| NavbarComp
    AccountsModule -->|"Injects"| AccountsService
    CustomersModule -->|"Injects"| CustomerService
    AccountsService -->|"HTTP calls"| BackendAPI
    CustomerService -->|"HTTP calls"| BackendAPI
    BackendAPI -->|"Reads/Writes"| DB

    %% Click Events
    click MainTS "https://github.com/mreckah/digitalbanking-front/blob/main/src/main.ts"
    click ServerTS "https://github.com/mreckah/digitalbanking-front/blob/main/src/server.ts"
    click MainServerTS "https://github.com/mreckah/digitalbanking-front/blob/main/src/main.server.ts"
    click AppModule "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/app.module.ts"
    click ClientRoutes "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/app.routes.ts"
    click ServerRoutes "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/app.routes.server.ts"
    click AppConfigClient "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/app.config.ts"
    click ServerConfig "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/app.config.server.ts"
    click AccountsModule "https://github.com/mreckah/digitalbanking-front/tree/main/src/app/accounts/"
    click CustomersModule "https://github.com/mreckah/digitalbanking-front/tree/main/src/app/customers/"
    click CustomerAccountComp "https://github.com/mreckah/digitalbanking-front/tree/main/src/app/customer-account/"
    click NavbarComp "https://github.com/mreckah/digitalbanking-front/tree/main/src/app/navbar/"
    click AccountsService "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/services/accounts.service.ts"
    click CustomerService "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/services/customer.service.ts"
    click AccountModel "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/model/account.model.ts"
    click CustomerModel "https://github.com/mreckah/digitalbanking-front/blob/main/src/app/model/customer.model.ts"
    click Stylesheet "https://github.com/mreckah/digitalbanking-front/blob/main/src/styles.css"

    %% Styles
    classDef client fill:#D6EAF8,stroke:#1B4F72,color:#1B4F72
    classDef server fill:#D5F5E3,stroke:#196F3D,color:#196F3D
    classDef backend fill:#FADBD8,stroke:#922B21,color:#922B21
    classDef module fill:#FCF3CF,stroke:#B7950B,color:#7D6608
    classDef service fill:#E8E8E8,stroke:#555,color:#333
    classDef model fill:#F2F3F4,stroke:#7B7D7D,color:#1C2833
    classDef db fill:#EBDEF0,stroke:#6C3483,color:#512E5F
    classDef flow stroke-dasharray: 5 5,color:#566573
```
