# moermansj/pizza-kata architecture

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

- Interactive diagram: https://gitdiagram.com/moermansj/pizza-kata
- Repository: https://github.com/moermansj/pizza-kata

## Overview

##### Project type and purpose
- This is a single‐service, RESTful Spring Boot application (“Pizza Kata”) whose sole responsibility is to accept pizza orders via a POST /order endpoint, apply business rules (size, optional toppings), persist orders, and return an estimated time.
- It uses an embedded H2 database by default, with an option to swap in PostgreSQL via Docker Compose or Testcontainers for integration testing.

##### File structure
- Top-level:
- pom.xml / mvnw / mvn wrapper: Maven-based build.
- compose.yaml: Docker Compose definition for spinning up PostgreSQL.
- src/main/java/be/pizza/kata:
- PizzaKataApplication.java – Spring Boot entry point.
- OrderController.java – REST controller.
- PizzaOrder.java – domain model/entity.
- PizzaOrderRepository.java – Spring Data JPA repository.
- src/main/resources:
- application.properties – DataSource config.
- schema.sql / data.sql – DB schema & seed data.
- src/test/java/...:
- Controller and application tests using JUnit5, Mockito, Testcontainers.

##### Extracted insights from the README
- Phases: refactoring (SOLID, Clean Code, constructor injection, domain layers, tests) and enhancements (custom toppings, Testcontainers with PostgreSQL).
- Tech stack: Java 21, Spring Boot 3.5+, JUnit5, Mockito, Testcontainers, Maven, Docker Compose.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client
    Client["Client<br/>(curl/Postman)"]:::client

    %% Spring Boot Application
    subgraph "Spring Boot Application"
        direction TB
        Entry["PizzaKataApplication"]:::entry
        Controller["OrderController"]:::api
        Service["PizzaOrderService"]:::service
        Domain["PizzaOrder"]:::domain
        Repository["PizzaOrderRepository"]:::repo
    end

    %% Databases
    subgraph "Databases"
        direction TB
        H2["H2 In-Memory"]:::db
        Postgres["PostgreSQL<br/>(Docker/Testcontainers)"]:::db
    end

    %% Configuration & Scripts
    subgraph "Config & Infra"
        direction TB
        AppProps["application.properties"]:::config
        SchemaSQL["schema.sql"]:::config
        DataSQL["data.sql"]:::config
        Compose["compose.yaml"]:::infra
        POM["pom.xml"]:::infra
    end

    %% Tests
    subgraph "Tests"
        direction TB
        UnitTest["OrderControllerTest"]:::test
        IntTest["PizzaKataApplicationTests"]:::test
    end

    %% Flows
    Client -->|"HTTP POST /order"| Controller
    Controller -->|"invoke"| Service
    Service -->|"invoke"| Repository
    Repository -->|"JPA/JDBC"| H2
    Repository -->|"JPA/JDBC"| Postgres
    H2 -->|"returns data"| Repository
    Postgres -->|"returns data"| Repository
    Repository -->|"returns entity"| Service
    Service -->|"returns ETA"| Controller
    Controller -->|"HTTP Response"| Client

    %% Build & Test Flows
    POM -->|"build & run tests"| UnitTest
    POM -->|"build & run tests"| IntTest
    IntTest -->|"spins up"| Postgres
    IntTest -->|"uses"| Repository

    %% Config mounts
    Entry --> AppProps
    Entry --> SchemaSQL
    Entry --> DataSQL
    Compose --> Postgres

    %% Click Events
    click Entry "https://github.com/moermansj/pizza-kata/blob/trunk/src/main/java/be/pizza/kata/PizzaKataApplication.java"
    click Controller "https://github.com/moermansj/pizza-kata/blob/trunk/src/main/java/be/pizza/kata/OrderController.java"
    click Domain "https://github.com/moermansj/pizza-kata/blob/trunk/src/main/java/be/pizza/kata/PizzaOrder.java"
    click Repository "https://github.com/moermansj/pizza-kata/blob/trunk/src/main/java/be/pizza/kata/PizzaOrderRepository.java"
    click AppProps "https://github.com/moermansj/pizza-kata/blob/trunk/src/main/resources/application.properties"
    click SchemaSQL "https://github.com/moermansj/pizza-kata/blob/trunk/src/main/resources/schema.sql"
    click DataSQL "https://github.com/moermansj/pizza-kata/blob/trunk/src/main/resources/data.sql"
    click Compose "https://github.com/moermansj/pizza-kata/blob/trunk/compose.yaml"
    click POM "https://github.com/moermansj/pizza-kata/blob/trunk/pom.xml"
    click UnitTest "https://github.com/moermansj/pizza-kata/blob/trunk/src/test/java/be/pizza/kata/OrderControllerTest.java"
    click IntTest "https://github.com/moermansj/pizza-kata/blob/trunk/src/test/java/be/pizza/kata/PizzaKataApplicationTests.java"

    %% Styles
    classDef client fill:#B3E5FC,stroke:#0288D1,color:#000
    classDef entry fill:#BBDEFB,stroke:#1976D2,color:#000
    classDef api fill:#90CAF9,stroke:#1565C0,color:#000
    classDef service fill:#C8E6C9,stroke:#2E7D32,color:#000
    classDef domain fill:#E8F5E9,stroke:#43A047,color:#000
    classDef repo fill:#FFE0B2,stroke:#EF6C00,color:#000
    classDef db fill:#EEEEEE,stroke:#757575,color:#000
    classDef config fill:#F5F5F5,stroke:#9E9E9E,color:#000
    classDef infra fill:#E1BEE7,stroke:#8E24AA,color:#000
    classDef test fill:#FFCDD2,stroke:#C62828,color:#000
```
