# ohyeahyao/2024-interview architecture

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

- Interactive diagram: https://gitdiagram.com/ohyeahyao/2024-interview
- Repository: https://github.com/ohyeahyao/2024-interview

## Overview

- Outer (Infrastructure) Layer: This includes web and application entry points such as:
- The HTTP layer under app/Http (with controllers like CheckAndTransformOrderController).
- Service Providers under app/Providers (e.g. OrderServiceProvider that inject dependencies into the domain).
- Configuration files (config/*) and environment definitions (.env.example).
- Docker configuration located in docker/php for deployment/containerization.
- Middle (Application) Layer: Represents orchestration and use case implementations:
- Located primarily in modules/Order/UseCases (e.g., CurrencyConverter) and additional controllers orchestrating business logic.
- It serves as a mediator between the delivery of HTTP requests and the inner domain logic.
- Core (Domain) Layer: Contains the essential business logic and domain rules:
- Modules/Order contains Entities (Order), Value Objects (Address), Enums (Currency) and Exceptions.
- Conversion strategies (modules/Order/ConversionStrategies) are implemented here using design patterns (abstract factory for CurrencyStrategyFactory and strategy pattern for OrderFormatValidator).
- Shared rules and validations (modules/Shared/Rules) used across modules.
- Supporting (Testing) Layer: Testing directories (tests/Feature, tests/Unit) ensure quality and validate domain behavior.

##### Establish Relationships and Flow
- Dependency Injection: Indicate that the Controller utilizes the CurrencyConverter, which in turn relies on the CurrencyStrategyFactory and validator interfaces to perform currency conversion and order validation.
- Domain Isolation: Emphasize that the Domain model (Order entity, conversion strategies, validators) is insulated from external dependencies, following the principles of Onion Architecture.

##### Architectural Patterns and Design Principles
- Implementation of the design patterns:
- Abstract Factory Pattern in CurrencyStrategyFactory.
- Strategy Pattern in OrderFormatValidator.
- That dependency injection (e.g., via the OrderServiceProvider) is used to pass concrete implementations of interfaces into consuming classes.

##### Incorporate Technological and External Elements
- Web Server & Docker: Represent the deployment container (docker/php) integrated with the Laravel public/index.php as the entry point.
- Database & External Services: Although not explicitly detailed in the README, include a database component as guided by the presence of migrations and seeders. If the project involves queues or external APIs (as hinted in config/queue and config/services), show those dependencies.
- That the Build and CI tools (GitHub Actions workflows, phpunit for testing, and Code Coverage reports) are part of the development infrastructure.

##### Detailed Element Inclusions
- For a full-stack API project like this:
- That the Controllers in app/Http are part of the entry point handling HTTP requests.
- In the Domain, include elements such as Entities (Order), Value Objects (Address), Enums (Currency), and the conversion strategies and validators.
- Dependency injection flow from outer providers to domain services.
- Mention the Docker and CI/CD pipelines to show deployment and quality assurance aspects, even though they reside outside the core application logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        CT["CheckAndTransformOrderController"] 
        SP["OrderServiceProvider"]
        DC["Docker Config"]
    end

    %% Application Layer
    subgraph "Application Layer"
        CC["CurrencyConverter Use Case"]
    end

    %% Domain Layer
    subgraph "Domain Layer"
        OE["Order Entity"]
        AV["Address Value Object"]
        CE["Currency Enum"]
        CSF["CurrencyStrategyFactory"]
        JTS["JpyToTwdConversionStrategy"]
        UTS["UsdToTwdConversionStrategy"]
        OFV["OrderFormatValidator"]
        SDR["Shared Domain Rules"]
    end

    %% Testing/Supporting Layer
    subgraph "Testing/Supporting Layer"
        TI["Testing Infrastructure"]
    end

    %% Connections - Data Flow & Dependency Injection
    DC -->|"deploys"| CT
    CT -->|"calls"| CC
    SP -->|"injects"| CC
    CC -->|"uses"| CSF
    CC -->|"uses"| OFV
    CSF -->|"selects"| JTS
    CSF -->|"selects"| UTS
    CC -->|"processes"| OE
    OE -->|"has"| AV
    OE -->|"uses"| CE
    OE -->|"applies"| SDR
    CC -->|"response"| CT
    TI -->|"tests"| OE
    TI -->|"tests"| CC

    %% Class Definitions for Color Coding
    class CT,SP,DC infrastructure
    class CC application
    class OE,AV,CE,CSF,JTS,UTS,OFV,SDR domain
    class TI testing

    %% Styles
    classDef infrastructure fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef application fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef domain fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef testing fill:#F5B7B1,stroke:#333,stroke-width:2px;

    %% Click Events
    click CT "https://github.com/ohyeahyao/2024-interview/blob/main/app/Http/Controllers/CheckAndTransformOrderController.php"
    click SP "https://github.com/ohyeahyao/2024-interview/blob/main/app/Providers/OrderServiceProvider.php"
    click DC "https://github.com/ohyeahyao/2024-interview/tree/main/docker/php"
    click CC "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/UseCases/CurrencyConverter.php"
    click OE "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/Entities/Order.php"
    click AV "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/ValueObjects/Address.php"
    click CE "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/Enums/Currency.php"
    click CSF "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/ConversionStrategies/CurrencyStrategyFactory.php"
    click JTS "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/ConversionStrategies/JpyToTwdConversionStrategy.php"
    click UTS "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/ConversionStrategies/UsdToTwdConversionStrategy.php"
    click OFV "https://github.com/ohyeahyao/2024-interview/blob/main/modules/Order/Validators/OrderFormatValidator.php"
    click SDR "https://github.com/ohyeahyao/2024-interview/tree/main/modules/Shared/Rules"
    click TI "https://github.com/ohyeahyao/2024-interview/tree/main/tests"
```
