# naresh5021/docker-java-kubernetes-project architecture

> Architecture diagram of the GitHub repository naresh5021/docker-java-kubernetes-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/naresh5021/docker-java-kubernetes-project
- Repository: https://github.com/naresh5021/docker-java-kubernetes-project

## Overview

##### Project type and purpose
- This is a microservices-based shopping demo written in Java.
- It consists of three independent services—productcatalogue, stockmanager, and shopfront—and is designed to illustrate deploying Java applications in Docker containers on Kubernetes.
- Each service is a standalone Java application (Dropwizard or Spring Boot style), packaged via Maven, containerized with Docker, and orchestrated via Kubernetes.

##### File structure
- Top-level directories:
– kubernetes: the deployment and service YAMLs for each microservice
– productcatalogue, stockmanager, shopfront: the three distinct microservices
- Each service folder contains:
– Dockerfile and pom.xml for container build and Java dependency management
– src/main/java/... with application entrypoint, configuration, resources (REST endpoints), models, services, repositories, etc.
– src/main/resources for configuration (application.properties or YAML) and templates (for shopfront’s HTML UI)
– src/test for unit and integration tests
- No monolithic “backend” or “frontend” directories; instead, separation is by service.
- Kubernetes directory holds three files—one per service—defining Deployments and Services.

##### Extract insights from README
- Purpose: Demonstrate Docker & Kubernetes on a shopping microservices project.

##### Main components and how they interact
a. Components
– Users (browser clients)
– shopfront service (Java web app serving UI + orchestrator)
– productcatalogue service (product data REST API)
– stockmanager service (stock data REST API)
– Docker registry (e.g., Docker Hub or private)
– Kubernetes cluster (nodes, kube-proxy, etcd, API server)
– (Optional) internal datastore or in-memory store per service
b. Relationships & interactions
– User’s browser → HTTP request → shopfront Service → Kubernetes Ingress or Service
– shopfront → REST call → productcatalogue Service → returns product details
– shopfront → REST call → stockmanager Service → returns stock levels
– shopfront aggregates data, renders UI back to user
– Each service is packaged as a Docker image and pulled by Kubernetes
c. Architectural patterns
– Microservices: each service is independent, with its own code, config, and lifecycle
– RESTful APIs for inter-service communication
– Containerization: Dockerfiles in each service directory
– Container orchestration: Kubernetes Deployments + Services in the kubernetes directory
d. Key technologies
– Java (Dropwizard or Spring Boot)
– Maven for builds (pom.xml)
– Docker for container images
– Kubernetes for deployment (YAML manifests)
– (Shopfront uses HTML templates; others expose JSON endpoints)

##### Detail without over-complication
- Microservice as its own module with its Dockerfile and codebase implied.
- Health check endpoint on productcatalogue (BasicHealthCheck) to illustrate internal monitoring.
- If desired, annotate that shopfront’s templates folder serves the index.html UI.
- Kubernetes YAML files alongside each service as the deployment configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actors
    Browser["Browser / Client"]:::external
    DockerRegistry["Docker Registry"]:::external

    %% Kubernetes Cluster Boundary
    subgraph "Kubernetes Cluster"
        direction TB
        Ingress["Ingress Controller"]:::k8s

        %% Shopfront Service
        subgraph "shopfront"
            direction TB
            SF_Service["shopfront Service (UI + orchestrator)"]:::frontend
            SF_Deployment["Deployment"]:::k8s
            SF_Pod["Pod"]:::k8s
            SF_Container["Container: shopfront"]:::frontend
        end

        %% Productcatalogue Service
        subgraph "productcatalogue"
            direction TB
            PC_Service["productcatalogue Service"]:::backend
            PC_Deployment["Deployment"]:::k8s
            PC_Pod["Pod"]:::k8s
            PC_Container["Container: productcatalogue"]:::backend
        end

        %% Stockmanager Service
        subgraph "stockmanager"
            direction TB
            SM_Service["stockmanager Service"]:::backend
            SM_Deployment["Deployment"]:::k8s
            SM_Pod["Pod"]:::k8s
            SM_Container["Container: stockmanager"]:::backend
        end
    end

    %% Connections: User to Services
    Browser -->|"HTTP Request"| Ingress
    Ingress -->|"Routes to"| SF_Service

    %% Intra-service flow
    SF_Service -->|"REST call"| PC_Service
    SF_Service -->|"REST call"| SM_Service

    %% Service to Pod/Container
    SF_Service --> SF_Deployment --> SF_Pod --> SF_Container
    PC_Service --> PC_Deployment --> PC_Pod --> PC_Container
    SM_Service --> SM_Deployment --> SM_Pod --> SM_Container

    %% Docker Registry pulls images
    DockerRegistry -->|"pull image"| SF_Deployment
    DockerRegistry -->|"pull image"| PC_Deployment
    DockerRegistry -->|"pull image"| SM_Deployment

    %% Click Events
    click productcatalogue "https://github.com/naresh5021/docker-java-kubernetes-project/tree/main/productcatalogue/"
    click stockmanager "https://github.com/naresh5021/docker-java-kubernetes-project/tree/main/stockmanager/"
    click shopfront "https://github.com/naresh5021/docker-java-kubernetes-project/tree/main/shopfront/"
    click kubernetes "https://github.com/naresh5021/docker-java-kubernetes-project/tree/main/kubernetes/"

    %% Styles
    classDef external fill:#fff2cc,stroke:#e6b800,stroke-width:1px
    classDef frontend fill:#cce5ff,stroke:#005cbf,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef k8s fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef cluster fill:#f8f9fa,stroke:#343a40,stroke-width:2px,stroke-dasharray: 5 5
```
