Skip to content

Commit ceebf2a

Browse files
Restructure service modules and resolve quality checks (#41)
* Restructure service modules and resolve quality checks * Resolved Docker & Ansible CI problem * Moved schemas and connectRetries into Flyway’s default environment
1 parent da870b1 commit ceebf2a

344 files changed

Lines changed: 7801 additions & 7103 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.dockerignore‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
**/__pycache__
1212

1313
# Only the four packaged service JARs enter application build contexts.
14-
!payguard-identity-service/target/
15-
payguard-identity-service/target/*
16-
!payguard-identity-service/target/payguard-identity-service-1.0.0-SNAPSHOT.jar
17-
!payguard-wallet-service/target/
18-
payguard-wallet-service/target/*
19-
!payguard-wallet-service/target/payguard-wallet-service-1.0.0-SNAPSHOT.jar
20-
!payguard-loan-service/target/
21-
payguard-loan-service/target/*
22-
!payguard-loan-service/target/payguard-loan-service-1.0.0-SNAPSHOT.jar
23-
!payguard-collateral-service/target/
24-
payguard-collateral-service/target/*
25-
!payguard-collateral-service/target/payguard-collateral-service-1.0.0-SNAPSHOT.jar
14+
!payguard-identity/target/
15+
payguard-identity/target/*
16+
!payguard-identity/target/payguard-identity-1.0.0-SNAPSHOT.jar
17+
!payguard-wallet/target/
18+
payguard-wallet/target/*
19+
!payguard-wallet/target/payguard-wallet-1.0.0-SNAPSHOT.jar
20+
!payguard-loan/target/
21+
payguard-loan/target/*
22+
!payguard-loan/target/payguard-loan-1.0.0-SNAPSHOT.jar
23+
!payguard-collateral/target/
24+
payguard-collateral/target/*
25+
!payguard-collateral/target/payguard-collateral-1.0.0-SNAPSHOT.jar

‎.env.example‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ PAYGUARD_POSTGRES_COLLATERAL_VOLUME=payguard_postgres_collateral_data
1717
PAYGUARD_VAULT_DATA_VOLUME=payguard_vault_data
1818
PAYGUARD_VAULT_AUDIT_VOLUME=payguard_vault_audit
1919
PAYGUARD_KAFKA_DATA_VOLUME=payguard_kafka_data
20+
21+
# Optional localhost ports with infrastructure/compose.ide.yaml.
22+
WALLET_POSTGRES_PORT=15431
23+
LOAN_POSTGRES_PORT=15432
24+
COLLATERAL_POSTGRES_PORT=15433
25+
IDENTITY_POSTGRES_PORT=15434

‎.github/workflows/_database-security.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Verify source contracts and build applications
3939
run: |
4040
python3 -m unittest discover -s infrastructure/tests -v
41-
./mvnw -B -ntp -pl payguard-identity-service,payguard-wallet-service,payguard-loan-service,payguard-collateral-service -am test package
41+
./mvnw -B -ntp -pl payguard-identity,payguard-wallet,payguard-loan,payguard-collateral -am test package
4242
- name: Prepare isolated fixture and allocate only new explicit volumes
4343
run: |
4444
ansible-playbook -i localhost, -c local infrastructure/operations/prepare.yml -e fresh_target=true

‎.github/workflows/_publish.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ jobs:
3030
- name: Verify Spring Boot plugin resolution
3131
run: |
3232
./mvnw -version
33-
./mvnw help:effective-pom -pl payguard-wallet-service \
33+
./mvnw help:effective-pom -pl payguard-wallet \
3434
| grep -A8 -B2 spring-boot-maven-plugin
3535
3636
- name: Build Wallet Service Image
37-
run: docker build -f payguard-wallet-service/Dockerfile -t payguard/wallet-service:${{ github.sha }} .
37+
run: docker build -f payguard-wallet/Dockerfile -t payguard/wallet-service:${{ github.sha }} .
3838

3939
- name: Build Loan Service Image
40-
run: docker build -f payguard-loan-service/Dockerfile -t payguard/loan-service:${{ github.sha }} .
40+
run: docker build -f payguard-loan/Dockerfile -t payguard/loan-service:${{ github.sha }} .
4141

4242
- name: Build Collateral Service Image
43-
run: docker build -f payguard-collateral-service/Dockerfile -t payguard/collateral-service:${{ github.sha }} .
43+
run: docker build -f payguard-collateral/Dockerfile -t payguard/collateral-service:${{ github.sha }} .
4444

4545
- name: Build Identity Service Image
46-
run: docker build -f payguard-identity-service/Dockerfile -t payguard/identity-service:${{ github.sha }} .
46+
run: docker build -f payguard-identity/Dockerfile -t payguard/identity-service:${{ github.sha }} .

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ PAYGUARD_GOAL.md
1313
# Protected local PostgreSQL/Vault rehearsal artifacts
1414
.local/
1515
__pycache__/
16+
17+
CLAUDE.md
18+
payguard-identity/NEW IDEAS.MD
19+
payguard-identity/ARCHITECTURE.md
20+
payguard-identity/IDENTITY_CHECKLIST.MD
21+
NO_LLM_FOR_CODING.MD

‎README.md‎

Lines changed: 226 additions & 75 deletions
Large diffs are not rendered by default.

‎docs/decission/# ADR-0002: Use Kafka (not RabbitMQ) for cross-service events.md‎

Lines changed: 0 additions & 58 deletions
This file was deleted.

‎docs/infrastructure-validation.md‎

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,13 @@
1-
# Vault and native infrastructure validation
1+
# Validation after restoring stashed work
22

3-
This branch is based on `main` at `c904d71ef8a7541885cbbe887f25148e196ef768`.
4-
It contains the infrastructure replacement, adapted to the committed service module names.
5-
The owner's uncommitted module renames, Identity refactor, Wallet edits, and local tooling
6-
remain outside the branch. No live database, Vault state, or deployment was accessed.
3+
Current source and evidence are documented in [the recovery record](recovery/stashed-work.md).
74

8-
## Scope
5+
The recovered reactor packages and compiles its tests. 302 selected Java tests and 18 offline
6+
infrastructure contracts pass. PostgreSQL 18 migration/import SQL checks passed using PGlite;
7+
Docker-backed runtime, TLS, Vault renewal, recovery and business end-to-end acceptance remain
8+
pending. Recovered Wallet formatting fails the full formatting gate, and the unfinished Identity
9+
audit adapter remains an application-startup blocker.
910

10-
- Compose manages PostgreSQL 18, Vault, dependencies, networks, application Agents and
11-
independent Agent/Flyway migration jobs. Existing persistent volumes have explicit external names.
12-
- Vault Agent handles AppRole authentication, token/credential renewal and application restart
13-
on credential replacement. Java consumes Agent token files for scoped KV access.
14-
- Ansible replaces preparation, provisioning, initialization, migration orchestration, import,
15-
identity refresh, backup and recovery launchers. The root `scripts/` directory and custom
16-
Java migration/import/leased-datasource implementations are removed.
17-
- The four existing versioned PostgreSQL SQL files are byte-for-byte unchanged; their hashes
18-
are recorded in `infrastructure/migrations.sha256`. Wallet receives a separate V1 marker,
19-
not a financial persistence implementation.
20-
- Identity import and privilege checks retain `identity_challenge`, `identity_audit_log`, and
21-
`identity_challenge_scope`. No SQL from the owner's unfinished Identity refactor is imported.
22-
- Existing Identity KV scoping and pepper-rotation tests are retained. Their fixture helper now
23-
requires Agent-delivered token paths in `PAYGUARD_REHEARSAL_OPERATOR_TOKEN_FILE`,
24-
`PAYGUARD_REHEARSAL_IDENTITY_TOKEN_FILE`, and `PAYGUARD_REHEARSAL_WALLET_TOKEN_FILE`.
25-
Those live Vault tests were not executed here.
26-
27-
## Executed checks
28-
29-
| Check | Result | Limit |
30-
| --- | --- | --- |
31-
| Offline deployment/security contracts | PASS, 18 tests | Configuration and HCL/TOML parsing, not live leases |
32-
| Compose base/application/migration/operations configuration | PASS | Compose 2.40.3; no daemon |
33-
| Compose production overlay configuration | PASS | Dummy external broker hosts and CA paths |
34-
| Ansible playbook syntax | PASS, 21 entry points | `preflight.yml` is an imported task list, not a playbook |
35-
| Fresh preparation | PASS | OpenSSL and Ansible on a new isolated fixture |
36-
| Repeated fresh preparation | PASS, safely refused | Generated bytes unchanged; private keys/passwords/config 0600, directories 0700 |
37-
| Existing versioned PostgreSQL SQL | PASS, 4 files unchanged | No live Flyway history available |
38-
| Shared Agent token/TLS/error-sanitization Java tests | PASS, 5 tests | No live Vault; repository style goals skipped for this run |
39-
| Application packaging and test-source compilation | PASS, all four services | Runtime tests skipped; Spotless/Checkstyle bypassed in this packaging run |
40-
| Reactor Maven validation | PASS | Spotless and Checkstyle for parent/shared/four services; PMD/SpotBugs not run |
41-
| Changed Java formatting | PASS | Google Java Format 1.30.0 |
42-
| Original checkout WIP preservation | PASS | Original status, staging state and file hashes unchanged |
43-
44-
The Java test command used JDK 25 and the repository Maven wrapper:
45-
46-
```bash
47-
./mvnw -B -ntp -pl payguard-shared \
48-
-Dspotless.skip=true -Dcheckstyle.skip=true \
49-
-Dtest=AgentTokenClientTest,PostgreSqlTlsTest,SanitizedDependencyErrorTest test
50-
python3 -m unittest discover -s infrastructure/tests -v
51-
```
52-
53-
Dependency downloads used private, workspace-only proxy settings and the system Java trust
54-
store. TLS verification remained enabled; proxy settings and generated secrets are not committed.
55-
56-
## Required live acceptance
57-
58-
The reusable native infrastructure CI workflow runs on an isolated Docker host. It prepares
59-
separate volumes, provisions Vault/databases, migrates every database twice, verifies privileges,
60-
starts the applications and rehearses a Vault outage. The workflow is executable test scaffolding,
61-
not evidence that those jobs have passed.
62-
63-
Production acceptance remains incomplete. Run integration, permission-denial, TLS failure,
64-
Agent renewal/reauthentication, credential replacement, interrupted migration/recovery,
65-
backup/restore, import rollback and business end-to-end tests before deployment. Test held SQL
66-
transactions and Vault outages explicitly; credential expiration does not terminate every
67-
already executing database statement. Complete paired PostgreSQL/Raft restoration and check
68-
existing records, histories, ownership and secret versions on isolated recovery volumes.
69-
70-
Base Kafka is a local plaintext rehearsal broker. The production overlay requires authenticated
71-
TLS external Redis/Kafka and verified CA/hostname settings. This is a single-host deployment
72-
building block, not a tested highly available database or Vault deployment.
11+
Historical infrastructure-only evidence from merged PR #40 is retained separately in
12+
[infrastructure-before-recovery.md](recovery/infrastructure-before-recovery.md). It must not be
13+
interpreted as validation of the recovered business refactor.

‎docs/infrastructure.md‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ OTP key is missing, reconciliation fails rather than silently replacing that sta
125125
historical SQL and Flyway checksums unchanged. An incompatible history needs a separate reviewed
126126
forward migration; baseline/repair is deliberately not automatic.
127127

128-
The replacement import retains the committed `identity_challenge`, `identity_audit_log`, and
129-
`identity_challenge_scope` tables. No old application data is
128+
The replacement import retains the committed `identity_otp`, `identity_audit_log`, and
129+
`identity_otp_scope` tables. No old application data is
130130
converted or rewritten during adoption.
131131

132132
## Fresh isolated environment
@@ -166,7 +166,7 @@ Build the committed service modules with JDK 25, then migrate each database expl
166166
This branch retains the existing module names and application persistence implementations:
167167

168168
```bash
169-
./mvnw -B -ntp -pl payguard-identity-service,payguard-wallet-service,payguard-loan-service,payguard-collateral-service -am package
169+
./mvnw -B -ntp -pl payguard-identity,payguard-wallet,payguard-loan,payguard-collateral -am package
170170
for service in identity wallet loan collateral; do
171171
docker compose run --rm --no-deps operations infrastructure/operations/migrate.yml -e service="$service"
172172
done
@@ -225,13 +225,38 @@ single-host deployment building block, not an HA database/Vault design. Deployme
225225
still requires live integration, security, recovery and business end-to-end checks. See the
226226
current validation report for executed checks and remaining acceptance work.
227227

228+
## IDE database connections
229+
230+
To publish only the four database ports on localhost, run from the repository root:
231+
232+
```bash
233+
docker compose -f docker-compose.yaml -f infrastructure/compose.ide.yaml up -d --no-deps postgres-wallet postgres-loan postgres-collateral postgres-identity
234+
```
235+
236+
Use the PostgreSQL driver, host `127.0.0.1`, schema `payguard`, and these defaults:
237+
238+
| Service | Port | Database |
239+
| --- | --- | --- |
240+
| Wallet | 15431 | payguard_wallet |
241+
| Loan | 15432 | payguard_loan |
242+
| Collateral | 15433 | payguard_collateral |
243+
| Identity | 15434 | payguard_identity |
244+
245+
For local administrative inspection, the username is `postgres` and each database's password is in `.local/payguard/<service>/admin-password`. This account has superuser privileges; do not use it in application configuration. Application credentials remain managed by Vault Agent.
246+
247+
Enable SSL with mode `verify-full` and CA certificate `.local/payguard/ca.crt` (use an absolute path in the IDE). No client certificate or key is required. Server certificates must include `IP:127.0.0.1` in their subject alternative names; older installations with only container DNS names need their server certificates reissued with the same CA before using this host. Fresh preparation already includes localhost names.
248+
249+
Override the ports with the `*_POSTGRES_PORT` settings from `.env.example`. The main Compose file alone keeps database ports private. The override reuses the existing external database volumes and does not initialize a replacement deployment.
250+
251+
If a local `.local/payguard/ide-image.yaml` exists, it records the exact previously installed PostgreSQL image for this workstation. Add `-f .local/payguard/ide-image.yaml` after the IDE override and use `--pull never` to reuse that image when the project-pinned image cannot be downloaded. This local file is ignored by Git and does not change the normal deployment image.
252+
228253
## Identity import
229254

230255
`import-identity.yml` replaces both the Python converter and Java import runner. Supply protected
231256
`source_file`, `mapping_file`, and `approved_mapping_sha256` variables in a protected variable file.
232257
The mapping JSON requires `approved_by`, `approval_reference`, `customers`, and `challenges`.
233258
Already-correct prefixed IDs pass through; historical IDs require explicit mappings. The source
234-
contains `challenges` and `audit` arrays. Audit records retain their `challenge_id` references.
259+
contains `challenges` and `audit` arrays. Historical audit `challenge_id` fields map to `otp_id` in the recovered schema.
235260

236261
The native PostgreSQL transaction sets the stable owner, locks the destination, refuses populated
237262
challenge/audit/scope tables, binds JSON values as parameters, checks integer/timestamp inputs,

‎infrastructure/application.Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ FROM eclipse-temurin:25-jre-alpine@sha256:b7528962e65d43064d8a8b67ba175367896bc9
44
COPY --from=vault /bin/vault /usr/local/bin/vault
55
ARG SERVICE
66
WORKDIR /app
7-
COPY payguard-${SERVICE}-service/target/payguard-${SERVICE}-service-1.0.0-SNAPSHOT.jar /app/service.jar
7+
COPY payguard-${SERVICE}/target/payguard-${SERVICE}-1.0.0-SNAPSHOT.jar /app/service.jar
88
USER 1000:1000
99
ENTRYPOINT ["vault", "agent"]

0 commit comments

Comments
 (0)