# chaimae-chakir/amortization architecture

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

- Interactive diagram: https://gitdiagram.com/chaimae-chakir/amortization
- Repository: https://github.com/chaimae-chakir/amortization

## Overview

##### Project type and purpose
- This is a full-stack web application (“Loan Amortization Table Generator”) consisting of:
- An Angular (TypeScript) frontend under `report-front/` that provides a UI for entering loan parameters and downloading PDFs.
- A Spring Boot (Java/Maven) backend under `report/` that exposes REST endpoints, computes amortization schedules, uses JasperReports to render the PDF, and (optionally) persists report metadata.

##### File structure
- Top-level directories:
- report-front/ – Angular CLI project (src/app/components, models, services, shared modules, configuration files).
- report/ – Spring Boot project (src/main/java for controllers, services, repositories, config, exception handlers; src/main/resources for application.properties and JRXML templates; src/test for unit tests).
- Build/deployment artifacts:
- Angular uses Vite under the .angular cache, package.json, tsconfig.
- Backend uses Maven wrapper (mvnw, pom.xml).
- Key patterns:
- Frontend follows an MVC-ish structure (components + services + models + routing).
- Backend follows layered architecture (Controller → Service → Repository + external JasperReports engine).

##### README
- Confirms Angular + Spring Boot, JasperReports for PDF generation, user-driven report download.

##### Elements
- Clear labels: e.g., “Angular App”, “ReportController”, “AmortizationCalculator”, “JasperReports Engine”, “Database”.
- From Browser → Angular Service → REST API → Controller → Service → JasperReports/Repository → back up to Browser.
- Blue rectangles for frontend modules/components
- Green rectangles for backend layers
- Protocols (HTTP/JSON), file types (JRXML → PDF), and build tools (npm, Maven) if space permits.

##### Detail
- Distinct module (e.g., amortization-table component, shared module, WebConfig, GlobalExceptionHandler).
- How JRXML in `src/main/resources/reports` flows into the reporting engine.
- Don’t oversimplify: even small services or exception handlers should appear if they play a role in the flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Angular)" 
        direction TB
        Browser["User Browser"]:::frontend
        AngularApp["Angular App (Bootstrap)"]:::frontend
        SharedModule["Shared Module"]:::frontend
        AppRouting["App Routing"]:::frontend
        AmortizationComp["AmortizationTableComponent"]:::frontend
        ReportServiceFE["ReportService (HTTP Client)"]:::frontend
        ReportModel["Report Model"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Spring Boot)"
        direction TB
        ReportApp["Spring Boot App"]:::backend
        WebConfig["WebConfig"]:::backend
        GlobalException["GlobalExceptionHandler"]:::backend
        ReportController["ReportController (REST API)"]:::backend
        ReportServiceBE["ReportService"]:::backend
        AmortCalc["AmortizationCalculator"]:::backend
        ReportRepo["ReportRepository"]:::backend
        JasperEngine["JasperReports Engine"]:::backend
        JRXML["JRXML Template"]:::backend
    end

    %% Data Store and Output
    Database[(Database)]:::db
    PDFDoc[[PDF Document]]:::doc

    %% Connections Frontend
    Browser -->|uses UI| AmortizationComp
    AngularApp --> SharedModule
    AngularApp --> AppRouting
    AmortizationComp -->|injects| ReportServiceFE
    AmortizationComp -->|uses Model| ReportModel
    ReportServiceFE -->|HTTP JSON| ReportController

    %% Connections Backend
    ReportController -->|calls| ReportServiceBE
    ReportController -->|handles exceptions| GlobalException
    ReportServiceBE -->|calculates| AmortCalc
    ReportServiceBE -->|fills JRXML| JasperEngine
    JasperEngine -->|reads| JRXML
    ReportServiceBE -->|persists metadata| ReportRepo
    ReportRepo -->|CRUD| Database

    %% Response flow
    JasperEngine -->|generates PDF| PDFDoc
    PDFDoc -->|response bytes| ReportController
    ReportController -->|HTTP response| ReportServiceFE
    ReportServiceFE -->|download| Browser

    %% Click Events Frontend
    click AngularApp "https://github.com/chaimae-chakir/amortization/tree/main/report-front/"
    click SharedModule "https://github.com/chaimae-chakir/amortization/blob/main/report-front/src/app/shared/shared.module.ts"
    click AppRouting "https://github.com/chaimae-chakir/amortization/blob/main/report-front/src/app/app.routes.ts"
    click AmortizationComp "https://github.com/chaimae-chakir/amortization/blob/main/report-front/src/app/components/amortization-table/amortization-table.component.ts"
    click ReportServiceFE "https://github.com/chaimae-chakir/amortization/blob/main/report-front/src/app/services/report.service.ts"
    click ReportModel "https://github.com/chaimae-chakir/amortization/blob/main/report-front/src/app/models/report.model.ts"
    click Browser "https://github.com/chaimae-chakir/amortization/blob/main/report-front/src/main.ts"

    %% Click Events Backend
    click ReportApp "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/java/ma/agilisys/report/ReportApplication.java"
    click WebConfig "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/java/ma/agilisys/report/config/WebConfig.java"
    click GlobalException "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/java/ma/agilisys/report/exception/GlobalExceptionHandler.java"
    click ReportController "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/java/ma/agilisys/report/controller/ReportController.java"
    click ReportServiceBE "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/java/ma/agilisys/report/service/ReportService.java"
    click AmortCalc "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/java/ma/agilisys/report/service/AmortizationCalculator.java"
    click ReportRepo "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/java/ma/agilisys/report/repository/ReportRepository.java"
    click JRXML "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/resources/reports/amortization_table.jrxml"
    click Database "https://github.com/chaimae-chakir/amortization/blob/main/report/src/main/resources/application.properties"
    click PDFDoc "https://github.com/chaimae-chakir/amortization/tree/main/report/reports/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#004085,color:#004085
    classDef backend fill:#D0FFD8,stroke:#155724,color:#155724
    classDef db fill:#FFE0B2,stroke:#7F6000,color:#7F6000
    classDef doc fill:#FFF3D4,stroke:#856404,color:#856404
```
