# iiamhimanshu/stocksense-inventory-system architecture

> Architecture diagram of the GitHub repository iiamhimanshu/stocksense-inventory-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iiamhimanshu/stocksense-inventory-system
- Repository: https://github.com/iiamhimanshu/stocksense-inventory-system

## Overview

StockSense is a Spring Boot inventory REST backend. Clients use product and category endpoints to submit validated requests or query inventory; controllers delegate to services, which apply business rules, map entities and DTOs, and use repositories for persistence. Product operations include CRUD, duplicate-name checks, search, low-stock filtering, and category lookup; category deletion protects categories still in use. DTO validation and centralized JSON error handling are also represented. The README describes MySQL persistence; suppliers, authentication, and other roadmap items are not implemented in the provided tree. Some links rely on the source index rather than full excerpts.

Main entry points: [`src/main/java/com/stocksense/inventory/service/ProductService.java`](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/service/ProductService.java) (Product Operations), [`src/main/java/com/stocksense/inventory/controller/CategoryController.java`](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/controller/CategoryController.java) (Category Endpoints), [`src/main/java/com/stocksense/inventory/service/CategoryService.java`](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/service/CategoryService.java) (Category Operations), [`src/main/java/com/stocksense/inventory/repository/ProductRepository.java`](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/repository/ProductRepository.java) (Product Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_product_api["Product Endpoints"]
  node_category_api["Category Endpoints"]
  node_product_dto["Product DTOs"]
  node_category_dto["Category DTOs"]
  node_error_handling["Error Responses"]
end

subgraph group_domain["Inventory Services"]
  node_product_service["Product Operations"]
  node_category_service["Category Operations"]
end

subgraph group_mapping["Data Mapping"]
  node_product_mapper["Product Mapper<br/>[ProductMapper.java]"]
  node_category_mapper["Category Mapper"]
end

subgraph group_persistence["Persistence and Errors"]
  node_product_entity["Product Entity<br/>[Product.java]"]
  node_category_entity["Category Entity<br/>[Category.java]"]
  node_product_repo["Product Repository"]
  node_category_repo["Category Repository"]
end

node_client(("API Client"))
node_mysql[("MySQL")]

node_client -->|"calls REST"| node_product_api
node_client -->|"calls REST"| node_category_api
node_product_api -->|"delegates"| node_product_service
node_category_api -->|"delegates"| node_category_service
node_category_api -->|"queries products"| node_product_service
node_product_api -->|"accepts and returns"| node_product_dto
node_category_api -->|"accepts and returns"| node_category_dto
node_product_service -->|"queries and saves"| node_product_repo
node_product_service -->|"checks categories"| node_category_repo
node_product_service -->|"maps products"| node_product_mapper
node_category_service -->|"queries and saves"| node_category_repo
node_category_service -->|"checks usage"| node_product_repo
node_category_service -->|"maps categories"| node_category_mapper
node_product_mapper -->|"maps DTOs"| node_product_dto
node_product_mapper -->|"maps entity"| node_product_entity
node_category_mapper -->|"maps DTOs"| node_category_dto
node_category_mapper -->|"maps entity"| node_category_entity
node_product_repo -->|"persists"| node_product_entity
node_category_repo -->|"persists"| node_category_entity
node_product_repo -->|"stores inventory"| node_mysql
node_category_repo -->|"stores categories"| node_mysql
node_error_handling -->|"returns JSON errors"| node_client

click node_product_api "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/controller/ProductController.java"
click node_category_api "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/controller/CategoryController.java"
click node_product_service "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/service/ProductService.java"
click node_category_service "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/service/CategoryService.java"
click node_product_dto "https://github.com/iiamhimanshu/stocksense-inventory-system/tree/main/src/main/java/com/stocksense/inventory/dto"
click node_category_dto "https://github.com/iiamhimanshu/stocksense-inventory-system/tree/main/src/main/java/com/stocksense/inventory/dto"
click node_product_mapper "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/mapper/ProductMapper.java"
click node_category_mapper "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/mapper/CatgeoryMapper.java"
click node_product_entity "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/model/Product.java"
click node_category_entity "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/model/Category.java"
click node_product_repo "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/repository/ProductRepository.java"
click node_category_repo "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/repository/CategoryRepository.java"
click node_error_handling "https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/exception/GlobalExceptionHandler.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_product_api,node_category_api,node_product_dto,node_category_dto,node_error_handling,node_client toneBlue
class node_product_service,node_category_service,node_mysql toneAmber
class node_product_mapper,node_category_mapper toneMint
class node_product_entity,node_category_entity,node_product_repo,node_category_repo toneRose
```

## Components

### REST API

- [Product Endpoints](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/controller/ProductController.java): `src/main/java/com/stocksense/inventory/controller/ProductController.java`
- [Category Endpoints](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/controller/CategoryController.java): `src/main/java/com/stocksense/inventory/controller/CategoryController.java`
- [Product DTOs](https://github.com/iiamhimanshu/stocksense-inventory-system/tree/main/src/main/java/com/stocksense/inventory/dto): `src/main/java/com/stocksense/inventory/dto`
- [Category DTOs](https://github.com/iiamhimanshu/stocksense-inventory-system/tree/main/src/main/java/com/stocksense/inventory/dto): `src/main/java/com/stocksense/inventory/dto`
- [Error Responses](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/exception/GlobalExceptionHandler.java): `src/main/java/com/stocksense/inventory/exception/GlobalExceptionHandler.java`

### Inventory Services

- [Product Operations](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/service/ProductService.java): `src/main/java/com/stocksense/inventory/service/ProductService.java`
- [Category Operations](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/service/CategoryService.java): `src/main/java/com/stocksense/inventory/service/CategoryService.java`

### Data Mapping

- [Product Mapper](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/mapper/ProductMapper.java): `src/main/java/com/stocksense/inventory/mapper/ProductMapper.java`
- [Category Mapper](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/mapper/CatgeoryMapper.java): `src/main/java/com/stocksense/inventory/mapper/CatgeoryMapper.java`

### Persistence and Errors

- [Product Entity](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/model/Product.java): `src/main/java/com/stocksense/inventory/model/Product.java`
- [Category Entity](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/model/Category.java): `src/main/java/com/stocksense/inventory/model/Category.java`
- [Product Repository](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/repository/ProductRepository.java): `src/main/java/com/stocksense/inventory/repository/ProductRepository.java`
- [Category Repository](https://github.com/iiamhimanshu/stocksense-inventory-system/blob/main/src/main/java/com/stocksense/inventory/repository/CategoryRepository.java): `src/main/java/com/stocksense/inventory/repository/CategoryRepository.java`

### Other components

- **API Client**
- **MySQL**

## Connections

- API Client → Product Endpoints: calls REST (evidence: `README.md`)
- API Client → Category Endpoints: calls REST (evidence: `README.md`)
- Product Endpoints → Product Operations: delegates (evidence: `src/main/java/com/stocksense/inventory/controller/ProductController.java`)
- Category Endpoints → Category Operations: delegates (evidence: `src/main/java/com/stocksense/inventory/controller/CategoryController.java`)
- Category Endpoints → Product Operations: queries products (evidence: `src/main/java/com/stocksense/inventory/controller/CategoryController.java`)
- Product Endpoints → Product DTOs: accepts and returns (evidence: `src/main/java/com/stocksense/inventory/controller/ProductController.java`)
- Category Endpoints → Category DTOs: accepts and returns (evidence: `src/main/java/com/stocksense/inventory/controller/CategoryController.java`)
- Product Operations → Product Repository: queries and saves (evidence: `src/main/java/com/stocksense/inventory/service/ProductService.java`)
- Product Operations → Category Repository: checks categories (evidence: `src/main/java/com/stocksense/inventory/service/ProductService.java`)
- Product Operations → Product Mapper: maps products (evidence: `src/main/java/com/stocksense/inventory/service/ProductService.java`)
- Category Operations → Category Repository: queries and saves (evidence: `src/main/java/com/stocksense/inventory/service/CategoryService.java`)
- Category Operations → Product Repository: checks usage (evidence: `src/main/java/com/stocksense/inventory/service/CategoryService.java`)
- Category Operations → Category Mapper: maps categories (evidence: `src/main/java/com/stocksense/inventory/service/CategoryService.java`)
- Product Mapper → Product DTOs: maps DTOs (evidence: `src/main/java/com/stocksense/inventory/mapper/ProductMapper.java`)
- Product Mapper → Product Entity: maps entity (evidence: `src/main/java/com/stocksense/inventory/mapper/ProductMapper.java`)
- Category Mapper → Category DTOs: maps DTOs (evidence: `src/main/java/com/stocksense/inventory/mapper/CatgeoryMapper.java`)
- Category Mapper → Category Entity: maps entity (evidence: `src/main/java/com/stocksense/inventory/mapper/CatgeoryMapper.java`)
- Product Repository → Product Entity: persists (evidence: `src/main/java/com/stocksense/inventory/repository/ProductRepository.java`)
- Category Repository → Category Entity: persists (evidence: `src/main/java/com/stocksense/inventory/repository/CategoryRepository.java`)
- Product Repository → MySQL: stores inventory (evidence: `README.md`)
- Category Repository → MySQL: stores categories (evidence: `README.md`)
- Error Responses → API Client: returns JSON errors (evidence: `src/main/java/com/stocksense/inventory/exception/GlobalExceptionHandler.java`)
