# gavinklfong/stream-api-exercises architecture

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

- Interactive diagram: https://gitdiagram.com/gavinklfong/stream-api-exercises
- Repository: https://github.com/gavinklfong/stream-api-exercises

## Overview

##### Main Components

a) Application Layer:
- Inside this container, create three main sections:
- Models (Customer, Order, Product)
- Repositories (CustomerRepo, OrderRepo, ProductRepo)
- Stream API Test Components

b) Database Layer:
- H2 In-Memory Database
- Table relationships matching the data model
- Auto-initialization process (data.sql, table_script.ddl)

##### Specific Elements

a) Models Section:

- Models     |

- Customer    |
- Order       |
- Product     |

b) Repository Layer:

- Repositories   |

- CustomerRepo   |
- OrderRepo      |
- ProductRepo    |

c) Test Component:

- Stream API Tests |

- 15 Exercises   |

##### Additional Details

- A note about Lombok integration
- Data initialization flow during startup
- Relationship cardinality between models (1-to-many relationships)

## Diagram (Mermaid)

```mermaid
flowchart TB
    title["Java Stream API Exercises - System Architecture"]

    subgraph SpringBoot["Spring Boot Application"]
        direction TB
        
        subgraph Models["Domain Models"]
            direction TB
            Customer["Customer Model"]:::model
            Order["Order Model"]:::model
            Product["Product Model"]:::model
        end

        subgraph Repos["Data Repositories"]
            direction TB
            CustomerRepo["Customer Repository"]:::repo
            OrderRepo["Order Repository"]:::repo
            ProductRepo["Product Repository"]:::repo
        end

        subgraph Tests["Stream API Tests"]
            direction TB
            StreamTests["15 Stream API Exercises"]:::test
        end

        AppCore["Application Core"]:::core
        AppRunner["Application Runner"]:::core
    end

    subgraph DB["Database Layer"]
        direction TB
        H2["H2 In-Memory Database"]:::db
        DBData["Database Data"]:::db
        DBSchema["Schema Definition"]:::db
        DBConfig["Database Configuration"]:::db
    end

    %% Relationships
    Customer --> Order
    Order --> Product
    
    CustomerRepo --> Customer
    OrderRepo --> Order
    ProductRepo --> Product
    
    Customer --> H2
    Order --> H2
    Product --> H2
    
    StreamTests --> CustomerRepo
    StreamTests --> OrderRepo
    StreamTests --> ProductRepo
    
    AppCore --> AppRunner
    AppRunner --> Repos
    
    DBData --> H2
    DBSchema --> H2
    DBConfig --> H2

    %% Click Events
    click Customer "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/models/Customer.java"
    click Order "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/models/Order.java"
    click Product "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/models/Product.java"
    
    click CustomerRepo "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/repos/CustomerRepo.java"
    click OrderRepo "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/repos/OrderRepo.java"
    click ProductRepo "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/repos/ProductRepo.java"
    
    click AppCore "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/DemoApplication.java"
    click AppRunner "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/java/space/gavinklfong/demo/streamapi/AppCommandRunner.java"
    
    click DBData "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/resources/data.sql"
    click DBSchema "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/resources/table_script.ddl"
    click DBConfig "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/main/resources/application.properties"
    
    click StreamTests "https://github.com/gavinklfong/stream-api-exercises/blob/main/src/test/java/space/gavinklfong/demo/streamapi/StreamApiTest.java"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef model fill:#FFC107,stroke:#FFA000,color:black
    classDef repo fill:#FF9800,stroke:#F57C00,color:white
    classDef test fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef db fill:#4CAF50,stroke:#388E3C,color:white

    %% Legend
    subgraph Legend
        direction TB
        L1["Application Core"]:::core
        L2["Domain Model"]:::model
        L3["Repository"]:::repo
        L4["Test Component"]:::test
        L5["Database Component"]:::db
    end
```
