# oktaliem/creditcardconverter architecture

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

- Interactive diagram: https://gitdiagram.com/oktaliem/creditcardconverter
- Repository: https://github.com/oktaliem/creditcardconverter

## Overview

##### Project type and purpose
- This is a small, standalone Java library/CLI tool whose sole responsibility is to mask credit-card numbers according to various patterns.
- It uses Maven for build, JUnit (4.12) for testing, and has a single entry point: CreditCardMaskApplication.

##### File structure
- Top-level:
- pom.xml — Maven build, dependency, and plugin configuration
- README.md — project description and sample test logs
- src/main/java/com/test/application
- CreditCardMaskApplication.java — main application logic (parses input, delegates to masking service)
- src/test/java/com/test/application/test
- CreditCardMaskTest.java — JUnit test cases covering input variations and expected outputs

##### Key components
a. CreditCardMaskApplication (CLI or Library API)
b. MaskingService (core business logic)
c. MaskStrategy or PatternHandlers (encapsulate various masking formats)
d. Input Parser / Validator (ensures non-empty number, valid mask parameter)
e. Output Generator (formats result or error messages)
f. Test Suite (JUnit harness)
g. Maven Build & Dependency Manager (pom.xml)

##### Relationships and data-flow
- Input enters via the Application layer (CLI args or API call)
- Application invokes Input Parser → Validation
- Valid data passed to MaskingService
- MaskingService selects appropriate MaskStrategy (e.g., star-mask, block-mask)
- MaskStrategy returns masked string
- Application routes result to Output Generator → STDOUT/Error code
- JUnit Test Suite invokes MaskingService directly and asserts results
- Maven orchestrates compile → test → package phases

##### Architectural patterns and principles
- Single Responsibility: each strategy handles one masking pattern
- Strategy Pattern: interchangeable masking algorithms passed to the service
- Layered approach:
- Presentation (CLI/API)
- Application (orchestration)
- Domain (masking logic)
- Infrastructure (Maven, JUnit)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Presentation Layer"
        Input["Input/CLI"]:::presentation
        App["CreditCardMaskApplication"]:::presentation
        Parser["Input Parser/Validator"]:::presentation
        Output["Output Formatter"]:::presentation
    end

    subgraph "Domain Layer"
        Service["MaskingService"]:::core
        StrategyA["MaskStrategy A"]:::core
        StrategyB["MaskStrategy B"]:::core
    end

    subgraph "Infrastructure"
        Maven["Maven pom.xml"]:::infra
        README["README.md"]:::infra
        Compile["Compile"]:::infra
        TestPhase["Test"]:::infra
        Package["Package"]:::infra
    end

    Test["JUnit Test Suite"]:::test
    STDOUT["STDOUT / ErrorCodes"]:::presentation

    Input --> App
    App --> Parser
    Parser --> Service
    Service --> StrategyA
    Service --> StrategyB
    StrategyA --> Service
    StrategyB --> Service
    Service --> App
    App --> Output
    Output --> STDOUT

    Test --> Service
    Test --> App

    Maven --> Compile
    Compile --> TestPhase
    TestPhase --> Package

    click App "https://github.com/oktaliem/creditcardconverter/blob/master/src/main/java/com/test/application/CreditCardMaskApplication.java"
    click Service "https://github.com/oktaliem/creditcardconverter/tree/master/src/main/java/com/test/application"
    click StrategyA "https://github.com/oktaliem/creditcardconverter/tree/master/src/main/java/com/test/application"
    click StrategyB "https://github.com/oktaliem/creditcardconverter/tree/master/src/main/java/com/test/application"
    click Parser "https://github.com/oktaliem/creditcardconverter/tree/master/src/main/java/com/test/application"
    click Output "https://github.com/oktaliem/creditcardconverter/tree/master/src/main/java/com/test/application"
    click Test "https://github.com/oktaliem/creditcardconverter/blob/master/src/test/java/com/test/application/test/CreditCardMaskTest.java"
    click Maven "https://github.com/oktaliem/creditcardconverter/blob/master/pom.xml"
    click README "https://github.com/oktaliem/creditcardconverter/blob/master/README.md"

    classDef presentation fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef core fill:#bbdefb,stroke:#0d47a1,stroke-width:1px
    classDef infra fill:#eeeeee,stroke:#757575,stroke-width:1px
    classDef test fill:#ffe0b2,stroke:#ef6c00,stroke-width:1px
```
