# coffeezombietux/customerservice architecture

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

- Interactive diagram: https://gitdiagram.com/coffeezombietux/customerservice
- Repository: https://github.com/coffeezombietux/customerservice

## Overview

Customer Loyalty & Account Service is a REST API for customer identity, profiles, bonus balances, and consent records, serving customers, administrators, and internal services. The main journey runs from registration and consent capture through email activation to login and token-backed sessions; separate paths manage profiles, agreements, and bonus operations. The README describes PostgreSQL persistence and independently secured API surfaces. Sampled services show authentication, token validation, bonus updates, and agreement auditing; unsampled controller-to-service connections are left unverified.

Main entry points: [`src/main/java/io/customerservice/customerservice/service/AuthService.java`](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AuthService.java) (Auth and sessions), [`src/main/java/io/customerservice/customerservice/service/CustomerService.java`](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/CustomerService.java) (Customer service), [`src/main/java/io/customerservice/customerservice/controller/internal`](https://github.com/coffeezombietux/customerservice/tree/master/src/main/java/io/customerservice/customerservice/controller/internal) (Internal APIs), [`src/main/java/io/customerservice/customerservice/service/AgreementService.java`](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AgreementService.java) (Agreement audit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surfaces"]
  node_authapi["Auth API"]
  node_customerapi["Customer API"]
  node_adminapi["Admin API"]
  node_internalapi["Internal APIs"]
end

subgraph group_identity["Identity and security"]
  node_auth["Auth and sessions<br/>[AuthService.java]"]
  node_jwt["JWT service<br/>[JwtService.java]"]
end

subgraph group_domain["Customer domains"]
  node_customer["Customer service"]
  node_agreements["Agreement audit"]
  node_bonus["Bonus accounts<br/>[BonusService.java]"]
  node_addresses["Address management"]
  node_adminservice["Admin operations<br/>[AdminService.java]"]
  node_email["Activation email<br/>[EmailService.java]"]
end

subgraph group_persistence["Persistence"]
  node_customerrepo[("Customer records")]
  node_sessionsrepo[("Refresh sessions")]
  node_agreementsrepo[("Consent records")]
  node_postgres[("PostgreSQL")]
end

node_client(("Customer client"))
node_adminactor(("Admin panel"))
node_internalactor(("Internal services"))
node_gateway["API Gateway"]

node_client -->|"sends requests"| node_gateway
node_adminactor -->|"sends requests"| node_gateway
node_internalactor -->|"calls API key routes"| node_internalapi
node_gateway -->|"routes customer calls"| node_authapi
node_gateway -->|"routes customer calls"| node_customerapi
node_gateway -->|"routes admin calls"| node_adminapi
node_authapi -->|"delegates to"| node_auth
node_customerapi -->|"delegates to"| node_customer
node_adminapi -->|"delegates to"| node_adminservice
node_auth -->|"reads and saves"| node_customerrepo
node_auth -->|"rotates sessions"| node_sessionsrepo
node_auth -->|"generates tokens"| node_jwt
node_auth -->|"sends activation email"| node_email
node_customer -->|"validates token claims"| node_jwt
node_customer -->|"reads and updates"| node_customerrepo
node_customer -->|"checks sessions"| node_sessionsrepo
node_agreements -->|"reads and appends"| node_agreementsrepo
node_internalapi -.->|"dispatches bonus calls"| node_bonus
node_internalapi -.->|"dispatches customer calls"| node_customer
node_internalapi -.->|"dispatches agreement calls"| node_agreements
node_auth -->|"records registration consents"| node_agreementsrepo
node_auth -->|"persists account data"| node_postgres
node_bonus -->|"persists balances and transactions"| node_postgres
node_agreements -->|"persists consent history"| node_postgres
node_addresses -->|"persists addresses"| node_postgres

click node_authapi "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/controller/AuthController.java"
click node_customerapi "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/controller/CustomerController.java"
click node_adminapi "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/controller/admin/AdminController.java"
click node_internalapi "https://github.com/coffeezombietux/customerservice/tree/master/src/main/java/io/customerservice/customerservice/controller/internal"
click node_auth "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AuthService.java"
click node_jwt "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/security/JwtService.java"
click node_customer "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/CustomerService.java"
click node_agreements "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AgreementService.java"
click node_bonus "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/BonusService.java"
click node_addresses "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AddressService.java"
click node_adminservice "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AdminService.java"
click node_email "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/EmailService.java"
click node_customerrepo "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/repository/CustomerRepository.java"
click node_sessionsrepo "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/repository/RefreshTokenRepository.java"
click node_agreementsrepo "https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/repository/CustomerAgreementRepository.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_authapi,node_customerapi,node_adminapi,node_internalapi,node_client toneBlue
class node_auth,node_jwt toneAmber
class node_customer,node_agreements,node_bonus,node_addresses,node_adminservice,node_email,node_gateway toneMint
class node_customerrepo,node_sessionsrepo,node_agreementsrepo,node_postgres toneRose
class node_adminactor,node_internalactor toneIndigo
```

## Components

### API surfaces

- [Auth API](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/controller/AuthController.java): `src/main/java/io/customerservice/customerservice/controller/AuthController.java`
- [Customer API](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/controller/CustomerController.java): `src/main/java/io/customerservice/customerservice/controller/CustomerController.java`
- [Admin API](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/controller/admin/AdminController.java): `src/main/java/io/customerservice/customerservice/controller/admin/AdminController.java`
- [Internal APIs](https://github.com/coffeezombietux/customerservice/tree/master/src/main/java/io/customerservice/customerservice/controller/internal): `src/main/java/io/customerservice/customerservice/controller/internal`

### Identity and security

- [Auth and sessions](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AuthService.java): `src/main/java/io/customerservice/customerservice/service/AuthService.java`
- [JWT service](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/security/JwtService.java): `src/main/java/io/customerservice/customerservice/security/JwtService.java`

### Customer domains

- [Customer service](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/CustomerService.java): `src/main/java/io/customerservice/customerservice/service/CustomerService.java`
- [Agreement audit](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AgreementService.java): `src/main/java/io/customerservice/customerservice/service/AgreementService.java`
- [Bonus accounts](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/BonusService.java): `src/main/java/io/customerservice/customerservice/service/BonusService.java`
- [Address management](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AddressService.java): `src/main/java/io/customerservice/customerservice/service/AddressService.java`
- [Admin operations](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/AdminService.java): `src/main/java/io/customerservice/customerservice/service/AdminService.java`
- [Activation email](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/service/EmailService.java): `src/main/java/io/customerservice/customerservice/service/EmailService.java`

### Persistence

- [Customer records](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/repository/CustomerRepository.java): `src/main/java/io/customerservice/customerservice/repository/CustomerRepository.java`
- [Refresh sessions](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/repository/RefreshTokenRepository.java): `src/main/java/io/customerservice/customerservice/repository/RefreshTokenRepository.java`
- [Consent records](https://github.com/coffeezombietux/customerservice/blob/master/src/main/java/io/customerservice/customerservice/repository/CustomerAgreementRepository.java): `src/main/java/io/customerservice/customerservice/repository/CustomerAgreementRepository.java`
- **PostgreSQL**

### Other components

- **Customer client**
- **Admin panel**
- **Internal services**
- **API Gateway**

## Connections

- Customer client → API Gateway: sends requests (evidence: `README.md`)
- Admin panel → API Gateway: sends requests (evidence: `README.md`)
- Internal services → Internal APIs: calls API key routes (evidence: `README.md`)
- API Gateway → Auth API: routes customer calls (evidence: `README.md`)
- API Gateway → Customer API: routes customer calls (evidence: `README.md`)
- API Gateway → Admin API: routes admin calls (evidence: `README.md`)
- Auth API → Auth and sessions: delegates to (evidence: `src/main/java/io/customerservice/customerservice/controller/AuthController.java`)
- Customer API → Customer service: delegates to (evidence: `src/main/java/io/customerservice/customerservice/controller/CustomerController.java`)
- Admin API → Admin operations: delegates to (evidence: `src/main/java/io/customerservice/customerservice/controller/admin/AdminController.java`)
- Auth and sessions → Customer records: reads and saves (evidence: `src/main/java/io/customerservice/customerservice/service/AuthService.java`)
- Auth and sessions → Refresh sessions: rotates sessions (evidence: `src/main/java/io/customerservice/customerservice/service/AuthService.java`)
- Auth and sessions → JWT service: generates tokens (evidence: `src/main/java/io/customerservice/customerservice/service/AuthService.java`)
- Auth and sessions → Activation email: sends activation email (evidence: `src/main/java/io/customerservice/customerservice/service/AuthService.java`)
- Customer service → JWT service: validates token claims (evidence: `src/main/java/io/customerservice/customerservice/service/CustomerService.java`)
- Customer service → Customer records: reads and updates (evidence: `src/main/java/io/customerservice/customerservice/service/CustomerService.java`)
- Customer service → Refresh sessions: checks sessions (evidence: `src/main/java/io/customerservice/customerservice/service/CustomerService.java`)
- Agreement audit → Consent records: reads and appends (evidence: `src/main/java/io/customerservice/customerservice/service/AgreementService.java`)
- Internal APIs → Bonus accounts: dispatches bonus calls (evidence: `src/main/java/io/customerservice/customerservice/controller/internal/InternalBonusController.java`)
- Internal APIs → Customer service: dispatches customer calls (evidence: `src/main/java/io/customerservice/customerservice/controller/internal/InternalCustomerController.java`)
- Internal APIs → Agreement audit: dispatches agreement calls (evidence: `src/main/java/io/customerservice/customerservice/controller/internal/InternalAgreementController.java`)
- Auth and sessions → Consent records: records registration consents (evidence: `src/main/java/io/customerservice/customerservice/service/AuthService.java`)
- Auth and sessions → PostgreSQL: persists account data (evidence: `README.md`)
- Bonus accounts → PostgreSQL: persists balances and transactions (evidence: `README.md`)
- Agreement audit → PostgreSQL: persists consent history (evidence: `README.md`)
- Address management → PostgreSQL: persists addresses (evidence: `README.md`)
