# nozomi-75/soko architecture

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

- Interactive diagram: https://gitdiagram.com/nozomi-75/soko
- Repository: https://github.com/nozomi-75/soko

## Overview

##### Project type and purpose
- This is a monolithic, full-stack web application called “Sōko” for managing a product inventory.
- The backend is built with Spring Boot (Java), exposing REST endpoints under `/api/products`.
- The frontend is a single‐page, mobile-first UI (HTML/CSS/JS/Bootstrap) served from Spring’s `static` folder.
- The embedded database is H2 (in-memory or file mode).

##### File structure
- Top-level: standard Maven layout (`pom.xml`, `mvnw`, `.mvn`).
- `src/main/java/com/keiaa/soko`:
- `SokoApplication.java` (Spring Boot entry point)
- `controller/ProductController.java` (REST API layer)
- `service/ProductService.java`, `CsvExportService.java` (business logic)
- `repository/ProductRepository.java` (Spring Data JPA)
- `model/Product.java` (JPA entity)
- `src/main/resources/static`: front-end assets (`index.html`, `main.js`, CSS, service worker)
- `application.properties`: config for server port (9090) and H2 settings.
- Tests under `src/test/java`.

##### Key points from README
- RESTful API with CRUD endpoints and query parameters for filtering, sorting, searching.
- Tech stack: Spring Boot, H2, JavaScript, Bootstrap 5, Maven.
- Mobile-first, responsive UI.

##### Main components
a. Client Layer
- Browser (mobile/desktop) hosts the SPA (`index.html`, `main.js`, CSS, service worker).
b. Server Layer
- Spring Boot Application
- Controller Layer (ProductController)
- Service Layer (ProductService, CsvExportService)
- Repository Layer (Spring Data JPA → H2)
c. Data Layer
- H2 Database (in-memory or file)
d. Build & Deployment
- Maven Wrapper, `pom.xml` dependencies (Spring Boot Starter Web, Data JPA, H2)
e. External Interfaces
- HTTP REST API /api/products
- Static file serving for frontend

##### Relationships & interactions
- User’s browser sends HTTP requests to the Spring Boot server.
- Frontend `main.js` calls `/api/products` endpoints.
- Controller receives REST calls → delegates to Service → Service uses Repository → Repository queries H2.
- Service returns domain objects → Controller serializes to JSON → frontend updates UI.
- Optional CSV export service invoked by controller to generate downloadable CSV.

##### Architectural patterns & principles
- Layered (Controller → Service → Repository)
- MVC-inspired on backend, though view is decoupled as an SPA.
- Repository pattern via Spring Data JPA.
- Single-page application on the client.

##### Technologies & frameworks to annotate
- Spring Boot (embedded Tomcat)
- Spring MVC, Spring Data JPA
- H2 Database (JDBC)
- JavaScript, Bootstrap 5, Service Worker (PWA shell)
- Maven (build, dependency management)

##### Essential elements
- Component labels (e.g., “ProductController”, “ProductService”)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Build & Deployment"
        MavenWrapper["mvnw<br/>mvnw.cmd<br/>pom.xml<br/>.mvn/wrapper/maven-wrapper.properties"]:::deploy
    end

    subgraph "Client Layer"
        Index["index.html"]:::frontend
        MainJS["main.js"]:::frontend
        PrintCSS["print.css"]:::frontend
        Manifest["manifest.json"]:::frontend
        SW["sw.js"]:::frontend
    end

    Browser["Browser (SPA UI)"]:::frontend

    subgraph "Server Layer"
        SokoApp["SokoApplication"]:::server
        subgraph "Controller Layer"
            Controller["ProductController"]:::server
        end
        subgraph "Service Layer"
            ProdService["ProductService"]:::server
            CsvService["CsvExportService"]:::server
        end
        subgraph "Repository Layer"
            Repository["ProductRepository"]:::server
        end
        Model["Product Entity"]:::server
    end

    Database["H2 Database"]:::db

    Browser -->|Serves static assets| SokoApp
    SokoApp -->|Serves| Index
    SokoApp -->|Serves| MainJS
    SokoApp -->|Serves| PrintCSS
    SokoApp -->|Serves| Manifest
    SokoApp -->|Serves| SW

    Browser -->|HTTP GET/POST /api/products| Controller
    Controller -->|"calls"| ProdService
    Controller -->|"export CSV"| CsvService
    ProdService -->|"queries"| Repository
    Repository -->|"JPA via JDBC"| Database
    CsvService -->|"queries"| Repository

    MavenWrapper -->|Build & Run| SokoApp

    click Index "https://github.com/nozomi-75/soko/blob/main/src/main/resources/static/index.html"
    click MainJS "https://github.com/nozomi-75/soko/blob/main/src/main/resources/static/main.js"
    click PrintCSS "https://github.com/nozomi-75/soko/blob/main/src/main/resources/static/print.css"
    click Manifest "https://github.com/nozomi-75/soko/blob/main/src/main/resources/static/manifest.json"
    click SW "https://github.com/nozomi-75/soko/blob/main/src/main/resources/static/sw.js"
    click SokoApp "https://github.com/nozomi-75/soko/blob/main/src/main/java/com/keiaa/soko/SokoApplication.java"
    click Controller "https://github.com/nozomi-75/soko/blob/main/src/main/java/com/keiaa/soko/controller/ProductController.java"
    click ProdService "https://github.com/nozomi-75/soko/blob/main/src/main/java/com/keiaa/soko/service/ProductService.java"
    click CsvService "https://github.com/nozomi-75/soko/blob/main/src/main/java/com/keiaa/soko/service/CsvExportService.java"
    click Repository "https://github.com/nozomi-75/soko/blob/main/src/main/java/com/keiaa/soko/repository/ProductRepository.java"
    click Model "https://github.com/nozomi-75/soko/blob/main/src/main/java/com/keiaa/soko/model/Product.java"
    click Database "https://github.com/nozomi-75/soko/blob/main/src/main/resources/application.properties"
    click MavenWrapper "https://github.com/nozomi-75/soko/blob/main/pom.xml"

    classDef frontend fill:#D0E8FF,stroke:#0284C7
    classDef server fill:#D1FAE5,stroke:#047857
    classDef db fill:#FFEDD5,stroke:#C2410C
    classDef deploy fill:#E5E7EB,stroke:#6B7280
```
