# june21621/car-pay-in-private architecture

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

- Interactive diagram: https://gitdiagram.com/june21621/car-pay-in-private
- Repository: https://github.com/june21621/car-pay-in-private

## Overview

This repository combines CarPayIn service code with a small slice of its private-cloud operations. The README’s principal private-cloud workflow is monitoring-triggered scaling: alerts reach the webhook adapter, which triggers GitLab CI and Ansible to adjust k3s capacity. The private-cloud runtime serves mock-card behind Octavia and Traefik. The tree does not include the documented Terraform or Ansible sources, so those operational components are represented as documented external systems; the broader AWS-hosted services are not expanded here.

Main entry points: [`services/mock-card/app/api/routes/card.py`](https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/api/routes/card.py) (Card API), [`infra/webhook-adapter/main.py`](https://github.com/june21621/car-pay-in-private/blob/main/infra/webhook-adapter/main.py) (Webhook adapter), [`services/mock-card/app/application/card/approve_card_payment.py`](https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/application/card/approve_card_payment.py) (Card approval), [`services/mock-card/app/application/card/verify_and_tokenize_card.py`](https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/application/card/verify_and_tokenize_card.py) (Card tokenization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scaling["Autoscaling"]
  node_prometheus["Prometheus"]
  node_alertmanager["AlertManager"]
  node_adapter["Webhook adapter<br/>[main.py]"]
  node_gitlab["GitLab CI"]
  node_ansible["Ansible scaling"]
end

subgraph group_cluster["Private Runtime"]
  node_k3s["k3s cluster"]
  node_octavia["Octavia LB"]
  node_traefik["Traefik ingress"]
  node_vpn["WireGuard VPN"]
end

subgraph group_cards["Card Service"]
  node_card_route["Card API<br/>[card.py]"]
  node_card_approval["Card approval"]
  node_card_tokenization["Card tokenization"]
  node_card_db[("Card database<br/>[models.py]")]
end

node_aws(("AWS traffic"))

node_prometheus -->|"alerts on CPU"| node_alertmanager
node_alertmanager -->|"posts alerts"| node_adapter
node_adapter -->|"triggers pipeline"| node_gitlab
node_gitlab -->|"runs scaling"| node_ansible
node_ansible -->|"adds or drains nodes"| node_k3s
node_aws -->|"tunnels traffic"| node_vpn
node_vpn -->|"DNATs to VIP"| node_octavia
node_octavia -->|"forwards traffic"| node_traefik
node_traefik -->|"routes to pods"| node_card_route
node_card_route -->|"invokes"| node_card_approval
node_card_route -->|"invokes"| node_card_tokenization

click node_adapter "https://github.com/june21621/car-pay-in-private/blob/main/infra/webhook-adapter/main.py"
click node_card_route "https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/api/routes/card.py"
click node_card_approval "https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/application/card/approve_card_payment.py"
click node_card_tokenization "https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/application/card/verify_and_tokenize_card.py"
click node_card_db "https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/infra/db/models.py"

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_prometheus,node_alertmanager,node_adapter,node_gitlab,node_ansible toneBlue
class node_k3s,node_octavia,node_traefik,node_vpn toneAmber
class node_card_route,node_card_approval,node_card_tokenization,node_card_db toneMint
class node_aws toneIndigo
```

## Components

### Autoscaling

- **Prometheus**
- **AlertManager**
- [Webhook adapter](https://github.com/june21621/car-pay-in-private/blob/main/infra/webhook-adapter/main.py): `infra/webhook-adapter/main.py`
- **GitLab CI**
- **Ansible scaling**

### Private Runtime

- **k3s cluster**
- **Octavia LB**
- **Traefik ingress**
- **WireGuard VPN**

### Card Service

- [Card API](https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/api/routes/card.py): `services/mock-card/app/api/routes/card.py`
- [Card approval](https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/application/card/approve_card_payment.py): `services/mock-card/app/application/card/approve_card_payment.py`
- [Card tokenization](https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/application/card/verify_and_tokenize_card.py): `services/mock-card/app/application/card/verify_and_tokenize_card.py`
- [Card database](https://github.com/june21621/car-pay-in-private/blob/main/services/mock-card/app/infra/db/models.py): `services/mock-card/app/infra/db/models.py`

### Other components

- **AWS traffic**

## Connections

- Prometheus → AlertManager: alerts on CPU
- AlertManager → Webhook adapter: posts alerts
- Webhook adapter → GitLab CI: triggers pipeline
- GitLab CI → Ansible scaling: runs scaling
- Ansible scaling → k3s cluster: adds or drains nodes
- AWS traffic → WireGuard VPN: tunnels traffic
- WireGuard VPN → Octavia LB: DNATs to VIP
- Octavia LB → Traefik ingress: forwards traffic
- Traefik ingress → Card API: routes to pods
- Card API → Card approval: invokes (evidence: `services/mock-card/app/api/routes/card.py`)
- Card API → Card tokenization: invokes (evidence: `services/mock-card/app/api/routes/card.py`)
