# renzomedina/calculate-order-mv architecture

> Architecture diagram of the GitHub repository renzomedina/calculate-order-mv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/renzomedina/calculate-order-mv
- Repository: https://github.com/renzomedina/calculate-order-mv

## Overview

##### Project Type and Purpose
- Full-stack? No UI here—this is a backend service (library/CLI style) that calculates order totals.
- Purpose: read a list of products, validate inputs, apply discounts, compute totals, and demonstrate unit testing and CI/CD.

##### File Structure
- src/main/java/com/ejemplo
- App.java – application entry point
- OrderService.java – core logic for summing products
- DiscountService.java – applies discount rules
- src/test/java/com/ejemplo
- Unit tests for App, OrderService, OrderService with mocks
- pom.xml – Maven build, dependencies, plugins (JUnit, JaCoCo)
- .github/workflows/maven-ci.yml – GitHub Actions pipeline

##### README Insights
- Stacks: Java 17+, Maven, JUnit, JaCoCo, GitHub Actions
- Input validation, unit testing, coverage reporting, CI automation

##### Main Components
a. Runtime Components
- Application (App)
- OrderService
- DiscountService
b. Supporting Tools / Build & Pipeline
- Maven Build
- JUnit Tests
- JaCoCo Coverage
- GitHub Actions CI

##### Relationships and Data Flow
- At runtime:
1. App reads input (list of products)
2. App calls OrderService.calculateTotal(products)
3. OrderService invokes DiscountService.applyDiscounts(order)
4. DiscountService returns adjusted totals → OrderService returns final total → App outputs result
- In CI: GitHub Actions triggers Maven → compiles code, runs JUnit tests → JaCoCo plugin generates coverage report

##### Architectural Patterns / Principles
- Service decomposition: business logic separated into OrderService and DiscountService
- Dependency injection (if used) or simple instantiation to allow mocking in tests
- Layered organization: application entrypoint vs. service layer vs. test layer

##### Technologies & Frameworks
- Java 17
- Maven (pom.xml)
- JUnit + Mockito (for OrderServiceMockTest)
- JaCoCo (coverage)
- GitHub Actions (CI pipeline)

##### Putting It All Together
Tier 1 (left) – CLI/Application Layer: App.java
Tier 2 (center) – Service Layer: OrderService, DiscountService
Tier 3 (right) – Data/Output: console output or generated total
- Below or aside, show the CI/CD pipeline:
- GitHub Actions → Maven compile/test → JUnit → JaCoCo report

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Runtime Architecture
    subgraph "Runtime Architecture"
        direction TB
        App["App"]:::biz
        OrderService["OrderService"]:::biz
        DiscountService["DiscountService"]:::biz
        Output["Console Output (Total)"]:::biz

        App -->|"calculateTotal(products)"| OrderService
        OrderService -->|"applyDiscounts(order)"| DiscountService
        DiscountService -->|"discounted order"| OrderService
        OrderService -->|"final total"| App
        App -->|"print total"| Output
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GitHub["GitHub Actions"]:::cicd
        Maven["Maven Build"]:::cicd
        JUnit["JUnit Tests"]:::test
        JaCoCo["JaCoCo Coverage"]:::test

        GitHub -->|"trigger pipeline"| Maven
        Maven -->|"compile & test"| JUnit
        Maven -->|"generate report"| JaCoCo
    end

    %% Click Events
    click App "https://github.com/renzomedina/calculate-order-mv/blob/main/src/main/java/com/ejemplo/App.java"
    click OrderService "https://github.com/renzomedina/calculate-order-mv/blob/main/src/main/java/com/ejemplo/OrderService.java"
    click DiscountService "https://github.com/renzomedina/calculate-order-mv/blob/main/src/main/java/com/ejemplo/DiscountService.java"
    click AppTest "https://github.com/renzomedina/calculate-order-mv/blob/main/src/test/java/com/ejemplo/AppTest.java"
    click OrderServiceTest "https://github.com/renzomedina/calculate-order-mv/blob/main/src/test/java/com/ejemplo/OrderServiceTest.java"
    click OrderServiceMockTest "https://github.com/renzomedina/calculate-order-mv/blob/main/src/test/java/com/ejemplo/OrderServiceMockTest.java"
    click Pom "https://github.com/renzomedina/calculate-order-mv/blob/main/pom.xml"
    click Workflow "https://github.com/renzomedina/calculate-order-mv/blob/main/.github/workflows/maven-ci.yml"

    %% Styles
    classDef biz fill:#D6EAF8,stroke:#2874A6,color:#1B4F72
    classDef cicd fill:#D5F5E3,stroke:#27AE60,color:#1E8449
    classDef test fill:#FCF3CF,stroke:#F1C40F,color:#B7950B
```
