Skip to content
ousama-oujaberPublic

About

Personal portfolio project / educational integration platform

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FlowGuard β€” Enterprise Integration Reliability Platform

FlowGuard CI Java 21 LTS Spring Boot Architecture Conformance Score

FlowGuard is an enterprise integration reliability platform designed to guarantee durable message acceptance, duplicate prevention, asynchronous database-backed worker processing, bounded exponential retries, and audited manual operator recovery for high-value asynchronous integration pipelines.

Built as a modular monolith adhering strictly to Hexagonal Architecture (Ports and Adapters) and Domain-Driven Design (DDD).


πŸ›οΈ Architectural Overview

FlowGuard enforces an inward-facing dependency graph. The core domain is completely isolated from frameworks, persistence, and network protocols.

[Inbound Adapters (Driving)]             [Outbound Adapters (Driven)]
  - REST API (MessageController)           - PostgreSQL Message Repository
  - Ops API (OperationsController)         - PostgreSQL Idempotency Repository
  - Worker Schedulers (SKIP LOCKED)        - PostgreSQL Attempt & Audit Adapters
  - Lease Recovery Engine                  - Outbound HTTP Delivery Adapter
           \                                      /
            \                                    /
         [Application Core / Use Cases & Ports]
            - Input Ports (Submit, Search, Retry, Ops)
            - Output Ports (MessagePort, DeliveryPort, AuditPort)
                            |
                            v
                [Pure Domain Model (POJOs)]
            - IntegrationMessage Aggregate Root
            - Value Objects (MessageId, ClientId, DestinationKey)
            - MessageLifecyclePolicy & RetryPolicy

Core Invariants & Guarantees

  1. Pure Domain Isolation: com.flowguard.core.domain.. contains POJOs with zero dependencies on Spring, JPA, SQL, Jackson, or cloud SDKs.
  2. Atomic Idempotent Ingestion: Guarantees atomic insertion of message and idempotency record (client_id, key_digest) in a single database transaction.
  3. Worker Lease Fencing: Workers claim batches using SELECT ... FOR UPDATE SKIP LOCKED and assign a unique lease_token. Completions conditionally match lease_token to prevent stale or crashed workers from overwriting newer state.
  4. Short DB Transactions: Remote deliveries execute outside database transactions to prevent connection pool exhaustion.
  5. Reconciliation Safety: Downstream socket timeouts on non-idempotent targets route to RECONCILIATION_REQUIRED and strictly forbid automatic retries.

⚑ Quick Start

Prerequisites

  • Java 21 LTS
  • Docker & Docker Compose (for PostgreSQL)

1. Launch PostgreSQL Database

docker compose up -d

2. Run FlowGuard Locally

./mvnw spring-boot:run

FlowGuard will start on http://localhost:8080 and run Flyway database migrations automatically.


πŸ“‘ REST API Reference

Base URL: /api/v1
All error responses adhere to RFC 9457 Problem Details (application/problem+json).

1. Submit Business Message (Durable Acceptance)

curl -i -X POST http://localhost:8080/api/v1/messages \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: idemp-2026-10-001" \
  -H "X-Client-Id: client_acme_corp" \
  -H "X-Correlation-ID: corr-txn-9841" \
  -d '{
    "messageType": "PAYROLL_DISBURSEMENT_V1",
    "destinationKey": "LEDGER_MAIN",
    "sourceSystem": "HR_WORKDAY",
    "externalReference": "PAY-OCT-2026",
    "payload": {"employeeId": "EMP-4819", "amount": 3500.00, "currency": "USD"}
  }'

Response: 202 Accepted

{
  "messageId": "9a0a8112-2591-4965-9831-2792c306d8a2",
  "status": "QUEUED",
  "idempotentReplay": false,
  "createdAt": "2026-10-18T01:30:00Z"
}

2. Search Messages with Deterministic Pagination

curl "http://localhost:8080/api/v1/messages?status=DEAD_LETTERED&page=0&size=10" \
  -H "X-Client-Id: client_acme_corp"

3. Review Monotonic Attempt History

curl "http://localhost:8080/api/v1/messages/9a0a8112-2591-4965-9831-2792c306d8a2/attempts" \
  -H "X-Client-Id: client_acme_corp"

4. Audited Manual Retry Command (Operator Recovery)

curl -i -X POST "http://localhost:8080/api/v1/messages/9a0a8112-2591-4965-9831-2792c306d8a2/retries" \
  -H "Content-Type: application/json" \
  -H "X-Actor-Id: ops-engineer-42" \
  -d '{
    "reason": "Downstream ledger endpoint restored and verified ready for re-drive."
  }'

Response: 202 Accepted

5. Explicit Message Cancellation (Prior to Dispatch)

curl -i -X POST "http://localhost:8080/api/v1/messages/9a0a8112-2591-4965-9831-2792c306d8a2/cancel" \
  -H "Content-Type: application/json" \
  -H "X-Actor-Id: ops-engineer-42" \
  -H "X-Client-Id: client_acme_corp" \
  -d '{
    "reason": "Order cancelled by customer before dispatch."
  }'

Response: 202 Accepted

6. Query Operational Summary

curl "http://localhost:8080/api/v1/operations/summary" \
  -H "X-Scope: operations:read"

7. Bulk Message Ingestion (Batch Submission)

curl -i -X POST http://localhost:8080/api/v1/messages/batch \
  -H "Content-Type: application/json" \
  -H "X-Client-Id: client_acme_corp" \
  -d '{
    "items": [
      {
        "idempotencyKey": "batch-item-001",
        "messageType": "ORDER_SYNC",
        "destinationKey": "LEDGER_MAIN",
        "payload": {"orderId": "ORD-101", "amount": 150.00}
      },
      {
        "idempotencyKey": "batch-item-002",
        "messageType": "ORDER_SYNC",
        "destinationKey": "LEDGER_MAIN",
        "payload": {"orderId": "ORD-102", "amount": 250.00}
      }
    ]
  }'

Response: 202 Accepted (or 200 OK if all items are idempotent replays)

{
  "totalCount": 2,
  "acceptedCount": 2,
  "replayedCount": 0,
  "items": [
    {
      "index": 0,
      "idempotencyKey": "batch-item-001",
      "messageId": "9a0a8112-2591-4965-9831-2792c306d8a2",
      "status": "QUEUED",
      "idempotentReplay": false
    },
    {
      "index": 1,
      "idempotencyKey": "batch-item-002",
      "messageId": "1b0a8234-3191-4965-9831-2792c306d8b3",
      "status": "QUEUED",
      "idempotentReplay": false
    }
  ]
}

8. Search & Export Audit Events

curl "http://localhost:8080/api/v1/audit-events?action=MANUAL_RETRY&page=0&size=20" \
  -H "X-Scope: audit:read"

πŸ§ͺ Automated Testing & Verification

Execute the complete test suite (124 automated unit tests, integration tests, E2E Testcontainers suite, and ArchUnit architecture verification rules):

./mvnw clean test

End-to-End (E2E) Test Suite with Testcontainers

FlowGuard includes a comprehensive E2E test suite (FlowGuardEnterpriseE2ETest) running against a live PostgreSQL 16 Alpine container:

  • Phase 1 & 2: Message submission (202 Accepted), idempotent replay (200 OK), payload conflict detection (409 Conflict), and SSRF raw URL rejection (400 Bad Request).
  • Phase 3: Deterministic worker claim with SELECT ... FOR UPDATE SKIP LOCKED, monotonic attempt tracking, and transition to SUCCEEDED.
  • Phase 4: Simulated ambiguous timeouts triggering RECONCILIATION_REQUIRED quarantine (prohibiting automatic retries).
  • Phase 5: Audited manual retry re-queueing to QUEUED with immutable audit log generation.
  • Phase 8: Explicit message cancellation prior to dispatch (CANCELLED).
  • Phase 9: Bulk message ingestion (POST /api/v1/messages/batch) and paged audit event querying (GET /api/v1/audit-events).
  • Operations & Actuator: Health and metrics inspection (/actuator/health, /actuator/metrics).

To run only the E2E test suite:

./mvnw test -Dtest=FlowGuardEnterpriseE2ETest

ArchUnit Architecture Verification

ArchUnit rules in HexagonalArchitectureTest continuously assert:

  • Domain layer has zero framework imports (org.springframework, jakarta.persistence, com.fasterxml.jackson).
  • Domain model has no outward dependencies on application or adapter layers.
  • Application core communicates with external systems exclusively via ports.
  • Inbound adapters never cross-communicate directly with outbound adapters.

πŸ›‘οΈ Operational Runbook & Incident Response

For detailed runbooks on failure triage, handling RECONCILIATION_REQUIRED ambiguous states, worker lease recovery, and alert thresholds, see: πŸ‘‰ FlowGuard Operational Runbook


πŸ“„ License

FlowGuard is proprietary enterprise integration reliability software. All rights reserved.

About

Personal portfolio project / educational integration platform

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages