# techops-recsys-lateral-hiring/developer-joi-delivery-java architecture

> Architecture diagram of the GitHub repository techops-recsys-lateral-hiring/developer-joi-delivery-java, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/techops-recsys-lateral-hiring/developer-joi-delivery-java
- Repository: https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java

## Overview

##### Project type & purpose (what you’re diagramming)
This repo is a **single-service Spring Boot (Gradle) Java backend** for a delivery domain (“JOI Delivery”). It currently exposes REST APIs for:
- **Cart**: add product to cart, view cart
- **Inventory**: health endpoint (stub/TBD)

There’s **no frontend** and **no obvious database/infrastructure integration** in the tree; data appears **in-memory and seeded** via `seedData/SeedData.java`.

##### File structure → architectural slices
Use the package layout as your architectural guide:

##### Web/API layer (Controllers)
- `controller/CartController.java`
- `controller/InventoryController.java`

##### Service layer (Use cases / application services)
- `service/CartService.java`
- `service/ProductService.java`
- `service/UserService.java`

##### Domain model (Entities / aggregates / value objects)
- `domain/Cart.java`
- `domain/Product.java` + specializations `FoodProduct`, `GroceryProduct`
- `domain/Outlet.java` + specializations `Restaurant`, `GroceryStore`
- `domain/User.java`

##### DTOs (API contracts)
- `dto/request/AddProductRequest.java`
- `dto/response/CartProductInfo.java`

##### Seed / data initialization
- `seedData/SeedData.java`

##### Configuration
- `src/main/resources/application.yaml`

##### Tests
- `controller/*Test.java`, `DeliveryApplicationTests.java`

The README describes a broader product vision (tracking, payments, partner ecosystem), but **the codebase currently implements only a small subset (cart + inventory health stub + seed data)**.

- Be faithful to **what exists** (single backend service, in-memory seed data)

##### API Client(s)
- Postman/cURL, Mobile App, Web App (even if not in repo)

##### JOI Delivery Backend (Spring Boot, Java 24)
Inside this container, split into subcomponents:
- **CartController**
- **InventoryController**
- **CartService**
- **ProductService**
- **UserService**
- **Domain Model** (Cart, Product hierarchy, Outlet hierarchy, User)
- **DTOs** (AddProductRequest, CartProductInfo)
- **SeedData (in-memory)**

##### (Optional placeholder) Persistence
Since no repository/DB layer exists in the tree, show:
- **“In-memory seeded dataset”** as the current “data store”

##### Relationships / interactions (key request flows)

**Flow 1: Add Product to Cart**
- Client → `POST /cart/product` → **CartController**
- CartController → **CartService**
- CartService → **UserService** (validate/find user)
- CartService → **ProductService** (lookup product by `productId`, validate outlet/store)
- Services → **SeedData / in-memory collections** (read/update)
- CartService → returns domain/response mapping → Controller → Client

**Flow 2: View Cart**
- Client → `GET /cart/view?userId=...` → **CartController**
- CartController → **CartService**
- CartService → SeedData/in-memory cart store → returns Cart → Client

**Flow 3: Inventory Health (stub)**
- Client → `GET /inventory/health?storeid=...` → **InventoryController**
- InventoryController → (likely ProductService / Inventory logic) → currently “to be implemented”

##### Architectural patterns to call out
- **Layered architecture**: Controller (web) → Service (use-case) → Domain (+ seed data as data source)
- **DTO boundary**: request/response models isolate API contract from domain model (even if domain is currently exposed in responses)
- **Polymorphic domain**: `Product` → `FoodProduct` / `GroceryProduct`; `Outlet` → `Restaurant` / `GroceryStore`

- **Spring Boot** (web, dependency injection)
- **Gradle** (build)
- **Java 24**
- **HTTP/JSON REST**
- Port **8080**
- “In-memory seeded data” (current persistence approach)

##### Labels
- Use exact class names for components:
- `CartController`, `InventoryController`
- `CartService`, `ProductService`, `UserService`
- `SeedData`
- `POST /cart/product`
- `GET /cart/view`
- `GET /inventory/health`

##### Notes/callouts
Small callouts for:
- “Runs on port 8080”
- “Data is seeded (dev-only) via SeedData”
- “No persistence layer present (yet)”

##### Practical “don’t overthink it” decomposition (separate into many components)

- **Domain Model**
- Cart
- User
- Outlet → GroceryStore / Restaurant
- Product → GroceryProduct / FoodProduct

- **API Contracts**
- AddProductRequest
- CartProductInfo

- **Seed Data**
- Users seed
- Stores/Outlets seed
- Products seed
- Carts seed (if present/created)

- controllers → services → seed data
- domain model group

- Clients (Mobile/Web/Postman) → JOI Delivery API

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% External Clients
  %% =========================
  subgraph "External Clients"
    Client["API Client(s)\n(Postman/cURL, Mobile App, Web App)"]:::external
  end

  %% =========================
  %% JOI Delivery Backend (Single Deployable)
  %% =========================
  subgraph "JOI Delivery Backend (Spring Boot • Java 24 • Gradle • REST/JSON)"
    direction TB

    App["DeliveryApplication\n(Spring Boot Bootstrap)"]:::app
    Config["application.yaml\n(Spring Boot Config • port 8080)"]:::config

    subgraph "Web/API Layer (Controllers)"
      direction TB
      CartController["CartController\n- POST /cart/product\n- GET /cart/view"]:::controller
      InventoryController["InventoryController\n- GET /inventory/health (stub)"]:::controller
      DTOreq["AddProductRequest\n(API Request DTO)"]:::dto
      DTOresp["CartProductInfo\n(API Response DTO)"]:::dto
    end

    subgraph "Service Layer (Use Cases)"
      direction TB
      CartService["CartService"]:::service
      ProductService["ProductService"]:::service
      UserService["UserService"]:::service
    end

    subgraph "Domain Model (Entities & Polymorphism)"
      direction TB
      Cart["Cart"]:::domain
      User["User"]:::domain

      subgraph "Products"
        direction TB
        Product["Product (base)"]:::domain
        FoodProduct["FoodProduct"]:::domain
        GroceryProduct["GroceryProduct"]:::domain
      end

      subgraph "Outlets"
        direction TB
        Outlet["Outlet (base)"]:::domain
        Restaurant["Restaurant"]:::domain
        GroceryStore["GroceryStore"]:::domain
      end
    end

    subgraph "Current Data Source (No DB layer in repo)"
      direction TB
      SeedData["SeedData\nSeeded In-Memory Data Store / Fixtures"]:::data
      FutureDB[("Future DB (TBD)\nNot implemented")]:::future
    end

    subgraph "Tests (Non-runtime)"
      direction TB
      AppTest["DeliveryApplicationTests"]:::test
      CartControllerTest["CartControllerTest"]:::test
      InventoryControllerTest["InventoryControllerTest"]:::test
    end
  end

  %% =========================
  %% Request Flows (Implemented)
  %% =========================
  Client -->|"HTTP/JSON\nPOST /cart/product"| CartController
  Client -->|"HTTP/JSON\nGET /cart/view?userId=..."| CartController
  Client -->|"HTTP/JSON\nGET /inventory/health?storeid=..."| InventoryController

  CartController -->|"uses DTO"| DTOreq
  CartController -->|"returns DTO"| DTOresp

  CartController -->|"calls"| CartService
  CartService -->|"validates/finds"| UserService
  CartService -->|"looks up/validates"| ProductService

  UserService -->|"reads"| SeedData
  ProductService -->|"reads"| SeedData
  CartService -->|"reads/updates"| SeedData

  CartService -->|"builds/returns"| Cart
  CartService -->|"uses"| User
  ProductService -->|"uses"| Product
  ProductService -->|"uses"| Outlet

  %% =========================
  %% Inventory Health (Stub / TODO)
  %% =========================
  InventoryController -.->|"TODO:inventory logic"| ProductService
  InventoryController -.->|"TODO:data access"| SeedData

  %% =========================
  %% Polymorphism (Domain)
  %% =========================
  Product -->|"extends"| FoodProduct
  Product -->|"extends"| GroceryProduct
  Outlet -->|"extends"| Restaurant
  Outlet -->|"extends"| GroceryStore

  %% =========================
  %% Configuration
  %% =========================
  Config -.->|"configures"| App
  App -->|"component scan/DI"| CartController
  App -->|"component scan/DI"| InventoryController
  App -->|"component scan/DI"| CartService
  App -->|"component scan/DI"| ProductService
  App -->|"component scan/DI"| UserService
  App -.->|"seeds data (dev-only)"| SeedData

  %% =========================
  %% Future Persistence
  %% =========================
  SeedData -.->|"future replace with"| FutureDB

  %% =========================
  %% Click Events (from component_mapping)
  %% =========================
  click App "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/DeliveryApplication.java"
  click CartController "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/controller/CartController.java"
  click InventoryController "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/controller/InventoryController.java"
  click CartService "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/service/CartService.java"
  click ProductService "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/service/ProductService.java"
  click UserService "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/service/UserService.java"
  click Cart "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/Cart.java"
  click Product "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/Product.java"
  click FoodProduct "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/FoodProduct.java"
  click GroceryProduct "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/GroceryProduct.java"
  click Outlet "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/Outlet.java"
  click Restaurant "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/Restaurant.java"
  click GroceryStore "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/GroceryStore.java"
  click User "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/domain/User.java"
  click DTOreq "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/dto/request/AddProductRequest.java"
  click DTOresp "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/dto/response/CartProductInfo.java"
  click SeedData "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/java/com/tw/joi/delivery/seedData/SeedData.java"
  click Config "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/main/resources/application.yaml"
  click AppTest "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/test/java/com/tw/joi/delivery/DeliveryApplicationTests.java"
  click CartControllerTest "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/test/java/com/tw/joi/delivery/controller/CartControllerTest.java"
  click InventoryControllerTest "https://github.com/techops-recsys-lateral-hiring/developer-joi-delivery-java/blob/main/src/test/java/com/tw/joi/delivery/controller/InventoryControllerTest.java"

  %% =========================
  %% Styles
  %% =========================
  classDef external fill:#ffffff,stroke:#2b2b2b,stroke-width:1.5px,color:#111
  classDef app fill:#e8f0ff,stroke:#2f5fd0,stroke-width:2px,color:#0b1b44
  classDef controller fill:#d7ebff,stroke:#2f80ed,stroke-width:2px,color:#0b2a4a
  classDef service fill:#daf5de,stroke:#27ae60,stroke-width:2px,color:#10351e
  classDef domain fill:#ffe6c7,stroke:#f2994a,stroke-width:2px,color:#4a2b07
  classDef data fill:#eeeeee,stroke:#6b7280,stroke-width:2px,color:#111
  classDef future fill:#f5f5f5,stroke:#9aa0a6,stroke-width:2px,stroke-dasharray: 6 4,color:#555
  classDef dto fill:#efe3ff,stroke:#8e44ad,stroke-width:2px,color:#2c123a
  classDef config fill:#fff4cc,stroke:#f2c94c,stroke-width:2px,color:#3b2f05
  classDef test fill:#ffd6d6,stroke:#eb5757,stroke-width:2px,color:#4a0b0b
```
