# asegomed/inventory-and-expiration-manager-stockdate- architecture

> Architecture diagram of the GitHub repository asegomed/inventory-and-expiration-manager-stockdate-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/asegomed/inventory-and-expiration-manager-stockdate-
- Repository: https://github.com/asegomed/inventory-and-expiration-manager-stockdate-

## Overview

StockDate is a web application for managing food inventory and expiration dates. The implemented workflow runs from a browser batch form through the inventory API, validation and persistence, then returns batch data; dashboard requests calculate and summarize expiration alerts. The README also documents planned dispatch/discard, reporting, and role-based access capabilities, which are not implemented yet. Edges reflect sampled calls or README statements; links for documented but unsampled capabilities are dashed and unverified.

Main entry points: [`Stockdate/src/main/java/stockdate/service/InventoryManager.java`](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/InventoryManager.java) (Inventory manager), [`Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java`](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java) (Inventory API), [`Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java`](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java) (Expiration alerts), [`Stockdate/src/main/java/stockdate/persistence/repository/InventoryRepository.java`](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/persistence/repository/InventoryRepository.java) (Inventory repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_webui["Inventory UI<br/>[app.js]"]
end

subgraph group_api["Presentation API"]
  node_inventory_api["Inventory API"]
  node_batch_request["Batch request"]
  node_batch_response["Batch response<br/>[BatchDTO.java]"]
  node_dashboard_response["Dashboard summary<br/>[DashboardDTO.java]"]
  node_access_control["Role access"]
end

subgraph group_domain["Inventory services"]
  node_inventory_manager["Inventory manager"]
  node_alerts["Expiration alerts"]
  node_factory["Batch factory<br/>[Factory.java]"]
  node_date_strategies["Date strategies<br/>[Strategy.java]"]
  node_stock_observer["Stock observer<br/>[Observer.java]"]
  node_dispatch_discard["Dispatch and discard"]
  node_reports["Waste reports<br/>[ReportService.java]"]
end

subgraph group_storage["Persistence"]
  node_batch_entity[("Batch records<br/>[BatchEntity.java]")]
  node_inventory_repository["Inventory repository"]
  node_sqlite[("SQLite database")]
end

node_user(("Staff user"))

node_user -->|"uses"| node_webui
node_webui -.->|"calls REST API"| node_inventory_api
node_inventory_api -->|"accepts"| node_batch_request
node_inventory_api -->|"delegates to"| node_inventory_manager
node_inventory_api -->|"requests dashboard"| node_alerts
node_inventory_manager -->|"reads and saves"| node_inventory_repository
node_inventory_manager -->|"creates and maps"| node_factory
node_inventory_manager -->|"validates dates"| node_date_strategies
node_inventory_manager -->|"notifies"| node_stock_observer
node_inventory_manager -->|"returns"| node_batch_response
node_alerts -->|"reads sorted batches"| node_inventory_repository
node_alerts -->|"maps batches"| node_factory
node_alerts -->|"builds"| node_dashboard_response
node_stock_observer -->|"implemented by"| node_alerts
node_factory -->|"selects"| node_date_strategies
node_inventory_repository -->|"persists"| node_batch_entity
node_inventory_repository -.->|"stores through JPA"| node_sqlite
node_dispatch_discard -.->|"planned workflow"| node_inventory_manager
node_reports -.->|"planned data access"| node_inventory_repository
node_access_control -.->|"planned authorization"| node_inventory_api

click node_webui "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/resources/static/js/app.js"
click node_inventory_api "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java"
click node_batch_request "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/request/CreateBatchRequest.java"
click node_batch_response "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/response/BatchDTO.java"
click node_dashboard_response "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/response/DashboardDTO.java"
click node_inventory_manager "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/InventoryManager.java"
click node_alerts "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java"
click node_factory "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/factory/Factory.java"
click node_date_strategies "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/strategy/Strategy.java"
click node_stock_observer "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/observer/Observer.java"
click node_dispatch_discard "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/request/DispatchRequest.java"
click node_reports "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/ReportService.java"
click node_access_control "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/config/SecurityConfig.java"
click node_batch_entity "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/persistence/entity/BatchEntity.java"
click node_inventory_repository "https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/persistence/repository/InventoryRepository.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_webui,node_user toneBlue
class node_inventory_api,node_batch_request,node_batch_response,node_dashboard_response,node_access_control toneAmber
class node_inventory_manager,node_alerts,node_factory,node_date_strategies,node_stock_observer,node_dispatch_discard,node_reports toneMint
class node_batch_entity,node_inventory_repository,node_sqlite toneRose
```

## Components

### Web interface

- [Inventory UI](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/resources/static/js/app.js): `Stockdate/src/main/resources/static/js/app.js`

### Presentation API

- [Inventory API](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java): `Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java`
- [Batch request](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/request/CreateBatchRequest.java): `Stockdate/src/main/java/stockdate/presentation/dto/request/CreateBatchRequest.java`
- [Batch response](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/response/BatchDTO.java): `Stockdate/src/main/java/stockdate/presentation/dto/response/BatchDTO.java`
- [Dashboard summary](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/response/DashboardDTO.java): `Stockdate/src/main/java/stockdate/presentation/dto/response/DashboardDTO.java`
- [Role access](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/config/SecurityConfig.java): `Stockdate/src/main/java/stockdate/config/SecurityConfig.java`

### Inventory services

- [Inventory manager](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/InventoryManager.java): `Stockdate/src/main/java/stockdate/service/InventoryManager.java`
- [Expiration alerts](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java): `Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java`
- [Batch factory](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/factory/Factory.java): `Stockdate/src/main/java/stockdate/service/factory/Factory.java`
- [Date strategies](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/strategy/Strategy.java): `Stockdate/src/main/java/stockdate/service/strategy/Strategy.java`
- [Stock observer](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/observer/Observer.java): `Stockdate/src/main/java/stockdate/service/observer/Observer.java`
- [Dispatch and discard](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/presentation/dto/request/DispatchRequest.java): `Stockdate/src/main/java/stockdate/presentation/dto/request/DispatchRequest.java`
- [Waste reports](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/service/ReportService.java): `Stockdate/src/main/java/stockdate/service/ReportService.java`

### Persistence

- [Batch records](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/persistence/entity/BatchEntity.java): `Stockdate/src/main/java/stockdate/persistence/entity/BatchEntity.java`
- [Inventory repository](https://github.com/asegomed/inventory-and-expiration-manager-stockdate-/blob/main/Stockdate/src/main/java/stockdate/persistence/repository/InventoryRepository.java): `Stockdate/src/main/java/stockdate/persistence/repository/InventoryRepository.java`
- **SQLite database**

### Other components

- **Staff user**

## Connections

- Staff user → Inventory UI: uses (evidence: `README.md`)
- Inventory UI → Inventory API: calls REST API (evidence: `README.md`)
- Inventory API → Batch request: accepts (evidence: `Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java`)
- Inventory API → Inventory manager: delegates to (evidence: `Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java`)
- Inventory API → Expiration alerts: requests dashboard (evidence: `Stockdate/src/main/java/stockdate/presentation/controller/InventoryController.java`)
- Inventory manager → Inventory repository: reads and saves (evidence: `Stockdate/src/main/java/stockdate/service/InventoryManager.java`)
- Inventory manager → Batch factory: creates and maps (evidence: `Stockdate/src/main/java/stockdate/service/InventoryManager.java`)
- Inventory manager → Date strategies: validates dates (evidence: `Stockdate/src/main/java/stockdate/service/InventoryManager.java`)
- Inventory manager → Stock observer: notifies (evidence: `Stockdate/src/main/java/stockdate/service/InventoryManager.java`)
- Inventory manager → Batch response: returns (evidence: `Stockdate/src/main/java/stockdate/service/InventoryManager.java`)
- Expiration alerts → Inventory repository: reads sorted batches (evidence: `Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java`)
- Expiration alerts → Batch factory: maps batches (evidence: `Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java`)
- Expiration alerts → Dashboard summary: builds (evidence: `Stockdate/src/main/java/stockdate/service/ExpirationAlertService.java`)
- Stock observer → Expiration alerts: implemented by (evidence: `Stockdate/src/main/java/stockdate/service/observer/Observer.java`)
- Batch factory → Date strategies: selects (evidence: `Stockdate/src/main/java/stockdate/service/factory/Factory.java`)
- Inventory repository → Batch records: persists (evidence: `Stockdate/src/main/java/stockdate/persistence/repository/InventoryRepository.java`)
- Inventory repository → SQLite database: stores through JPA (evidence: `README.md`)
- Dispatch and discard → Inventory manager: planned workflow (evidence: `README.md`)
- Waste reports → Inventory repository: planned data access
- Role access → Inventory API: planned authorization (evidence: `README.md`)
