# maydeixxx/loyaltyengine architecture

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

- Interactive diagram: https://gitdiagram.com/maydeixxx/loyaltyengine
- Repository: https://github.com/maydeixxx/loyaltyengine

## Overview

OmniPoint is a loyalty platform with a React storefront and Java microservices. The main purchase flow submits an idempotent transaction, publishes it through Kafka, calculates cashback in the rule engine, and applies the result to a wallet; user registration also triggers wallet initialization. The README documents the broader capabilities, including product catalog, rule administration, wallet controls, JWT/RBAC, and outbox-based event handling. Source excerpts confirm several service internals; unsampled links are included only where the README documents them.

Main entry points: [`GatewayService/src/main/java/com/LoyaltyEngine/GatewayService/GatewayServiceApplication.java`](https://github.com/maydeixxx/loyaltyengine/blob/main/GatewayService/src/main/java/com/LoyaltyEngine/GatewayService/GatewayServiceApplication.java) (API Gateway), [`frontend/src/App.tsx`](https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/App.tsx) (SPA Router), [`RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/CalculateCashbackService.java`](https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/CalculateCashbackService.java) (Cashback Calculation), [`RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/RuleEngineService.java`](https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/RuleEngineService.java) (Rule Management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Experience"]
  node_app["SPA Router<br/>[App.tsx]"]
  node_checkout["Checkout UI<br/>[CheckoutPage.tsx]"]
  node_walletui["Wallet UI<br/>[WalletPage.tsx]"]
  node_adminui["Admin UI<br/>[AdminPage.tsx]"]
end

subgraph group_edge["Gateway and Discovery"]
  node_api["API Gateway"]
  node_eureka["Service Discovery"]
end

subgraph group_identity["Identity and Catalog"]
  node_users["User Accounts<br/>[UserService.java]"]
  node_auth["Authentication<br/>[AuthService.java]"]
  node_products["Product Catalog"]
end

subgraph group_purchase["Purchase and Cashback"]
  node_transactions["Transaction Processing"]
  node_rules["Rule Management"]
  node_calculation["Cashback Calculation"]
  node_wallet["Wallet Operations<br/>[WalletService.java]"]
end

subgraph group_infra["Event Infrastructure"]
  node_kafka["Kafka Events"]
  node_rulecache[("Rule Cache<br/>[RedisConfig.java]")]
  node_ruledata[("Rule Database")]
  node_txoutbox[("Transaction Outbox")]
  node_walletoutbox[("Wallet Outbox")]
end

node_customer(("Customer or Admin"))

node_customer -->|"uses"| node_app
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_walletui
node_app -->|"routes to"| node_adminui
node_checkout -->|"submits purchase"| node_api
node_walletui -.->|"uses API"| node_api
node_adminui -.->|"manages rules"| node_api
node_api -->|"discovers services"| node_eureka
node_api -->|"routes requests"| node_transactions
node_api -->|"routes requests"| node_users
node_api -->|"routes requests"| node_rules
node_api -.->|"routes requests"| node_products
node_users -.->|"authenticates users"| node_auth
node_users -->|"publishes registration"| node_kafka
node_transactions -->|"records event"| node_txoutbox
node_txoutbox -->|"publishes transaction"| node_kafka
node_kafka -->|"delivers transaction"| node_calculation
node_calculation -->|"reads cached rules"| node_rulecache
node_calculation -->|"reads rules"| node_ruledata
node_calculation -->|"publishes result"| node_kafka
node_kafka -->|"delivers result"| node_wallet
node_wallet -->|"saves events"| node_walletoutbox
node_walletoutbox -->|"publishes outcome"| node_kafka
node_kafka -->|"initializes wallet"| node_wallet
node_adminui -->|"configures cashback"| node_rules
node_rules -->|"persists rules"| node_ruledata
node_rules -->|"evicts cache"| node_rulecache

click node_app "https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/App.tsx"
click node_checkout "https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/pages/CheckoutPage.tsx"
click node_walletui "https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/pages/WalletPage.tsx"
click node_adminui "https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/pages/AdminPage.tsx"
click node_api "https://github.com/maydeixxx/loyaltyengine/blob/main/GatewayService/src/main/java/com/LoyaltyEngine/GatewayService/GatewayServiceApplication.java"
click node_eureka "https://github.com/maydeixxx/loyaltyengine/blob/main/EurekaServer/src/main/java/com/LoyaltyEngine/EurekaServer/EurekaServerApplication.java"
click node_users "https://github.com/maydeixxx/loyaltyengine/blob/main/UserService/src/main/java/com/LoyaltyEngine/UserService/services/UserService.java"
click node_auth "https://github.com/maydeixxx/loyaltyengine/blob/main/UserService/src/main/java/com/LoyaltyEngine/UserService/services/AuthService.java"
click node_products "https://github.com/maydeixxx/loyaltyengine/blob/main/ProductService/src/main/java/com/LoyaltyEngine/ProductService/services/ProductService.java"
click node_transactions "https://github.com/maydeixxx/loyaltyengine/blob/main/TransactionService/src/main/java/com/LoyaltyEngine/TransactionService/services/TransactionService.java"
click node_rules "https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/RuleEngineService.java"
click node_calculation "https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/CalculateCashbackService.java"
click node_wallet "https://github.com/maydeixxx/loyaltyengine/blob/main/WalletService/src/main/java/com/LoyaltyEngine/WalletService/services/WalletService.java"
click node_rulecache "https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/configs/RedisConfig.java"
click node_ruledata "https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/interfaces/RuleEngineRepository.java"
click node_txoutbox "https://github.com/maydeixxx/loyaltyengine/blob/main/TransactionService/src/main/java/com/LoyaltyEngine/TransactionService/services/TransactionService.java"
click node_walletoutbox "https://github.com/maydeixxx/loyaltyengine/blob/main/WalletService/src/main/java/com/LoyaltyEngine/WalletService/services/OutboxEventService.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_app,node_checkout,node_walletui,node_adminui toneBlue
class node_api,node_eureka toneAmber
class node_users,node_auth,node_products toneMint
class node_transactions,node_rules,node_calculation,node_wallet toneRose
class node_kafka,node_rulecache,node_ruledata,node_txoutbox,node_walletoutbox,node_customer toneIndigo
```

## Components

### Web Experience

- [SPA Router](https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Checkout UI](https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/pages/CheckoutPage.tsx): `frontend/src/pages/CheckoutPage.tsx`
- [Wallet UI](https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/pages/WalletPage.tsx): `frontend/src/pages/WalletPage.tsx`
- [Admin UI](https://github.com/maydeixxx/loyaltyengine/blob/main/frontend/src/pages/AdminPage.tsx): `frontend/src/pages/AdminPage.tsx`

### Gateway and Discovery

- [API Gateway](https://github.com/maydeixxx/loyaltyengine/blob/main/GatewayService/src/main/java/com/LoyaltyEngine/GatewayService/GatewayServiceApplication.java): `GatewayService/src/main/java/com/LoyaltyEngine/GatewayService/GatewayServiceApplication.java`
- [Service Discovery](https://github.com/maydeixxx/loyaltyengine/blob/main/EurekaServer/src/main/java/com/LoyaltyEngine/EurekaServer/EurekaServerApplication.java): `EurekaServer/src/main/java/com/LoyaltyEngine/EurekaServer/EurekaServerApplication.java`

### Identity and Catalog

- [User Accounts](https://github.com/maydeixxx/loyaltyengine/blob/main/UserService/src/main/java/com/LoyaltyEngine/UserService/services/UserService.java): `UserService/src/main/java/com/LoyaltyEngine/UserService/services/UserService.java`
- [Authentication](https://github.com/maydeixxx/loyaltyengine/blob/main/UserService/src/main/java/com/LoyaltyEngine/UserService/services/AuthService.java): `UserService/src/main/java/com/LoyaltyEngine/UserService/services/AuthService.java`
- [Product Catalog](https://github.com/maydeixxx/loyaltyengine/blob/main/ProductService/src/main/java/com/LoyaltyEngine/ProductService/services/ProductService.java): `ProductService/src/main/java/com/LoyaltyEngine/ProductService/services/ProductService.java`

### Purchase and Cashback

- [Transaction Processing](https://github.com/maydeixxx/loyaltyengine/blob/main/TransactionService/src/main/java/com/LoyaltyEngine/TransactionService/services/TransactionService.java): `TransactionService/src/main/java/com/LoyaltyEngine/TransactionService/services/TransactionService.java`
- [Rule Management](https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/RuleEngineService.java): `RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/RuleEngineService.java`
- [Cashback Calculation](https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/CalculateCashbackService.java): `RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/CalculateCashbackService.java`
- [Wallet Operations](https://github.com/maydeixxx/loyaltyengine/blob/main/WalletService/src/main/java/com/LoyaltyEngine/WalletService/services/WalletService.java): `WalletService/src/main/java/com/LoyaltyEngine/WalletService/services/WalletService.java`

### Event Infrastructure

- **Kafka Events**
- [Rule Cache](https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/configs/RedisConfig.java): `RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/configs/RedisConfig.java`
- [Rule Database](https://github.com/maydeixxx/loyaltyengine/blob/main/RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/interfaces/RuleEngineRepository.java): `RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/interfaces/RuleEngineRepository.java`
- [Transaction Outbox](https://github.com/maydeixxx/loyaltyengine/blob/main/TransactionService/src/main/java/com/LoyaltyEngine/TransactionService/services/TransactionService.java): `TransactionService/src/main/java/com/LoyaltyEngine/TransactionService/services/TransactionService.java`
- [Wallet Outbox](https://github.com/maydeixxx/loyaltyengine/blob/main/WalletService/src/main/java/com/LoyaltyEngine/WalletService/services/OutboxEventService.java): `WalletService/src/main/java/com/LoyaltyEngine/WalletService/services/OutboxEventService.java`

### Other components

- **Customer or Admin**

## Connections

- Customer or Admin → SPA Router: uses
- SPA Router → Checkout UI: routes to (evidence: `frontend/src/App.tsx`)
- SPA Router → Wallet UI: routes to (evidence: `frontend/src/App.tsx`)
- SPA Router → Admin UI: routes to (evidence: `frontend/src/App.tsx`)
- Checkout UI → API Gateway: submits purchase
- Wallet UI → API Gateway: uses API
- Admin UI → API Gateway: manages rules
- API Gateway → Service Discovery: discovers services
- API Gateway → Transaction Processing: routes requests
- API Gateway → User Accounts: routes requests
- API Gateway → Rule Management: routes requests
- API Gateway → Product Catalog: routes requests
- User Accounts → Authentication: authenticates users (evidence: `UserService/src/main/java/com/LoyaltyEngine/UserService/services/AuthService.java`)
- User Accounts → Kafka Events: publishes registration
- Transaction Processing → Transaction Outbox: records event (evidence: `TransactionService/src/main/java/com/LoyaltyEngine/TransactionService/services/TransactionService.java`)
- Transaction Outbox → Kafka Events: publishes transaction
- Kafka Events → Cashback Calculation: delivers transaction
- Cashback Calculation → Rule Cache: reads cached rules
- Cashback Calculation → Rule Database: reads rules
- Cashback Calculation → Kafka Events: publishes result
- Kafka Events → Wallet Operations: delivers result
- Wallet Operations → Wallet Outbox: saves events (evidence: `WalletService/src/main/java/com/LoyaltyEngine/WalletService/services/WalletService.java`)
- Wallet Outbox → Kafka Events: publishes outcome
- Kafka Events → Wallet Operations: initializes wallet
- Admin UI → Rule Management: configures cashback
- Rule Management → Rule Database: persists rules (evidence: `RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/RuleEngineService.java`)
- Rule Management → Rule Cache: evicts cache (evidence: `RuleEngineService/src/main/java/com/LoyaltyEngine/RuleEngineService/services/RuleEngineService.java`)
