# pardiv-db0779/spendx-backend architecture

> Architecture diagram of the GitHub repository pardiv-db0779/spendx-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pardiv-db0779/spendx-backend
- Repository: https://github.com/pardiv-db0779/spendx-backend

## Overview

SpendX is an Azure Functions API for creating and managing event spend-threshold offers. The principal flow accepts offer inputs, validates and processes them in the service, persists offer and SKU details through the repository, and returns offer results. Separate operations support overview editing, SKU data views and recalculation, brand search, pricing extracts, and moving offers between flyer positions. The excerpts establish controller-to-service and service-to-repository behavior; wiring for some endpoints and integrations is not fully shown, so uncertain links are omitted.

Main entry points: [`GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs) (Offer endpoints), [`GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs`](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs) (Offer data access), [`GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs`](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs) (EF data mapping), [`GPC.Boost.SpendX/GPC.Boost.SpendX.Service/SpendXService.cs`](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Service/SpendXService.cs) (Offer workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_controller["Offer endpoints"]
  node_middleware["Exception handling"]
end

subgraph group_business["Offer operations"]
  node_service["Offer workflows<br/>[SpendXService.cs]"]
  node_validators["Request validation"]
end

subgraph group_persistence["Persistence"]
  node_repository["Offer data access"]
  node_context["EF data mapping<br/>[SpendXDbContext.cs]"]
  node_database[("SpendX database")]
end

subgraph group_contracts["Domain contracts"]
  node_offer["Offer records<br/>[TEventOffer.cs]"]
  node_offer_detail["Offer SKU details"]
  node_product["Product records<br/>[TProduct.cs]"]
  node_offer_type["Offer type<br/>[OfferType.cs]"]
  node_create_request["Offer input"]
  node_overview_request["Overview input"]
  node_dataview_request["Data view input"]
  node_move_request["Move input"]
  node_dataview_response["Data view result"]
  node_api_response["API responses<br/>[APIResponseDto.cs]"]
  node_pricing_request["Pricing input"]
  node_brand_request["Brand search input"]
end

node_caller(("API caller"))

node_caller -->|"sends requests"| node_controller
node_controller -->|"invokes workflows"| node_service
node_controller -->|"validates inputs"| node_validators
node_controller -->|"deserializes"| node_create_request
node_controller -->|"deserializes"| node_overview_request
node_controller -->|"builds query"| node_dataview_request
node_controller -->|"deserializes"| node_move_request
node_controller -->|"builds query"| node_pricing_request
node_controller -->|"accepts search"| node_brand_request
node_controller -->|"returns result"| node_dataview_response
node_controller -->|"formats errors"| node_api_response
node_service -->|"requests data"| node_repository
node_repository -->|"queries and saves"| node_context
node_context -->|"maps entities"| node_database
node_repository -->|"persists"| node_offer
node_repository -->|"persists"| node_offer_detail
node_repository -->|"queries products"| node_product
node_context -->|"maps entity"| node_offer
node_context -->|"maps entity"| node_offer_detail
node_context -->|"maps entity"| node_product
node_service -->|"uses offer types"| node_offer_type
node_middleware -.->|"wraps failures"| node_controller

click node_controller "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs"
click node_middleware "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Middleware/GlobalExceptionMiddleware.cs"
click node_service "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Service/SpendXService.cs"
click node_repository "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs"
click node_context "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs"
click node_offer "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TEventOffer.cs"
click node_offer_detail "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TEventOfferDetail.cs"
click node_product "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TProduct.cs"
click node_offer_type "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Enums/OfferType.cs"
click node_create_request "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/EventOfferRequestDto.cs"
click node_overview_request "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/SpendXOverviewRequestDto.cs"
click node_dataview_request "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/DataViewRequestDto.cs"
click node_move_request "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/MoveOfferRequestDto.cs"
click node_dataview_response "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/ResponseDto/DataViewResponseDto.cs"
click node_api_response "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/ResponseDto/APIResponseDto.cs"
click node_pricing_request "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/PricingExtractRequestDto.cs"
click node_brand_request "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/SearchByBrandRequestDto.cs"
click node_validators "https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Validation/Validators/SpendXValidators.cs"

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_controller,node_middleware toneBlue
class node_service,node_validators toneAmber
class node_repository,node_context,node_database,node_caller toneMint
class node_offer,node_offer_detail,node_product,node_offer_type,node_create_request,node_overview_request,node_dataview_request,node_move_request,node_dataview_response,node_api_response,node_pricing_request,node_brand_request toneRose
```

## Components

### API entry

- [Offer endpoints](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`
- [Exception handling](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Middleware/GlobalExceptionMiddleware.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Middleware/GlobalExceptionMiddleware.cs`

### Offer operations

- [Offer workflows](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Service/SpendXService.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Service/SpendXService.cs`
- [Request validation](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Validation/Validators/SpendXValidators.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Validation/Validators/SpendXValidators.cs`

### Persistence

- [Offer data access](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs`
- [EF data mapping](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs`
- **SpendX database**

### Domain contracts

- [Offer records](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TEventOffer.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TEventOffer.cs`
- [Offer SKU details](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TEventOfferDetail.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TEventOfferDetail.cs`
- [Product records](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TProduct.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Models/TProduct.cs`
- [Offer type](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Enums/OfferType.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Domain/Enums/OfferType.cs`
- [Offer input](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/EventOfferRequestDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/EventOfferRequestDto.cs`
- [Overview input](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/SpendXOverviewRequestDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/SpendXOverviewRequestDto.cs`
- [Data view input](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/DataViewRequestDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/DataViewRequestDto.cs`
- [Move input](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/MoveOfferRequestDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/MoveOfferRequestDto.cs`
- [Data view result](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/ResponseDto/DataViewResponseDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/ResponseDto/DataViewResponseDto.cs`
- [API responses](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/ResponseDto/APIResponseDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/ResponseDto/APIResponseDto.cs`
- [Pricing input](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/PricingExtractRequestDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/PricingExtractRequestDto.cs`
- [Brand search input](https://github.com/pardiv-db0779/spendx-backend/blob/main/GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/SearchByBrandRequestDto.cs): `GPC.Boost.SpendX/GPC.Boost.SpendX.Dto/RequestDto/SearchByBrandRequestDto.cs`

### Other components

- **API caller**

## Connections

- API caller → Offer endpoints: sends requests (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Offer workflows: invokes workflows
- Offer endpoints → Request validation: validates inputs (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Offer input: deserializes (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Overview input: deserializes (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Data view input: builds query (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Move input: deserializes (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Pricing input: builds query (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Brand search input: accepts search (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → Data view result: returns result (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer endpoints → API responses: formats errors (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Api/Controllers/EventOfferController.cs`)
- Offer workflows → Offer data access: requests data (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Service/SpendXService.cs`)
- Offer data access → EF data mapping: queries and saves (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs`)
- EF data mapping → SpendX database: maps entities (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs`)
- Offer data access → Offer records: persists (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs`)
- Offer data access → Offer SKU details: persists (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs`)
- Offer data access → Product records: queries products (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Repository/SpendXRepository.cs`)
- EF data mapping → Offer records: maps entity (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs`)
- EF data mapping → Offer SKU details: maps entity (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs`)
- EF data mapping → Product records: maps entity (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Data/SpendXDbContext.cs`)
- Offer workflows → Offer type: uses offer types (evidence: `GPC.Boost.SpendX/GPC.Boost.SpendX.Service/SpendXService.cs`)
- Exception handling → Offer endpoints: wraps failures
