# 1medx/shopws architecture

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

- Interactive diagram: https://gitdiagram.com/1medx/shopws
- Repository: https://github.com/1medx/shopws

## Overview

##### Project type and purpose
- This is a Spring Boot web application (full-stack in the sense that it exposes both REST endpoints and server-side rendered pages) whose sole purpose is to provide a REST API to manage products in an online shop (plus a simple Thymeleaf page to view product details).

##### File structure
- Top-level artifacts:
- pom.xml, mvnw(.cmd) → Maven build
- src/main/java/ma/fsr/shopws → Java codebase
– ShopwsApplication.java → Spring Boot entry point
– dao/ProductRepository.java → Spring Data JPA repository
– entities/Product.java → JPA entity
– exception/ProductNotFoundException.java → custom exception
– web/ProductController.java → REST & web controller
- src/main/resources/
– application.properties → configuration (datasource, JPA, server port, etc.)
– templates/product.html → Thymeleaf view
- src/test/java/… → basic application test

##### README
- Confirms: “Rest API for managing products in an online shop.” No further architectural notes, so we infer typical Spring Boot MVC layered architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    subgraph "Clients"
        direction TB
        Browser["Web Browser"]:::client
        APIClient["API Consumer (e.g. Postman)"]:::client
    end

    %% HTTP Flow
    HTTP["HTTP Request"]:::flow

    %% Spring Boot Application Layers
    subgraph "Spring Boot Application"
        direction TB
        ShopApp["ShopwsApplication<br/>(Entry Point)"]:::entry
        ProductController["ProductController<br/>(REST & Thymeleaf)"]:::web
        ProductNotFoundException["ProductNotFoundException"]:::exception
        ProductRepository["ProductRepository"]:::data
        ProductEntity["Product<br/>(JPA Entity)"]:::domain
        ThymeleafEngine["Thymeleaf Engine"]:::template
    end

    %% Database
    Database["Relational Database"]:::db

    %% Templates & Configuration
    Config["application.properties"]:::config
    productHtml["product.html"]:::template

    %% Build & Deployment
    subgraph "Build & Deployment"
        direction TB
        Pom["pom.xml"]:::build
        MVNW["mvnw / mvnw.cmd"]:::build
        JAR["Executable JAR<br/>(Embedded Tomcat)"]:::build
    end

    %% Tests
    Test["ShopwsApplicationTests"]:::test

    %% Flows
    Browser -->|HTTP| HTTP
    APIClient -->|HTTP| HTTP
    HTTP -->|routes to| ShopApp
    ShopApp -->|starts Spring context| ProductController
    ProductController -->|calls| ProductRepository
    ProductController -->|uses| ThymeleafEngine
    ProductRepository -->|uses| ProductEntity
    ProductRepository -->|JPA/JDBC| Database
    ThymeleafEngine -->|renders| productHtml
    ProductController -->|throws/catches| ProductNotFoundException
    Config --- ShopApp
    Pom & MVNW -->|builds| JAR
    Test -->|validates| ShopApp

    %% Click Events
    click ShopApp "https://github.com/1medx/shopws/blob/master/src/main/java/ma/fsr/shopws/ShopwsApplication.java"
    click ProductController "https://github.com/1medx/shopws/blob/master/src/main/java/ma/fsr/shopws/web/ProductController.java"
    click ProductRepository "https://github.com/1medx/shopws/blob/master/src/main/java/ma/fsr/shopws/dao/ProductRepository.java"
    click ProductEntity "https://github.com/1medx/shopws/blob/master/src/main/java/ma/fsr/shopws/entities/Product.java"
    click ProductNotFoundException "https://github.com/1medx/shopws/blob/master/src/main/java/ma/fsr/shopws/exception/ProductNotFoundException.java"
    click productHtml "https://github.com/1medx/shopws/blob/master/src/main/resources/templates/product.html"
    click Config "https://github.com/1medx/shopws/blob/master/src/main/resources/application.properties"
    click Pom "https://github.com/1medx/shopws/blob/master/pom.xml"
    click MVNW "https://github.com/1medx/shopws/tree/master/mvnw"
    click Test "https://github.com/1medx/shopws/blob/master/src/test/java/ma/fsr/shopws/ShopwsApplicationTests.java"

    %% Styles
    classDef client fill:#FFD700,stroke:#333,stroke-width:1px
    classDef flow fill:#EEE,stroke:#666,stroke-width:1px,stroke-dasharray: 5 5
    classDef entry fill:#B0E0E6,stroke:#333,stroke-width:1px
    classDef web fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef domain fill:#98FB98,stroke:#333,stroke-width:1px
    classDef db fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef template fill:#FFDAB9,stroke:#333,stroke-width:1px
    classDef config fill:#FFEFD5,stroke:#333,stroke-width:1px
    classDef build fill:#DCDCDC,stroke:#333,stroke-width:1px
    classDef test fill:#E0FFFF,stroke:#333,stroke-width:1px
    classDef exception fill:#FFB6C1,stroke:#333,stroke-width:1px
```
