# mathiasconradt/javacoffeeshop architecture

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

- Interactive diagram: https://gitdiagram.com/mathiasconradt/javacoffeeshop
- Repository: https://github.com/mathiasconradt/javacoffeeshop

## Overview

##### Main Components

a. Web Layer (Presentation Tier):
- Static resources (CSS)
- This to the Controllers layer

b. Application Layer:
- HomeController
- OrderController
- ProductController
- PersonController
- LoginController
- etc.

c. Service Layer:
- CustomUserDetailsService
- OrderService
- PersonService
- ProductService

d. Repository Layer:
- Repositories:
- OrderRepository
- PersonRepository
- ProductRepository
- SearchRepository

e. Domain Model:
- Core domain entities:
- Person
- Order
- Product
- OrderLine

f. Security Components:
- SecurityConfig
- AuthenticationFailureListener
- Role-based access control

g. Export/Import Functionality:
- XML Export/Import
- YAML Import/Export

##### Relationships and Data Flow

- Web Browser → Controllers → Services → Repositories → Database
- Login Request → Security Layer → UserDetailsService
- Bidirectional relationships where applicable

Top Section:
- External Client Access
- Security Perimeter

Middle Section:
- Application Core Components
- Business Logic
- Service Layer

Bottom Section:
- Data Persistence
- External Integrations

##### Additional Elements

- Notes about intentional vulnerabilities
- Workshop-specific components
- Docker container boundaries

##### Technical Details

- Spring Boot framework
- Thymeleaf template engine
- JPA/Hibernate
- Security frameworks
- Export/Import capabilities (XML/YAML)

Remember to include a note indicating that this is a training application with intentional vulnerabilities, and should not be used in production environments.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef web fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef security fill:#f1c40f,stroke:#f39c12,color:black
    classDef repository fill:#9b59b6,stroke:#8e44ad,color:white
    classDef domain fill:#e74c3c,stroke:#c0392b,color:white
    classDef vulnerable fill:#e74c3c,stroke:#c0392b,color:white,stroke-dasharray: 5 5
    
    %% External Client
    Client["Web Browser"]:::web
    
    %% Web Layer
    subgraph WebLayer["Presentation Layer"]
        Templates["Thymeleaf Templates"]:::web
        StaticRes["Static Resources"]:::web
    end
    click Templates "https://github.com/mathiasconradt/JavaCoffeeShop/tree/main/src/main/resources/templates/"
    click StaticRes "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/resources/static/css/style.css"
    
    %% Controllers Layer
    subgraph Controllers["Controllers Layer"]
        HomeC["HomeController"]:::web
        OrderC["OrderController"]:::web
        ProductC["ProductController"]:::web
        PersonC["PersonController"]:::web
        LoginC["LoginController"]:::web
    end
    click Controllers "https://github.com/mathiasconradt/JavaCoffeeShop/tree/main/src/main/java/org/workshop/coffee/controller/"
    click HomeC "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/controller/HomeController.java"
    click OrderC "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/controller/OrderController.java"
    click ProductC "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/controller/ProductController.java"
    click LoginC "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/controller/LoginController.java"
    
    %% Security Layer
    subgraph Security["Security Components"]
        SecConfig["SecurityConfig"]:::security
        AuthFailure["AuthenticationFailureListener"]:::security
        UserDetails["CustomUserDetailsService"]:::security
    end
    click SecConfig "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/config/SecurityConfig.java"
    click AuthFailure "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/config/AuthenticationFailureListener.java"
    click UserDetails "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/service/CustomUserDetailsService.java"
    
    %% Service Layer
    subgraph Services["Service Layer"]
        OrderS["OrderService"]:::service
        PersonS["PersonService"]:::service
        ProductS["ProductService"]:::service
    end
    click Services "https://github.com/mathiasconradt/JavaCoffeeShop/tree/main/src/main/java/org/workshop/coffee/service/"
    click OrderS "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/service/OrderService.java"
    click PersonS "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/service/PersonService.java"
    click ProductS "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/service/ProductService.java"
    
    %% Repository Layer
    subgraph Repos["Repository Layer"]
        OrderR["OrderRepository"]:::repository
        PersonR["PersonRepository"]:::repository
        ProductR["ProductRepository"]:::repository
        SearchR["SearchRepository"]:::repository
    end
    click Repos "https://github.com/mathiasconradt/JavaCoffeeShop/tree/main/src/main/java/org/workshop/coffee/repository/"
    click OrderR "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/repository/OrderRepository.java"
    click PersonR "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/repository/PersonRepository.java"
    click ProductR "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/repository/ProductRepository.java"
    click SearchR "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/repository/SearchRepository.java"
    
    %% Domain Model
    subgraph Domain["Domain Model"]
        Person["Person"]:::domain
        Order["Order"]:::domain
        Product["Product"]:::domain
        OrderLine["OrderLine"]:::domain
    end
    click Domain "https://github.com/mathiasconradt/JavaCoffeeShop/tree/main/src/main/java/org/workshop/coffee/domain/"
    click Person "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/domain/Person.java"
    click Order "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/domain/Order.java"
    click Product "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/domain/Product.java"
    click OrderLine "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/domain/OrderLine.java"
    
    %% Export/Import
    subgraph Export["Export/Import"]
        XMLExp["XML Export/Import"]:::vulnerable
        YAMLExp["YAML Export/Import"]:::vulnerable
    end
    click Export "https://github.com/mathiasconradt/JavaCoffeeShop/tree/main/src/main/java/org/workshop/coffee/export/"
    click XMLExp "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/export/XMLExporter.java"
    click YAMLExp "https://github.com/mathiasconradt/JavaCoffeeShop/blob/main/src/main/java/org/workshop/coffee/export/YamlImportExport.java"
    
    %% Vulnerable Components
    subgraph Vulnerable["Vulnerable Components"]
        Log4Shell["Log4Shell Server"]:::vulnerable
    end
    click Log4Shell "https://github.com/mathiasconradt/JavaCoffeeShop/tree/main/tools/log4shellserver/"
    
    %% Relationships
    Client --> Templates
    Client --> StaticRes
    Templates --> Controllers
    Controllers --> Security
    Controllers --> Services
    Security --> UserDetails
    Services --> Repos
    Repos --> Domain
    Services --> Export
    
    %% Legend
    subgraph Legend
        Web["Web Component"]:::web
        Sec["Security Component"]:::security
        Serv["Service Component"]:::service
        Rep["Repository Component"]:::repository
        Dom["Domain Component"]:::domain
        Vuln["Vulnerable Component"]:::vulnerable
    end
```
