# newbie1337x/stockify architecture

> Architecture diagram of the GitHub repository newbie1337x/stockify, 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/newbie1337x/stockify
- Repository: https://github.com/newbie1337x/stockify

## Overview

##### Project type and purpose
- Stockify is a Spring Boot–based, RESTful, back-end monolith that provides an inventory and point-of-sale (POS) management system. It exposes HTTP/JSON endpoints (with HATEOAS links), uses JWT for authentication, and persists data in PostgreSQL. There is no separate front-end code here—clients (web SPA, mobile apps or Postman) consume its APIs, generate PDFs (via Thymeleaf templates), and send emails.

##### File structure
- Top-level folders:
- config – Spring and OpenAPI/Swagger configurations, startup/bootstrapping settings
- controller – HTTP API layer, organized by domain modules (product, provider, store, transaction, shift) plus cross-cutting controllers (AuthController, PdfGeneratorController)
- dto – Data Transfer Objects, subdivided into request/response payloads per use case
- model – domain:
– entity – JPA @Entity classes
– assembler – “ModelAssembler” classes to convert entities to HATEOAS models
– mapper – MapStruct (or manual) mappers between DTOs and entities
– repository – Spring Data JPA interfaces
– service – business-logic interfaces and implementations
– exception – application-wide exceptions and global handler
– specification – dynamic query builders for filtering
- security – Spring Security setup, JWT filters, AuthController, user/role/permit entities and repos, JwtService
- src/main/resources – application.properties, SQL scripts for DB initialization, Thymeleaf templates for PDF, Swagger UI resources
- Key build/config files: pom.xml, mvnw, .mvn/wrapper, .gitignore.

##### README for additional insights
- It confirms a layered architecture: Controllers → Services → Repositories
- Patterns: DTOs, MapStruct mapping, Hibernate Validator, centralized exception handling, JWT auth, HATEOAS, OpenAPI/Swagger documentation, Thymeleaf for PDF templates.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client\n(Web/Mobile)"]:::client

    subgraph "Configuration" 
        App["StockifyApplication\n(src/main/java/org/stockify/StockifyApplication.java)"]:::config
        Config["AppEnvConfig,GlobalPreferencesConfig,StartupConfig\n(src/main/java/org/stockify/config)"]:::config
        App --> Config
    end

    subgraph "API Layer" 
        HTTP["Spring MVC Controllers\n(src/main/java/org/stockify/controller)"]:::api
        Swagger["OpenAPI/Swagger UI"]:::api
        Client -->|"HTTP/JSON"| HTTP
        HTTP -->|"serves API docs"| Swagger

        click HTTP "https://github.com/newbie1337x/stockify/tree/main/src/main/java/org/stockify/controller"
        click Swagger "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/config/OpenApiConfig.java"
        click Swagger "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/config/SwaggerConfig.java"
    end

    subgraph "Security Layer"
        JwtFilter["JwtAuthenticationFilter"]:::security
        AuthEntry["RestAuthenticationEntryPoint"]:::security
        SecConfig["SecurityConfig"]:::security
        AuthCtrl["AuthController"]:::security

        HTTP -->|passes through| JwtFilter
        JwtFilter --> AuthEntry
        AuthEntry --> SecConfig
        HTTP --> AuthCtrl

        click JwtFilter "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/security/filter/JwtAuthenticationFilter.java"
        click AuthEntry "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/security/filter/RestAuthenticationEntryPoint.java"
        click SecConfig "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/security/config/SecurityConfig.java"
        click AuthCtrl "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/security/controller/AuthController.java"
    end

    subgraph "Business Layer"
        Services["Domain Services\n(src/main/java/org/stockify/model/service)"]:::business
        HTTP -->|calls| Services
        AuthCtrl -->|calls| Services

        click Services "https://github.com/newbie1337x/stockify/tree/main/src/main/java/org/stockify/model/service"
    end

    subgraph "Utility Modules"
        DTOs["DTOs\n(src/main/java/org/stockify/dto/request & response)"]:::util
        Mappers["Mappers\n(src/main/java/org/stockify/model/mapper)"]:::util
        Assemblers["Model Assemblers\n(src/main/java/org/stockify/model/assembler)"]:::util
        Exceptions["GlobalExceptionHandler & Exceptions\n(src/main/java/org/stockify/model/exception)"]:::util
        Specs["Specification Builders\n(src/main/java/org/stockify/model/specification)"]:::util

        Services -->|use| DTOs
        Services -->|use| Mappers
        Services -->|use| Assemblers
        Services -->|handle| Exceptions
        Services -->|use| Specs

        click DTOs "https://github.com/newbie1337x/stockify/tree/main/src/main/java/org/stockify/dto/request"
        click DTOs "https://github.com/newbie1337x/stockify/tree/main/src/main/java/org/stockify/dto/response"
        click Mappers "https://github.com/newbie1337x/stockify/tree/main/src/main/java/org/stockify/model/mapper"
        click Assemblers "https://github.com/newbie1337x/stockify/tree/main/src/main/java/org/stockify/model/assembler"
        click Exceptions "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/model/exception/GlobalExceptionHandler.java"
        click Specs "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/model/specification/SpecificationBuilder.java"
    end

    subgraph "Data Access Layer"
        Repos["Repositories\n(src/main/java/org/stockify/model/repository)"]:::data
        Services -->|CRUD calls| Repos
        Specs -->|filter queries| Repos

        click Repos "https://github.com/newbie1337x/stockify/tree/main/src/main/java/org/stockify/model/repository"
    end

    Repos -->|SQL queries| DB["PostgreSQL Database"]:::db

    subgraph "External Services"
        Email["SMTP Mail Server"]:::external
        PDF["PDF Generation via Thymeleaf"]:::external

        Services -->|send email| Email
        Services -->|generate PDF| PDF

        click PDF "https://github.com/newbie1337x/stockify/blob/main/src/main/java/org/stockify/controller/PdfGeneratorController.java"
        click PDF "https://github.com/newbie1337x/stockify/blob/main/src/main/resources/buyTemplate.html"
        click PDF "https://github.com/newbie1337x/stockify/blob/main/src/main/resources/saleTemplate.html"
    end

    classDef client fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef api fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef security fill:#d6d4f0,stroke:#333,stroke-width:1px
    classDef business fill:#d4edda,stroke:#333,stroke-width:1px
    classDef util fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef data fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef db fill:#ffeeba,stroke:#333,stroke-width:1px
    classDef external fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef config fill:#f8d7da,stroke:#333,stroke-width:1px
```
