diff --git a/.gitignore b/.gitignore index 3400fe9..38de85b 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ build/ ### Internal docs (not committed) ### internal/ +internal/* diff --git a/CHANGELOG.md b/CHANGELOG.md index bb24838..b47f6ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Repository contribution guidelines and branch protection rules (`CONTRIBUTING.md`). - GitHub status badges in `README.md`. +### Fixed +- Dockerfile JDK version mismatch: `eclipse-temurin:21-jre` → `eclipse-temurin:25-jre` to align with project's `java.version`. +- Broken GraalVM native profile in `pom.xml`: removed invalid dependency declaration with undefined property reference. +- Removed `System.out.println` debug statement from `UserController`. +- README updated to accurately reflect current project status. + --- ## [0.1.0] - 2026-07-27 diff --git a/Dockerfile b/Dockerfile index dde89d9..5245ccd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:21-jre AS runtime +FROM eclipse-temurin:25-jre AS runtime WORKDIR /app diff --git a/README.md b/README.md index 96a6fa4..168baaf 100644 --- a/README.md +++ b/README.md @@ -4,107 +4,95 @@ Build Java 25 Spring Boot - PostgreSQL License: MIT PRs Welcome

-Payflow is a highly resilient, transactional payments backend built using **Java 25** and **Spring Boot 4.x**. The project is designed with a pluggable, cloud-flexible architecture optimized for local developer iteration, Kubernetes deployment, and resource-constrained environments (like AWS Free Tier and Oracle Cloud Always Free). +Payflow is a transactional payments backend built using **Java 25** and **Spring Boot 4.x**, designed to evolve from a baseline REST API into an enterprise-grade payment system with ACID guarantees, event-driven architecture, and observability. --- -## Current Status & Evolution Roadmap +## Current Status -The project is currently evolving through a phased implementation roadmap from a Phase 0 baseline into an enterprise-grade payment system. +The project is evolving through a phased implementation roadmap. See the full plan in **[Phased Roadmap](docs/ROADMAP.md)**. -- **Phase 0 (Completed)**: Baseline REST API for User & Transaction CRUD with H2 in-memory storage. -- **Phase 1 (In Progress)**: Project hygiene, static analysis (Spotless, Checkstyle), and GitHub Actions CI. -- **Target Phases**: PostgreSQL & Flyway migrations, pessimistic row locking with deadlock avoidance, durable idempotency engine, transactional outbox pattern, JWT security, Resilience4j fault tolerance, Redis caching & Redisson distributed locking, Kafka event streaming, and Gen-AI transaction insights. - -See the complete step-by-step evolution in **[Phased Roadmap](docs/ROADMAP.md)**. +| Phase | Description | Status | +|-------|-------------|--------| +| **Phase 0** | Baseline REST API — User & Transaction CRUD with H2 in-memory storage | ✅ Complete | +| **Phase 1** | Project hygiene — Spotless, Checkstyle, GitHub Actions CI | ✅ Complete | +| **Phase 2** | Domain model hardening, DTO layer, validation, error handling | ⬜ Not Started | +| **Phase 3+** | Concurrency control, Flyway, security, observability, and more | ⬜ Not Started | --- -## Technical Architecture Highlights +## Implemented Features -- **ACID Transaction Hardening**: Enforces sequential consistency under race conditions using database-level pessimistic locking (`SELECT FOR UPDATE`). -- **Distributed Locking Coordination**: Integrates **Redis Redlock** (via Redisson) to synchronize distributed triggers across multi-instance deployments. -- **JPA N+1 Resolution**: Avoids Hibernate lazy loading bottlenecks through explicit **Fetch Joins** and `@EntityGraph` definitions. -- **REST API Versioning**: Implements strict URI version control (`/api/v1`) protecting endpoints from breaking changes. -- **Gen-AI Spending Assistant**: Integrates **Spring AI** (Ollama / Groq / Gemini) to automatically categorize transactions and generate spend analysis. -- **Durable Idempotency Engine**: Enforces exactly-once execution on mutation APIs via SHA-256 request payload hashing and persistent state checking. -- **Transactional Outbox Pattern**: Guarantees atomic consistency between state transitions and event streaming without dual-write vulnerabilities. -- **Pluggable Resilience Policies**: Configured via Resilience4j for client-side rate-limiting, exponential backoff retries with jitter, and call timeouts. -- **Telemetry & Observability**: Integrated with Spring Boot Actuator, Prometheus metrics, Logback MDC-based distributed trace correlation, and Grafana dashboards. +- **REST API**: Basic CRUD endpoints for User registration and Transaction creation. +- **Layered Architecture**: Controller → Service → Repository pattern with Spring Data JPA. +- **In-Memory Database**: H2 with auto-generated schema for zero-dependency local development. +- **Code Quality**: Spotless (Eclipse formatter) + Checkstyle enforced at Maven `validate` phase. +- **CI Pipeline**: GitHub Actions workflow running `mvn clean verify` on push/PR to `main`. +- **Actuator**: Health, info, and metrics endpoints exposed. --- -## Project Documentation Directory +## Target Architecture (Roadmap) -1. 📘 **[System Architecture Guide](docs/ARCHITECTURE.md)**: Deep technical details on topology, locking, idempotency, Spring profiles, and observability. -2. 🗓️ **[Phased Implementation Roadmap](docs/ROADMAP.md)**: Subdivided step-by-step phases (A and B) spanning database migrations, security, event streaming, and deployment. -3. 🌐 **[REST API Specification](docs/API_SPECIFICATION.md)**: Complete request and response payload schemas, versioned endpoints, validations, status codes, and RFC 7807 error formats. -4. 📋 **[Engineering Conventions](docs/CONVENTIONS.md)**: Coding standards, Git commit conventions, PR guidelines, and test naming rules. -5. 📜 **[Architecture Decision Records](docs/ADR.md)**: Log of architectural decisions, context, trade-offs, and consequences. +The following features are planned and will be implemented across future phases: ---- +- ACID transaction hardening with pessimistic locking and deadlock avoidance +- Balance ledger with double-entry bookkeeping for auditability +- DTO layer with input validation and RFC 7807 error responses +- PostgreSQL with Flyway-managed schema migrations +- Durable idempotency engine with SHA-256 payload hashing +- Transactional outbox pattern for reliable event streaming +- JWT authentication and authorization +- Resilience4j fault tolerance (rate limiting, retry, circuit breaker) +- Redis caching and distributed locking +- Kafka event streaming +- Structured logging with MDC trace correlation and Prometheus metrics +- Multi-stage Docker build with full-stack Docker Compose +- Kubernetes manifests with health probes and graceful shutdown +- Gen-AI spend insights with Spring AI -## Spring Profiles Strategy +See **[System Architecture Guide](docs/ARCHITECTURE.md)** for detailed design documentation. -The application leverages profile isolation to adapt resources to the target environment dynamically: +--- -- **`local` (Default)**: In-memory H2 database, automated hibernate schema updates, and zero-dependency local startup. -- **`test`**: Active during integration tests, utilizing **Testcontainers** to dynamically boot local Postgres/Kafka container instances for validation. -- **`prod`**: Production-grade settings. Database credentials and broker addresses are read from system environment variables. Schema evolution is strictly managed by **Flyway migrations**. -- **`prod-light` (Resource Constrained / Free Tier)**: Memory-optimized profile for single constrained virtual servers (1 GiB RAM). Uses lightweight in-memory fallbacks for Redis and Kafka to prevent OOM failures. +## Project Documentation + +| Doc | Description | +|-----|-------------| +| 📘 [System Architecture](docs/ARCHITECTURE.md) | Design patterns, concurrency control, observability | +| 🗓️ [Phased Roadmap](docs/ROADMAP.md) | Step-by-step evolution plan | +| 🌐 [API Specification](docs/API_SPECIFICATION.md) | Endpoints, payloads, validation rules, error formats | +| 📋 [Conventions](docs/CONVENTIONS.md) | Coding standards, Git workflow, testing rules | +| 📜 [Architecture Decisions](docs/ADR.md) | Decision records with context and trade-offs | --- ## Quick Start -### 1. Build and Run Local Tests -Requires JDK 25 and Maven: -```bash -mvn clean install -mvn test -``` +### Prerequisites +- JDK 25 (Temurin recommended) +- Maven 3.9+ -### 2. Local Standalone Startup (Zero Dependencies) -Boots the application on port `8080` using H2 in-memory storage: +### Build & Run ```bash -mvn spring-boot:run -``` -- **H2 Console**: Available at `http://localhost:8080/h2-console` - - *JDBC URL*: `jdbc:h2:mem:payupidb` - - *Credentials*: `user` / `user` +# Build and run tests +mvn clean verify -### 3. Local Full-Stack Ecosystem Startup (Docker Compose) -To run a local staging environment containing Postgres, Redis, Kafka KRaft, Prometheus, and Grafana: -```bash -docker-compose up --build +# Start locally (H2 in-memory, port 8080) +mvn spring-boot:run ``` ---- +- **H2 Console**: `http://localhost:8080/h2-console` + - JDBC URL: `jdbc:h2:mem:payupidb` + - Credentials: `user` / `user` -## Production Deployment Readiness - -### Kubernetes Deployment -Static Kubernetes manifests are defined under the `k8s/` directory. Deploy using: +### Docker ```bash -kubectl apply -f k8s/ -``` -- **Liveness Probe**: Routed to `/actuator/health/liveness` -- **Readiness Probe**: Routed to `/actuator/health/readiness` -- **Graceful Shutdown**: Handled via `server.shutdown=graceful` coordinating with container orchestration to process in-flight transactions before pod termination. - -### GraalVM Native Compilation -To compile the application to a lightweight, platform-native binary that starts in milliseconds and consumes ~30-50MB of RAM: -```bash -# Compile native binary locally -mvn -Pnative native:compile - -# Or build an optimized native OCI image via Buildpacks -mvn -Pnative spring-boot:build-image +docker-compose up --build ``` --- diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 26dcb22..635746a 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -1,292 +1,150 @@ # Payflow API — Roadmap -This roadmap outlines a structured, phased progression to evolve the Payflow API from a Phase 0 baseline into a highly resilient, enterprise-grade transactional backend. - -Each major phase is subdivided into iterative sub-phases scoped to a **single pull request**. Sub-phases are designed to be independently mergeable, buildable, and testable. Every sub-phase PR includes relevant documentation updates, diagrams, and testing to maintain a green build at all times. - -### Design Principles -- **Free-tier first**: All infrastructure defaults to free, open-source options. Paid services are activated via profile-driven configuration changes only. -- **Documentation parity**: Every documented feature has corresponding implemented and tested code. No aspirational claims. -- **PR-sized increments**: Each sub-phase is a single, reviewable pull request. +A phased evolution plan from baseline REST API to enterprise-grade transactional backend. Each sub-phase maps to a single pull request. ### Status Legend -- ✅ Complete -- 🔄 In Progress -- ⬜ Not Started +- ✅ Complete   🔄 In Progress   ⬜ Not Started --- -## Phase 0 — Baseline Implementation ✅ - -*Goal: Establish a running transactional baseline.* +## Phase 0 — Baseline ✅ -### Deliverables -- Basic user and transaction API endpoints. -- In-memory H2 persistence for zero-dependency development builds. -- Layered service/repository architecture. -- Baseline Spring profiles setup (`local`). +Basic User and Transaction REST endpoints with H2 in-memory storage and layered architecture. --- ## Phase 1 — Project Hygiene & Dev Tooling ✅ -*Goal: Establish professional project scaffolding, code quality enforcement, and continuous integration before any feature work begins.* - -### Phase 1A — Project Scaffolding & Repository Standards ✅ - -#### Work Items -- Add MIT license file and initialize a changelog following Keep a Changelog format. -- Add `.editorconfig` enforcing consistent formatting rules across IDEs. -- Create Architecture Decision Records (ADR) log to document key technical decisions. -- Create engineering conventions document (coding standards, commit message format, PR guidelines). -- Add GitHub badges to README (CI status, Java version, Spring Boot version, license, code coverage). -- Harden `.gitignore` for comprehensive IDE/OS artifact exclusion. +### 1A — Project Scaffolding ✅ +MIT license, changelog, `.editorconfig`, ADR log, engineering conventions, GitHub badges. -### Phase 1B — Code Formatting & Static Analysis ✅ +### 1B — Code Formatting & Static Analysis ✅ +Spotless (Eclipse formatter) and Checkstyle bound to Maven `validate` phase. -#### Work Items -- Integrate Spotless plugin (Eclipse Java Format) for automated code formatting. -- Integrate Checkstyle plugin with a baseline rule configuration (`checkstyle.xml`). -- Format all existing source files and bind checks to the Maven validate phase. +### 1C — CI Pipeline ✅ +GitHub Actions workflow with JDK 25, dependency caching, `mvn clean verify`. -### Phase 1C — GitHub Actions CI Pipeline ✅ - -#### Work Items -- Create a CI workflow triggered on push and pull request events. -- Configure JDK setup, dependency caching, and full Maven verify execution. -- Document branch protection recommendations in `CONTRIBUTING.md`. +### 1D — Fixes ✅ +Dockerfile JDK alignment, GraalVM profile fix, README cleanup. --- -## Phase 2 — Domain Model & API Contract Hardening ⬜ - -*Goal: Transform bare JPA entities into a properly modeled domain with validated DTOs, clean error handling, and versioned API routes.* - -### Phase 2A — Entity Model Hardening ⬜ - -#### Work Items -- Replace `Double` with `BigDecimal` for all monetary fields (financial precision). -- Add audit timestamps, transaction status/type enums, and reference IDs. -- Adopt Lombok to eliminate boilerplate. Add JPA `@Version` for optimistic locking support. -- Refactor all field injection to constructor injection. +## Phase 2 — Domain Model & API Hardening ⬜ -### Phase 2B — DTO Layer, Input Validation & API Documentation ⬜ +### 2A — Entity Model & Rich Domain ⬜ +`BigDecimal` financials, `@Column` constraints, JPA FK relationships, audit timestamps, status/type enums, rich domain methods (`debit`/`credit`), constructor injection. -#### Work Items -- Create request DTOs with Jakarta validation annotations and response DTOs using Java records. -- Update controllers to accept validated DTOs and return response objects (never raw entities). -- Establish `/api/v1/` versioned route prefix on all endpoints. -- Return correct HTTP status codes (`201 Created`, `404 Not Found`, etc.). -- Integrate `springdoc-openapi` for auto-generated interactive Swagger UI and OpenAPI 3.0 specification. +### 2B — DTO Layer & Validation ⬜ +Request/response DTOs, Jakarta validation, `/api/v1/` versioning, pagination with max limits. -### Phase 2C — Error Handling & Exception Framework ⬜ +### 2C — Mappers & API Docs ⬜ +MapStruct compile-time mappers, OpenAPI/Swagger UI via `springdoc-openapi`. -#### Work Items -- Create domain-specific exception hierarchy (e.g., not found, insufficient balance, duplicate UPI, self-transfer). -- Implement a global exception handler using Spring's native RFC 7807 `ProblemDetail` support. -- Replace all `System.out.println` usage with SLF4J structured logging. +### 2D — Error Handling ⬜ +Custom exception hierarchy, RFC 7807 `ProblemDetail` responses, `X-Request-Id` correlation. --- -## Phase 3 — ACID Transaction Logic & Concurrency Control ⬜ +## Phase 3 — ACID Transactions & Concurrency ⬜ -*Goal: Implement real money transfer mechanics with ledger integrity guarantees under concurrent load.* +### 3A — Transfer & Refund Logic ⬜ +End-to-end transfer orchestration within `@Transactional` boundaries, append-only refund semantics. -### Phase 3A — Money Transfer & Refund Implementation ⬜ +### 3B — Pessimistic Locking ⬜ +`SELECT ... FOR UPDATE` with deterministic lock ordering, `@EntityGraph` for N+1 resolution. -#### Work Items -- Implement end-to-end transfer orchestration: validate participants, check balance, debit/credit, persist transaction record — all within a single `@Transactional` boundary. -- Implement transaction refund/reversal endpoint following append-only ledger semantics. -- Add transaction status lookup and paginated user transaction history endpoints. - -### Phase 3B — Pessimistic Locking & Deadlock Avoidance ⬜ - -#### Work Items -- Add pessimistic write lock (`SELECT ... FOR UPDATE`) on balance lookups during transfers. -- Implement deterministic lock ordering (alphabetical UPI ID sort) to prevent deadlock cycles. -- Enforce append-only ledger semantics on the transactions table. -- Resolve JPA N+1 query patterns using `@EntityGraph` and explicit fetch joins. +### 3C — Balance Ledger ⬜ +Double-entry bookkeeping (DEBIT/CREDIT entries), `balanceBefore`/`balanceAfter` audit trail. --- -## Phase 4 — Database Migration & Profile Infrastructure ⬜ - -*Goal: Replace volatile H2 with PostgreSQL, establish Flyway-managed schema evolution, and configure environment-specific profiles.* - -### Phase 4A — Flyway Migrations & PostgreSQL Integration ⬜ - -#### Work Items -- Add PostgreSQL driver and Flyway dependencies. -- Create versioned SQL migration scripts for users, transactions, and performance indexes. -- Restructure configuration from `.properties` to YAML format. +## Phase 4 — Database & Profiles ⬜ -### Phase 4B — Spring Profiles & Testcontainers Setup ⬜ +### 4A — Flyway & PostgreSQL ⬜ +Versioned SQL migrations, PostgreSQL driver, YAML configuration, performance indexes. -#### Work Items -- Create profile-specific configuration files (`local`, `test`, `prod`). -- Add Testcontainers dependencies and create a shared integration test base class. -- Enforce Flyway-only schema control in production (`ddl-auto=validate`). +### 4B — Spring Profiles & Testcontainers ⬜ +Profile-specific configs (`local`/`test`/`prod`), Testcontainers PostgreSQL for integration tests. --- ## Phase 5 — Testing ⬜ -*Goal: Establish comprehensive test coverage with unit, integration, and concurrency verification.* +### 5A — Unit Tests ⬜ +Mockito service tests, `@WebMvcTest` controller tests, `@DataJpaTest` repository tests. -### Phase 5A — Unit Tests ⬜ - -#### Work Items -- Service layer tests using Mockito: transfer happy path, edge cases, refund scenarios. -- Controller layer tests using `@WebMvcTest` + MockMVC: input validation, status codes, error payloads. -- Repository layer tests using `@DataJpaTest`: custom query verification. - -### Phase 5B — Integration & Concurrency Tests ⬜ - -#### Work Items -- Full transfer lifecycle tests against Testcontainers PostgreSQL. -- Concurrent race condition test: 10 simultaneous threads contending on the same balance, verifying exactly 1 succeeds and no double-spend occurs. -- Update CI pipeline to run integration tests. +### 5B — Integration & Concurrency Tests ⬜ +Full lifecycle tests on Testcontainers PG, 10-thread race condition tests, balance reconciliation assertions. --- -## Phase 6 — Idempotency & Transactional Outbox ⬜ - -*Goal: Guarantee exactly-once mutation execution and reliable event streaming without dual-write vulnerabilities.* +## Phase 6 — Idempotency & Outbox ⬜ -### Phase 6A — Durable Idempotency Engine ⬜ +### 6A — Idempotency Engine ⬜ +`Idempotency-Key` header filter, SHA-256 payload hashing, cached response replay, TTL cleanup. -#### Work Items -- Create idempotency registry schema (Flyway migration), entity, and repository. -- Implement a request filter that intercepts `Idempotency-Key` headers, computes payload hashes (SHA-256), and replays cached responses for duplicate requests. -- Handle concurrent duplicate submissions with `409 Conflict`. - -### Phase 6B — Transactional Outbox Pattern ⬜ - -#### Work Items -- Create outbox events schema (Flyway migration), entity, and repository. -- Write outbox events atomically within the same transaction as balance updates. -- Implement a scheduled dispatcher that polls and publishes pending events. -- Define a pluggable event publisher interface with an in-memory default implementation. +### 6B — Transactional Outbox ⬜ +Outbox table with `SKIP LOCKED` polling, pluggable event publisher interface, in-memory default. --- -## Phase 7 — Security & Access Control ⬜ - -*Goal: Restrict mutation endpoints to authenticated actors using stateless JWT validation.* - -### Phase 7A — Spring Security & JWT Authentication ⬜ - -#### Work Items -- Integrate Spring Security with stateless JWT-based authentication. -- Create a JWT token provider and authentication filter. -- Configure endpoint security: permit public registration, authenticate transaction mutations. -- Configure CORS policy for frontend integration readiness. -- Add a simplified auth/login endpoint for token issuance. +## Phase 7 — Security ⬜ -### Phase 7B — Authorization & Sender Verification ⬜ +### 7A — JWT Authentication ⬜ +Spring Security, stateless JWT, auth/login endpoint, CORS configuration. -#### Work Items -- Verify that the authenticated user's identity matches the sender in transfer requests (`403 Forbidden` on mismatch). -- Restrict transaction history access to the owning user. -- Add comprehensive security-focused unit tests. +### 7B — Authorization ⬜ +Sender verification, transaction/ledger history access control. --- -## Phase 8 — Observability, Resilience, Caching & Event Streaming ⬜ - -*Goal: Add structured telemetry, fault tolerance policies, distributed caching, and production event streaming.* - -### Phase 8A — Structured Logging, Tracing & Prometheus Metrics ⬜ - -#### Work Items -- Configure JSON-structured logging with MDC trace correlation (traceId, spanId, requestId). -- Add distributed tracing support with Micrometer Tracing for cross-service trace propagation. -- Expose custom Micrometer counters for payment volumes, failure rates, and amount distributions. -- Harden actuator endpoint exposure. - -### Phase 8B — Resilience4j Policies ⬜ +## Phase 8 — Observability, Resilience & Caching ⬜ -#### Work Items -- Add rate limiting (token bucket) on transaction endpoints with `429 Too Many Requests`. -- Add retry with exponential backoff and jitter on outbox event dispatch. -- Add timeout policies on lock acquisition and external calls. -- Export resilience metrics to Prometheus. +### 8A — Logging & Metrics ⬜ +JSON-structured logging, MDC trace correlation, Prometheus metrics, HikariCP monitoring. -### Phase 8C — Distributed Caching & Locking (Redis) ⬜ +### 8B — Resilience4j ⬜ +Per-user rate limiting, retry with exponential backoff, timeout policies. -#### Work Items -- Integrate Redis with Spring Cache abstraction for cache-aside pattern on user lookups. -- Automatic cache eviction on writes with `@CacheEvict`. -- Enhance idempotency filter with Redis-backed distributed locking (Redisson) for multi-instance gateway coordination. -- Profile-conditional bean wiring: Redis for `prod`, Caffeine for `local`/`test`. -- Add cache hit/miss metrics to Prometheus. +### 8C — Caching (Redis) ⬜ +Cache-aside pattern, `@CacheEvict` on writes, Caffeine fallback for local/test. -### Phase 8D — Kafka Integration & Event Streaming ⬜ - -#### Work Items -- Implement a Kafka-backed event publisher (activated in `prod` profile). -- Configure Kafka producer with durability guarantees (`acks=all`). -- Add Testcontainers Kafka integration tests for end-to-end event verification. +### 8D — Distributed Locking ⬜ +Redisson Redlock for multi-instance idempotency coordination, NoOp fallback. --- -## Phase 9 — Infrastructure, Docker & Deployment ⬜ - -*Goal: Production-grade containerization, local full-stack orchestration, Kubernetes readiness, and cloud deployment.* - -### Phase 9A — Multi-Stage Dockerfile & Docker Compose ⬜ - -#### Work Items -- Rewrite Dockerfile with multi-stage build, correct JDK version, non-root user, and health check. -- Expand Docker Compose to orchestrate: application, PostgreSQL, Redis, Kafka, Prometheus, and Grafana. -- Add monitoring configuration (Prometheus scrape config, Grafana provisioned dashboards). +## Phase 9 — Event Streaming ⬜ -### Phase 9B — Kubernetes Manifests ⬜ - -#### Work Items -- Create Deployment, Service, ConfigMap, and Secret manifests. -- Configure liveness/readiness probes and graceful shutdown alignment. -- Validate deployment on a local Minikube/Kind cluster. - -### Phase 9C — CI/CD Enhancement & Code Coverage ⬜ - -#### Work Items -- Add SpotBugs static analysis, artifact archiving, and dependency caching to the CI workflow. -- Integrate JaCoCo for code coverage reporting with minimum threshold enforcement. -- Add CI status and code coverage badges to README. +### 9A — Kafka Integration ⬜ +Kafka event publisher (`acks=all`, idempotent producer), Testcontainers Kafka tests. --- -## Phase 10 — Gen-AI Spend Insights ⬜ +## Phase 10 — Infrastructure & Deployment ⬜ -*Goal: Integrate LLM-powered transaction categorization and budgeting insights.* +### 10A — Docker ⬜ +Multi-stage Dockerfile, full-stack Docker Compose (PG, Redis, Kafka, Prometheus, Grafana). -### Phase 10A — Spring AI Integration & Categorization Endpoint ⬜ +### 10B — Kubernetes ⬜ +Deployment, Service, ConfigMap, Secret, HPA manifests with health probes. -#### Work Items -- Integrate Spring AI with a provider-agnostic abstraction (Ollama for local, Groq/Gemini for deployed). -- Implement a spend insights service with structured prompt engineering and JSON-schema output parsing. -- Add authenticated insights endpoint with circuit breaker fallback. -- Feature-flag AI capabilities for environments without API keys. +### 10C — CI/CD Hardening ⬜ +SpotBugs, JaCoCo coverage thresholds (80% line, 70% branch), artifact archiving. --- -## Phase 11 — Production Hardening & Documentation ⬜ +## Phase 11 — Gen-AI Insights ⬜ -*Goal: Final polish for production readiness, cloud deployment, and professional presentation.* +### 11A — Spend Categorization ⬜ +Spring AI with provider-agnostic config (Gemini/Groq/Ollama), circuit breaker fallback, feature flag. -### Phase 11A — prod-light Profile, Virtual Threads & GraalVM ⬜ +--- -#### Work Items -- Create a memory-optimized profile for resource-constrained deployments (1 GiB RAM). -- Swap Redis/Kafka with lightweight in-memory alternatives using conditional bean wiring. -- Enable virtual threads (`spring.threads.virtual.enabled=true`) and tune HikariCP pool sizing. -- Validate and document GraalVM native compilation (`mvn -Pnative native:compile`). +## Phase 12 — Production Hardening ⬜ -### Phase 11B — Cloud Deployment & Documentation Finalization ⬜ +### 12A — Performance Tuning ⬜ +`prod-light` profile (1 GiB RAM), virtual threads, HikariCP tuning, connection leak detection. -#### Work Items -- Document cloud deployment options with step-by-step guides for AWS Free Tier and Oracle Cloud Always Free. -- Ensure all documentation accurately reflects implemented, tested features. -- Finalize architecture docs with Mermaid diagrams, API specification, ADR log, changelog, and README. -- Validate that a new developer can clone and run the project within 5 minutes. +### 12B — Documentation Finalization ⬜ +Final review of all docs, diagrams, and README. Clone-and-run validation. diff --git a/pom.xml b/pom.xml index eba9f5d..0b983ad 100644 --- a/pom.xml +++ b/pom.xml @@ -139,14 +139,6 @@ exec true - - - org.graalvm.buildtools - native-maven-plugin - ${graalvm-native-maven-plugin.version} - provided - - diff --git a/src/main/java/com/payflow/controller/UserController.java b/src/main/java/com/payflow/controller/UserController.java index 5e391ac..5c14ec7 100644 --- a/src/main/java/com/payflow/controller/UserController.java +++ b/src/main/java/com/payflow/controller/UserController.java @@ -23,7 +23,6 @@ public class UserController { @PostMapping public User registerUser(@RequestBody User user) { - System.out.println("User object with @RequestBody: " + user.getName()); return userService.registerUser(user); }