<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>xyz.tcheeric</groupId>
        <artifactId>imani-gateway-customer</artifactId>
        <version>0.17.0</version>
    </parent>

    <artifactId>gateway-customer-rest</artifactId>
    <packaging>jar</packaging>
    <name>Gateway Customer - REST + Spring Boot Application</name>
    <description>REST controllers, Spring Boot application, and configuration for the Customer Wallet Service (wallet, voucher, token DM, mint, sync, nostr)</description>

    <dependencies>
        <!-- Shared libraries -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>imani-security</artifactId>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>imani-gateway-api</artifactId>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>imani-nostrdb</artifactId>
        </dependency>

        <!-- Wallet library (Nostr messaging + DM chunking) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-nostr</artifactId>
        </dependency>

        <!-- FR-GAP-004 Slice A — wallet service layer deps.
             These bring in the types needed by the upcoming verbatim port of
             WalletPluginAdapter (H2WalletService, VoucherService, SendService,
             ReceiveService, MintingService, MeltService, MintApi,
             DataSourceFactory, ProofRepository, DatabaseMigrator). Slice A only
             adds the deps and a compile-only classpath smoke test; the real
             @Bean wiring begins in Slice B (mint-quote path). See
             research.md §R9 for the H2-backend decision. -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-app</artifactId>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-cashu</artifactId>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-base</artifactId>
        </dependency>

        <!-- Spec 048 trace-event producer SDK (version from imani-bom 0.1.28+).
             cashu-ledger-trace-core (TransactionEvent / ProofRef / LightningRef
             types) is pulled transitively via wallet-core-cashu, but we add it
             explicitly so the bean wiring + health indicator can import the
             OperationIdRegistry + TraceabilityPublisher directly. -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>cashu-ledger-trace-publisher</artifactId>
        </dependency>

        <!-- NIP-44 encryption for token DM transfers -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-nip-44</artifactId>
        </dependency>

        <!-- NIP-17 private direct messages (gift wrap protocol) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-nip-17</artifactId>
        </dependency>

        <!-- NIP-60 wallet events. Used to replicate the gateway's own float to relays,
             so losing the H2 file stops being unrecoverable: the mint's proof table is a
             spent-only ledger and can never repopulate a lost wallet
             (imani-gateway-customer#64). -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-nip-60</artifactId>
        </dependency>

        <!-- Identity API (ports for bunker integration) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>identity-api</artifactId>
        </dependency>

        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <!-- Spring Cache with Caffeine -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>caffeine</artifactId>
        </dependency>

        <!-- Database -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
        </dependency>

        <!-- Distributed locking for @Scheduled jobs in multi-replica deployments (FR-GAP-014) -->
        <dependency>
            <groupId>net.javacrumbs.shedlock</groupId>
            <artifactId>shedlock-spring</artifactId>
            <version>5.16.0</version>
        </dependency>
        <dependency>
            <groupId>net.javacrumbs.shedlock</groupId>
            <artifactId>shedlock-provider-jdbc-template</artifactId>
            <version>5.16.0</version>
        </dependency>

        <!-- Jackson -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- WireMock for HTTP mocking in parallel service tests -->
        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>3.9.1</version>
            <scope>test</scope>
        </dependency>

        <!-- Spring Cloud Contract (FR-GAP-024 producer side).
             Generates consumer-driven contract verifier tests from the Groovy
             contracts under src/test/resources/contracts/. The generated tests
             extend the ContractBaseTest class, which wires a standalone MockMvc
             over VoucherController with a mocked WalletPort. -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-contract-verifier</artifactId>
            <version>${spring-cloud-contract.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <!-- Spring Cloud Contract 4.3.x aligns with Spring Cloud 2025.0.x / Spring Boot 3.5.x.
             Keep in sync with imani-bom's spring-boot version when it's upgraded. -->
        <spring-cloud-contract.version>4.3.0</spring-cloud-contract.version>
    </properties>

    <build>
        <plugins>
            <!-- FR-GAP-024 — Spring Cloud Contract producer plugin.
                 Generates JUnit tests from contracts under src/test/resources/contracts/
                 and installs the stub JAR (classifier: stubs) into the local Maven
                 repository so consumers (atomic, portal) can resolve it via
                 @AutoConfigureStubRunner in their contract tests. -->
            <plugin>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-contract-maven-plugin</artifactId>
                <version>${spring-cloud-contract.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <baseClassForTests>
                        xyz.tcheeric.gateway.customer.rest.contract.ContractBaseTest
                    </baseClassForTests>
                    <testFramework>JUNIT5</testFramework>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <classifier>exec</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>${jib-maven-plugin.version}</version>
                <configuration>
                    <from>
                        <image>eclipse-temurin:21-jre</image>
                    </from>
                    <to>
                        <image>docker.398ja.xyz/gateway-customer</image>
                        <tags>
                            <tag>${project.version}</tag>
                            <tag>latest</tag>
                        </tags>
                    </to>
                    <container>
                        <ports>
                            <port>8082</port>
                        </ports>
                        <jvmFlags>
                            <jvmFlag>-Xms256m</jvmFlag>
                            <jvmFlag>-Xmx512m</jvmFlag>
                        </jvmFlags>
                    </container>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
