# sgra64/mvn-fun architecture

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

- Interactive diagram: https://gitdiagram.com/sgra64/mvn-fun
- Repository: https://github.com/sgra64/mvn-fun

## Overview

##### Project Type and Purpose
- This is a single‐module, console‐based Java application (CLI tool) built and managed with Maven.
- Purpose: factorize positive integers passed as command‐line arguments and display their prime factors, with an indicator for prime inputs.

##### High‐Level Components
- Source Code
- App (Entry point)
- Factorizer interface + FactorizerImpl (lazy singleton)
- JUnit tests (AppTest, FactorizerTests)
- Build System
- pom.xml (Maven project descriptor)
- Maven Lifecycle (validate → compile → test → package → install → deploy)
- Local .m2 repository for dependencies
- Version Control
- Git repository with branches: main, factorizer, release
- Runtime Platform
- JVM hosting the packaged JAR

##### Relationships and Data Flows
- Developer → Git → Source Code
- Developer/Maven CLI → Maven → Reads pom.xml →
- src/main/java → compile → target/classes
- src/test/java → test → surefire-reports
- package → target/*.jar
- JVM → Loads packaged JAR → App.main(args) → Factorizer.getInstance() → factorize(n) → stdout
- Git branching: feature work on factorizer branch, merge (squash) into release branch, tag RELEASE-1.0.0, then push to remote.

##### Architectural Patterns & Design Principles
- Component Pattern: factorization logic encapsulated behind Factorizer interface.
- Singleton Pattern: lazy instantiation of FactorizerImpl via static getInstance().
- Layered separation:
- Presentation/CLI layer (App)
- Domain/Service layer (Factorizer)
- Build/Test layer managed by Maven and JUnit
- Convention‐over‐configuration: standard Maven directory layout.

- validate → compile (src/main → target/classes)
- test (src/test → reports)
- package (target/*.jar)
- App (CLI entrypoint) that invokes → Factorizer (singleton service).

##### Details
- Package‐to‐file‐path mapping (e.g., de/factorizer/App.java).
- Call out the singleton pattern on FactorizerImpl (e.g., «lazy singleton» stereotype).
- Pom.xml as the configuration/resource driving the build.
- Optionally overlay Git branch merge graph as a footnote to illustrate branching strategy.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Dev["Developer Workstation"]:::actor

    Dev -->|"git push/fetch"| Git["Git Repository\nbranches: main, factorizer, release"]:::vcs
    click Git "https://github.com/sgra64/mvn-fun/blob/main/README.md"

    Dev -->|"mvn clean clean compile test package"| Maven["Maven Build System"]:::build
    Maven --> Pom["pom.xml"]:::build
    click Pom "https://github.com/sgra64/mvn-fun/blob/main/pom.xml"

    subgraph "Maven Lifecycle"
        Validate["validate"]:::build
        Compile["compile\n(src/main → target/classes)"]:::build
        TestPhase["test\n(src/test/java → surefire-reports)"]:::build
        Package["package\n(target/*.jar)"]:::build
        Validate --> Compile --> TestPhase --> Package
    end

    Maven --> Validate
    Maven -->|"resolves deps"| M2[("Local .m2 Repository")]:::repo
    Package --> JAR["Packaged JAR Artifact"]:::build

    JAR -->|"java -jar"| JVMRuntime["JVM Runtime"]:::runtime

    subgraph "Inside JVM Runtime"
        App["App (CLI Entry Point)\ncom.mycompany.app.App"]:::code
        FactI["Factorizer Interface\ncom.mycompany.app.Factorizer"]:::code
        FactImpl["FactorizerImpl\n«lazy singleton»"]:::code
        Output["Console Output"]:::output

        App -->|"getInstance() → factorize(n)"| FactImpl
        FactImpl -->|"writes factors"| Output
    end

    TestPhase --> Tests["JUnit Test Suite\nAppTest, FactorizerTests"]:::test
    Tests -->|"test results (pass/fail)"| TestPhase

    classDef code fill:#cce5ff,stroke:#004085,color:#004085;
    classDef build fill:#d4edda,stroke:#155724,color:#155724;
    classDef vcs fill:#fff3cd,stroke:#856404,color:#856404;
    classDef repo fill:#fff5c6,stroke:#856404,color:#856404,shape:cylinder;
    classDef runtime fill:#e2e3e5,stroke:#6c757d,color:#6c757d,shape:cloud;
    classDef test fill:#f5c6cb,stroke:#721c24,color:#721c24;
    classDef actor fill:#e2f0fb,stroke:#0b2e59,color:#0b2e59;
    classDef output fill:#f8d7da,stroke:#721c24,color:#721c24;
```
