# i-love-flamingo/flamingo-commerce architecture

> Architecture diagram of the GitHub repository i-love-flamingo/flamingo-commerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/i-love-flamingo/flamingo-commerce
- Repository: https://github.com/i-love-flamingo/flamingo-commerce

## Overview

##### High-Level Architecture Components

a. Interface Layer (Top)
- GraphQL API endpoints
- REST Controllers
- Template Functions
- Web Controllers

b. Application Layer (Middle)
- Services
- Event Handlers
- Cache Management
- Command Handlers

c. Domain Layer (Bottom)
- Core Business Logic
- Domain Models
- Service Ports
- Value Objects

##### Core Bounded Contexts

Major module as a bounded context with clear boundaries:

- Product Context
- Cart Context
- Checkout Context
- Payment Context
- Category Context
- Customer Context
- Order Context
- Search Context
- Price Context

##### Specific Implementation Details

Specialized components:
- Infrastructure adapters (shown at the bottom of each context)
- Event publishing/handling mechanisms
- Cache implementations
- External service integrations

##### Key Elements to Highlight

a. Cart Module (Central):
- Cart domain model
- Decorator pattern implementation
- Event handling system
- Cache management

b. Checkout Flow:
- State machine implementation
- Payment integration points
- Order processing pipeline

c. Product & Category:
- Product type hierarchy
- Search integration
- Category tree structure

##### Cross-Cutting Concerns

As vertical layers:
- W3C Data Layer
- Breadcrumbs
- Price handling
- Authentication/Authorization

##### Integration Points

Clearly mark:
- GraphQL endpoints
- REST API endpoints
- External service connections
- Event buses

##### Technical Details

Annotations for:
- Go-specific implementations
- Dingo dependency injection
- Flamingo framework integration
- GraphQL schema locations

- Clean architecture principles
- Domain-driven design patterns
- Microservice readiness
- Event-driven architecture
- Clear separation of concerns

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make Flamingo Commerce unique, such as its ports and adapters pattern and its modular approach to e-commerce functionality.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef interface fill:#90EE90,stroke:#333,stroke-width:2px
    classDef application fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef domain fill:#4682B4,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef crosscutting fill:#FFD700,stroke:#333,stroke-width:2px

    %% Cross-cutting Concerns
    subgraph CrossCutting["Cross-cutting Concerns"]
        W3C["W3C Data Layer"]:::crosscutting
        Breadcrumbs["Breadcrumbs"]:::crosscutting
    end
    click W3C "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/w3cdatalayer"
    click Breadcrumbs "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/breadcrumbs"

    %% Cart Context
    subgraph Cart["Cart Context"]
        CartInt["Interface Layer"]:::interface
        CartApp["Application Layer"]:::application
        CartDom["Domain Layer"]:::domain
        CartInf["Infrastructure Layer"]:::infrastructure
    end
    click Cart "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/cart"
    click CartInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/cart/interfaces"
    click CartApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/cart/application"
    click CartDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/cart/domain"
    click CartInf "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/cart/infrastructure"

    %% Checkout Context
    subgraph Checkout["Checkout Context"]
        CheckInt["Interface Layer"]:::interface
        CheckApp["Application Layer"]:::application
        CheckDom["Domain Layer"]:::domain
        CheckInf["Infrastructure Layer"]:::infrastructure
    end
    click Checkout "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/checkout"
    click CheckInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/checkout/interfaces"
    click CheckApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/checkout/application"
    click CheckDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/checkout/domain"
    click CheckInf "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/checkout/infrastructure"

    %% Product Context
    subgraph Product["Product Context"]
        ProdInt["Interface Layer"]:::interface
        ProdApp["Application Layer"]:::application
        ProdDom["Domain Layer"]:::domain
        ProdInf["Infrastructure Layer"]:::infrastructure
    end
    click Product "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/product"
    click ProdInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/product/interfaces"
    click ProdApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/product/application"
    click ProdDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/product/domain"
    click ProdInf "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/product/infrastructure"

    %% Category Context
    subgraph Category["Category Context"]
        CatInt["Interface Layer"]:::interface
        CatApp["Application Layer"]:::application
        CatDom["Domain Layer"]:::domain
        CatInf["Infrastructure Layer"]:::infrastructure
    end
    click Category "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/category"
    click CatInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/category/interfaces"
    click CatApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/category/application"
    click CatDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/category/domain"
    click CatInf "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/category/infrastructure"

    %% Customer Context
    subgraph Customer["Customer Context"]
        CustInt["Interface Layer"]:::interface
        CustApp["Application Layer"]:::application
        CustDom["Domain Layer"]:::domain
        CustInf["Infrastructure Layer"]:::infrastructure
    end
    click Customer "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/customer"
    click CustInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/customer/interfaces"
    click CustApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/customer/application"
    click CustDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/customer/domain"
    click CustInf "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/customer/infrastructure"

    %% Order Context
    subgraph Order["Order Context"]
        OrderInt["Interface Layer"]:::interface
        OrderDom["Domain Layer"]:::domain
        OrderInf["Infrastructure Layer"]:::infrastructure
    end
    click Order "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/order"
    click OrderInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/order/interfaces"
    click OrderDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/order/domain"
    click OrderInf "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/order/infrastructure"

    %% Search Context
    subgraph Search["Search Context"]
        SearchInt["Interface Layer"]:::interface
        SearchApp["Application Layer"]:::application
        SearchDom["Domain Layer"]:::domain
    end
    click Search "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/search"
    click SearchInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/search/interfaces"
    click SearchApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/search/application"
    click SearchDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/search/domain"

    %% Payment Context
    subgraph Payment["Payment Context"]
        PayInt["Interface Layer"]:::interface
        PayApp["Application Layer"]:::application
        PayDom["Domain Layer"]:::domain
    end
    click Payment "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/payment"
    click PayInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/payment/interfaces"
    click PayApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/payment/application"
    click PayDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/payment/domain"

    %% Price Context
    subgraph Price["Price Context"]
        PriceInt["Interface Layer"]:::interface
        PriceApp["Application Layer"]:::application
        PriceDom["Domain Layer"]:::domain
    end
    click Price "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/price"
    click PriceInt "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/price/interfaces"
    click PriceApp "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/price/application"
    click PriceDom "https://github.com/i-love-flamingo/flamingo-commerce/tree/master/price/domain"

    %% Relationships
    CrossCutting --> Cart
    CrossCutting --> Checkout
    CrossCutting --> Product
    CrossCutting --> Category
    Cart --> Checkout
    Product --> Cart
    Category --> Product
    Customer --> Cart
    Checkout --> Order
    Checkout --> Payment
    Search --> Product
    Price --> Product
    Price --> Cart

    %% Legend
    subgraph Legend
        L1["Interface Layer"]:::interface
        L2["Application Layer"]:::application
        L3["Domain Layer"]:::domain
        L4["Infrastructure Layer"]:::infrastructure
        L5["Cross-cutting Concerns"]:::crosscutting
    end
```
