# nithin900/paymentsecurityjourney architecture

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

- Interactive diagram: https://gitdiagram.com/nithin900/paymentsecurityjourney
- Repository: https://github.com/nithin900/paymentsecurityjourney

## Overview

Payment Security Journey is a four-service payment system: a user obtains an OAuth2 token, submits a payment through Service A, and Service B validates the token, enforces ownership, persists the payment, and requests an email notification. Service B obtains a separate client-credentials token for the notification call. The README documents these cross-service relationships and the failure guarantees; the source excerpts do not expose the services’ full internal call chains, so the graph stays at documented subsystem boundaries.

Main entry points: [`payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java`](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java) (Payment processing), [`payment-authorization-server/src/main/java/com/example/payment_authorization_server/Config/SecurityConfig.java`](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-authorization-server/src/main/java/com/example/payment_authorization_server/Config/SecurityConfig.java) (Authorization server), [`payment-service-b/src/main/java/org/example/Notification/NotificationListener.java`](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Notification/NotificationListener.java) (Notification listener), [`payment-service-a/src/main/java/com/example/PaymentA/Service/PaymentServiceImpl.java`](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-a/src/main/java/com/example/PaymentA/Service/PaymentServiceImpl.java) (Service A gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_auth["Authorization server"]
  node_ownership["Ownership checks"]
  node_a_security["Service A security"]
  node_b_security["Service B security"]
  node_n_security["Notification security"]
end

subgraph group_payments["Payment processing"]
  node_servicea["Service A gateway"]
  node_acontroller["Payment API"]
  node_bcontroller["Service B API"]
  node_bservice["Payment processing"]
  node_payment["Payment record<br/>[Payment.java]"]
  node_repository["Payment repository"]
  node_database[("H2 database<br/>[schema.sql]")]
end

subgraph group_notification["Email notification"]
  node_event["Payment-created event"]
  node_listener["Notification listener"]
  node_notifclient["Notification client"]
  node_notification["Notification API"]
  node_emailservice["Email delivery"]
end

subgraph group_operations["Errors and resilience"]
  node_errors["Error handling"]
end

node_user(("Payment user"))
node_smtp["Gmail SMTP"]

node_user -->|"logs in"| node_auth
node_auth -->|"issues JWT"| node_user
node_user -->|"submits payment"| node_acontroller
node_acontroller -.->|"delegates"| node_servicea
node_servicea -->|"forwards JWT"| node_bcontroller
node_a_security -->|"validates JWT"| node_auth
node_b_security -->|"revalidates JWT"| node_auth
node_bcontroller -.->|"processes request"| node_bservice
node_bservice -->|"checks owner"| node_ownership
node_bservice -->|"persists payment"| node_repository
node_repository -->|"reads and writes"| node_database
node_bservice -.->|"creates record"| node_payment
node_bservice -->|"requests notification"| node_event
node_listener -.->|"handles event"| node_event
node_listener -->|"gets client token"| node_auth
node_listener -.->|"dispatches request"| node_notifclient
node_notifclient -.->|"sends notification"| node_notification
node_n_security -->|"validates JWT"| node_auth
node_notification -.->|"sends email"| node_emailservice
node_emailservice -->|"delivers email"| node_smtp
node_bservice -->|"maps failures"| node_errors

click node_auth "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-authorization-server/src/main/java/com/example/payment_authorization_server/Config/SecurityConfig.java"
click node_servicea "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-a/src/main/java/com/example/PaymentA/Service/PaymentServiceImpl.java"
click node_acontroller "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-a/src/main/java/com/example/PaymentA/Controller/PaymentController.java"
click node_bcontroller "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Controller/PaymentController.java"
click node_bservice "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java"
click node_ownership "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java"
click node_payment "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Entity/Payment.java"
click node_repository "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Repository/PaymentRepository.java"
click node_database "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/resources/schema.sql"
click node_event "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Notification/PaymentCreatedEvent.java"
click node_listener "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Notification/NotificationListener.java"
click node_notifclient "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Config/NotificationClientConfig.java"
click node_notification "https://github.com/nithin900/paymentsecurityjourney/blob/main/NotificationService/src/main/java/com/example/NotificationService/Controller/NotificationController.java"
click node_emailservice "https://github.com/nithin900/paymentsecurityjourney/blob/main/NotificationService/src/main/java/com/example/NotificationService/Service/EmailNotificationService.java"
click node_a_security "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-a/src/main/java/com/example/PaymentA/Security/SecurityConfig.java"
click node_b_security "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Config/SecurityConfig.java"
click node_n_security "https://github.com/nithin900/paymentsecurityjourney/blob/main/NotificationService/src/main/java/com/example/NotificationService/Config/SecurityConfig.java"
click node_errors "https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Exceptions/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_auth,node_ownership,node_a_security,node_b_security,node_n_security,node_user toneBlue
class node_servicea,node_acontroller,node_bcontroller,node_bservice,node_payment,node_repository,node_database toneAmber
class node_event,node_listener,node_notifclient,node_notification,node_emailservice toneMint
class node_errors toneRose
class node_smtp toneIndigo
```

## Components

### Identity and access

- [Authorization server](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-authorization-server/src/main/java/com/example/payment_authorization_server/Config/SecurityConfig.java): `payment-authorization-server/src/main/java/com/example/payment_authorization_server/Config/SecurityConfig.java`
- [Ownership checks](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java): `payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java`
- [Service A security](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-a/src/main/java/com/example/PaymentA/Security/SecurityConfig.java): `payment-service-a/src/main/java/com/example/PaymentA/Security/SecurityConfig.java`
- [Service B security](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Config/SecurityConfig.java): `payment-service-b/src/main/java/org/example/Config/SecurityConfig.java`
- [Notification security](https://github.com/nithin900/paymentsecurityjourney/blob/main/NotificationService/src/main/java/com/example/NotificationService/Config/SecurityConfig.java): `NotificationService/src/main/java/com/example/NotificationService/Config/SecurityConfig.java`

### Payment processing

- [Service A gateway](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-a/src/main/java/com/example/PaymentA/Service/PaymentServiceImpl.java): `payment-service-a/src/main/java/com/example/PaymentA/Service/PaymentServiceImpl.java`
- [Payment API](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-a/src/main/java/com/example/PaymentA/Controller/PaymentController.java): `payment-service-a/src/main/java/com/example/PaymentA/Controller/PaymentController.java`
- [Service B API](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Controller/PaymentController.java): `payment-service-b/src/main/java/org/example/Controller/PaymentController.java`
- [Payment processing](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java): `payment-service-b/src/main/java/org/example/Service/PaymentServiceImpl.java`
- [Payment record](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Entity/Payment.java): `payment-service-b/src/main/java/org/example/Entity/Payment.java`
- [Payment repository](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Repository/PaymentRepository.java): `payment-service-b/src/main/java/org/example/Repository/PaymentRepository.java`
- [H2 database](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/resources/schema.sql): `payment-service-b/src/main/resources/schema.sql`

### Email notification

- [Payment-created event](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Notification/PaymentCreatedEvent.java): `payment-service-b/src/main/java/org/example/Notification/PaymentCreatedEvent.java`
- [Notification listener](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Notification/NotificationListener.java): `payment-service-b/src/main/java/org/example/Notification/NotificationListener.java`
- [Notification client](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Config/NotificationClientConfig.java): `payment-service-b/src/main/java/org/example/Config/NotificationClientConfig.java`
- [Notification API](https://github.com/nithin900/paymentsecurityjourney/blob/main/NotificationService/src/main/java/com/example/NotificationService/Controller/NotificationController.java): `NotificationService/src/main/java/com/example/NotificationService/Controller/NotificationController.java`
- [Email delivery](https://github.com/nithin900/paymentsecurityjourney/blob/main/NotificationService/src/main/java/com/example/NotificationService/Service/EmailNotificationService.java): `NotificationService/src/main/java/com/example/NotificationService/Service/EmailNotificationService.java`

### Errors and resilience

- [Error handling](https://github.com/nithin900/paymentsecurityjourney/blob/main/payment-service-b/src/main/java/org/example/Exceptions/GlobalExceptionHandler.java): `payment-service-b/src/main/java/org/example/Exceptions/GlobalExceptionHandler.java`

### Other components

- **Payment user**
- **Gmail SMTP**

## Connections

- Payment user → Authorization server: logs in (evidence: `README.md`)
- Authorization server → Payment user: issues JWT (evidence: `README.md`)
- Payment user → Payment API: submits payment (evidence: `README.md`)
- Payment API → Service A gateway: delegates
- Service A gateway → Service B API: forwards JWT (evidence: `README.md`)
- Service A security → Authorization server: validates JWT (evidence: `README.md`)
- Service B security → Authorization server: revalidates JWT (evidence: `README.md`)
- Service B API → Payment processing: processes request
- Payment processing → Ownership checks: checks owner (evidence: `README.md`)
- Payment processing → Payment repository: persists payment (evidence: `README.md`)
- Payment repository → H2 database: reads and writes (evidence: `README.md`)
- Payment processing → Payment record: creates record
- Payment processing → Payment-created event: requests notification (evidence: `README.md`)
- Notification listener → Payment-created event: handles event
- Notification listener → Authorization server: gets client token (evidence: `README.md`)
- Notification listener → Notification client: dispatches request
- Notification client → Notification API: sends notification
- Notification security → Authorization server: validates JWT (evidence: `README.md`)
- Notification API → Email delivery: sends email
- Email delivery → Gmail SMTP: delivers email (evidence: `README.md`)
- Payment processing → Error handling: maps failures (evidence: `README.md`)
