# currenjin/wharf architecture

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

- Interactive diagram: https://gitdiagram.com/currenjin/wharf
- Repository: https://github.com/currenjin/wharf

## Overview

##### Main Components

a) Core Components:
- CLI Interface (Entry Point)
- Project Analyzer
- Framework Detectors
- Service Detectors
- Docker Configuration Generators
- File Writers

b) Domain Model:
- Project
- Framework
- Services (Database, Cache, MessageQueue)

##### Component Relationships

**CLI Input → Project Analysis → Detection → Generation → Output Files**

##### Input Layer
- CommandLineRunner (entry point)
- CommandLineMessage (user input processing)

##### Analysis Layer
- DefaultProjectAnalyzer
- Project domain object

##### Detection Layer (two parallel tracks)
- Framework Detectors:
- SpringBootFrameworkDetector
- NodeFrameworkDetector

- Service Detectors:
- DatabaseService (MySQL, PostgreSQL)
- CacheService (Redis)
- MessageQueueService (RabbitMQ)

##### Generation Layer
- DockerComposeGenerator
- DockerfileGenerator
- DockerServiceGenerator

##### Output Layer
- DockerConfigWriter
- Generated Files (Dockerfile, docker-compose.yml)

##### Important Details

- Supported frameworks (Spring Boot, Node.js)
- Supported services (MySQL, PostgreSQL, Redis, RabbitMQ)
- File I/O operations
- Main flow of control

##### Technical Notes

- Interface-based design (ProjectAnalyzer, FrameworkDetector, ServiceDetector)
- Domain model relationships
- Where exception handling occurs (UnsupportedFrameworkException, UnsupportedServiceException)

Remember to maintain a balance between showing the high-level architecture and including important implementation details that make Wharf unique, such as its smart detection capabilities and zero-configuration approach.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef cli fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef analyzer fill:#90EE90,stroke:#333,stroke-width:2px
    classDef detector fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef generator fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef writer fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef domain fill:#E6E6FA,stroke:#333,stroke-width:2px
    classDef exception fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% CLI Layer
    CLR[CommandLineRunner]:::cli
    CLM[CommandLineMessage]:::cli
    click CLR "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/cli/CommandLineRunner.java"
    click CLM "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/cli/CommandLineMessage.java"

    %% Analysis Layer
    DPA[DefaultProjectAnalyzer]:::analyzer
    PA[ProjectAnalyzer]:::analyzer
    click DPA "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/analyzer/DefaultProjectAnalyzer.java"
    click PA "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/analyzer/ProjectAnalyzer.java"

    %% Domain Models
    subgraph DomainModels
        PRJ[Project]:::domain
        FRM[Framework]:::domain
        SVC[Service]:::domain
        DBS[DatabaseService]:::domain
        CHS[CacheService]:::domain
        MQS[MessageQueueService]:::domain
    end
    click PRJ "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/Project.java"
    click FRM "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/Framework.java"
    click SVC "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/Service.java"
    click DBS "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/DatabaseService.java"
    click CHS "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/CacheService.java"
    click MQS "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/MessageQueueService.java"

    %% Detectors
    subgraph FrameworkDetectors
        FD[FrameworkDetector]:::detector
        SBD[SpringBootFrameworkDetector]:::detector
        NFD[NodeFrameworkDetector]:::detector
    end
    click FD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/FrameworkDetector.java"
    click SBD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/SpringBootFrameworkDetector.java"
    click NFD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/NodeFrameworkDetector.java"

    subgraph ServiceDetectors
        SD[ServiceDetector]:::detector
        MSQLD[MySQLServiceDetector]:::detector
        PSQLD[PostgreSQLServiceDetector]:::detector
        RDD[RedisServiceDetector]:::detector
        RMQD[RabbitMQServiceDetector]:::detector
    end
    click SD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/ServiceDetector.java"
    click MSQLD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/MySQLServiceDetector.java"
    click PSQLD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/PostgreSQLServiceDetector.java"
    click RDD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/RedisServiceDetector.java"
    click RMQD "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/detector/RabbitMQServiceDetector.java"

    %% Generators
    DCG[DockerComposeGenerator]:::generator
    DFG[DockerfileGenerator]:::generator
    DSG[DockerServiceGenerator]:::generator
    DCYG[DockerComposeYamlGenerator]:::generator
    click DCG "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/docker/DockerComposeGenerator.java"
    click DFG "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/docker/DockerfileGenerator.java"
    click DSG "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/docker/DockerServiceGenerator.java"
    click DCYG "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/docker/DockerComposeYamlGenerator.java"

    %% Writers
    DCW[DockerConfigWriter]:::writer
    click DCW "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/docker/DockerConfigWriter.java"

    %% Exceptions
    UFE[UnsupportedFrameworkException]:::exception
    USE[UnsupportedServiceException]:::exception
    click UFE "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/UnsupportedFrameworkException.java"
    click USE "https://github.com/currenjin/wharf/blob/main/src/main/java/com/currenjin/wharf/domain/UnsupportedServiceException.java"

    %% Relationships
    CLR --> CLM
    CLM --> DPA
    DPA --> PA
    PA --> FD
    PA --> SD

    FD --> SBD & NFD
    SD --> MSQLD & PSQLD & RDD & RMQD

    SBD & NFD --> FRM
    MSQLD & PSQLD --> DBS
    RDD --> CHS
    RMQD --> MQS

    DBS & CHS & MQS --> SVC
    FRM & SVC --> PRJ

    PRJ --> DCG & DFG & DSG
    DCG & DFG & DSG --> DCYG
    DCYG --> DCW

    %% Exception relationships
    FD -.-> UFE
    SD -.-> USE

    %% Legend
    subgraph Legend
        L1[CLI Components]:::cli
        L2[Analyzers]:::analyzer
        L3[Detectors]:::detector
        L4[Generators]:::generator
        L5[Writers]:::writer
        L6[Domain Models]:::domain
        L7[Exceptions]:::exception
    end
```
