Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ==============================================================================
# CODEOWNERS Configuration
# ==============================================================================
# This file automatically requests reviews from the code owners when files are
# modified. Patterns are evaluated in order; the last matching pattern takes
# precedence.
# ==============================================================================

# Default owner for the entire repository
* @aniebietafia

# CI/CD & GitHub Configurations
/.github/workflows/ @aniebietafia
/pom.xml @aniebietafia

# Core Application Framework & Security Configuration
/src/main/java/com/xtraction/api/core/ @aniebietafia
/src/main/resources/*.properties @aniebietafia
/src/main/resources/*.json @aniebietafia

# Identity, Authentication & User Management
/src/main/java/com/xtraction/api/identity/ @aniebietafia

# Extraction, OCR Parsing & Document Core
/src/main/java/com/xtraction/api/extraction/ @aniebietafia

# Billing, Credits & Payment Integrations (PayPal, Paystack)
/src/main/java/com/xtraction/api/billing/ @aniebietafia

# Third-party Integrations (Messaging, Storage, WebSockets)
/src/main/java/com/xtraction/api/integration/ @aniebietafia
36 changes: 36 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Description

Please include a summary of the changes and the related issue/feature request. List any dependencies that are required for this change.

Fixes # (issue)

## Type of Change

Please mark options that apply:

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Refactoring (code cleanup, formatting, or performance optimizations with no behavior changes)
- [ ] Documentation update
- [ ] Chore / Maintenance (dependencies update, CI config, etc.)

## Verification Details

### Automated Tests
Describe the tests that you ran to verify your changes (e.g. `mvn test`).
- [ ] Unit Tests
- [ ] Integration Tests

### Manual Verification
Describe any manual testing performed (e.g. API requests tested via Postman/Bruno, console output logs, database verification).

## Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] My changes generate no new compiler warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
18 changes: 12 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ jobs:
- name: Determine version bump from commits
id: version_info
run: |
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
LAST_TAG=$(git tag --sort=-v:refname | head -n 1 || echo "")

if [ -z "$LAST_TAG" ]; then
COMMITS=$(git log --pretty=format:"%s" --no-merges)
COMMITS=$(git log --pretty=format:"%s" --no-merges || echo "")
else
COMMITS=$(git log $LAST_TAG..HEAD --pretty=format:"%s" --no-merges)
COMMITS=$(git log "$LAST_TAG..HEAD" --pretty=format:"%s" --no-merges || echo "")
fi

echo "Commits to analyze:"
Expand Down Expand Up @@ -130,9 +130,15 @@ jobs:
run: |
set -e
git fetch --tags
LATEST_TAG=$(git describe --tags --abbrev=0 HEAD~1^) || LATEST_TAG=$(git rev-list --max-parents=0 HEAD)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
CHANGELOG=$(git log $LATEST_TAG..HEAD^ --pretty=format:"* %s")
PREV_TAG=$(git tag --sort=-v:refname | sed -n '2p' || echo "")
echo "PREV_TAG=$PREV_TAG"
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log HEAD~1 --pretty=format:"* %s" --no-merges || echo "First release")
else
CHANGELOG=$(git log "$PREV_TAG..HEAD~1" --pretty=format:"* %s" --no-merges || echo "No changes found")
fi
echo "Generated changelog:"
echo "$CHANGELOG"
echo "$CHANGELOG" > changelog.txt

- name: Create GitHub Release
Expand Down
88 changes: 0 additions & 88 deletions .github/workflows/security.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -21,7 +22,7 @@
* Global exception handler for PayPal payment operations.
*/
@Slf4j
@Order(1)
@Order(Ordered.HIGHEST_PRECEDENCE)
@RestControllerAdvice(basePackages = "com.xtraction.api.billing.payment.paypal")
public class PayPalGlobalExceptionHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ProblemDetail;
Expand All @@ -23,6 +25,7 @@
* Global exception handler for Paystack-related operations
*/
@Slf4j
@Order(Ordered.HIGHEST_PRECEDENCE)
@RestControllerAdvice(basePackages = "com.xtraction.api.billing.payment.paystack")
public class PaystackGlobalExceptionHandler {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package com.xtraction.api.billing.promocode.exception;

import lombok.Getter;
import com.xtraction.api.core.exceptions.custom.BusinessException;
import com.xtraction.api.core.exceptions.custom.ErrorCode;

/**
* Exception thrown when a promo is invalid or cannot be used.
*/
@Getter
public class InvalidPromoCodeException extends RuntimeException {

private final String errorCode;

public InvalidPromoCodeException(String message, String errorCode) {
super(message);
this.errorCode = errorCode;
}
public class InvalidPromoCodeException extends BusinessException {

public InvalidPromoCodeException(String message) {
super(message);
this.errorCode = "INVALID_PROMO_CODE";
super(ErrorCode.INVALID_PROMO_CODE, message);
}

public InvalidPromoCodeException(ErrorCode errorCode, String message) {
super(errorCode, message);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.xtraction.api.billing.promocode.exception;

import com.xtraction.api.core.exceptions.custom.BusinessException;
import com.xtraction.api.core.exceptions.custom.ErrorCode;

/**
* Exception thrown when a promo is not found.
*/
public class PromoCodeNotFoundException extends RuntimeException {
public class PromoCodeNotFoundException extends BusinessException {

public PromoCodeNotFoundException(String message) {
super(message);
super(ErrorCode.PROMO_CODE_NOT_FOUND, message);
}

public PromoCodeNotFoundException(String promoCode, boolean isCode) {
super(isCode ? "PromoCode with code '" + promoCode + "' not found"
super(ErrorCode.PROMO_CODE_NOT_FOUND, isCode ? "PromoCode with code '" + promoCode + "' not found"
: "PromoCode with ID '" + promoCode + "' not found");
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package com.xtraction.api.billing.subscription.controller;

import com.xtraction.api.core.web.response.ApiResponse;

import com.xtraction.api.core.web.response.ResponseBuilderService;
import com.xtraction.api.billing.subscription.datamodel.SubscriptionCurrency;
import com.xtraction.api.billing.subscription.dto.ConvertedPrice;
import com.xtraction.api.billing.subscription.service.CurrencyConversionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
Expand All @@ -29,21 +24,20 @@
public class CurrencyController {

private final CurrencyConversionService currencyConversionService;
private final ResponseBuilderService responseBuilderService;

@Operation(summary = "Convert an amount between currencies", description = "Converts an amount from one currency to another using cached exchange rates. "
+
"Amount should be in the smallest unit (e.g., cents for USD, kobo for NGN).")
@GetMapping("/convert")
public ResponseEntity<ApiResponse<ConvertedPrice>> convert(
public ConvertedPrice convert(
@RequestParam long amountInCents,
@RequestParam(defaultValue = "USD") String from,
@RequestParam String to) {

SubscriptionCurrency fromCurrency = SubscriptionCurrency.fromIdentifier(from);
SubscriptionCurrency toCurrency = SubscriptionCurrency.fromIdentifier(to);

// Convert cents to main unit (e.g., 500 cents → $5.00)
// Convert cents to main unit (e.g., 500 cents -> $5.00)
BigDecimal amountInMainUnit = BigDecimal.valueOf(amountInCents)
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);

Expand All @@ -57,15 +51,12 @@ public ResponseEntity<ApiResponse<ConvertedPrice>> convert(
}

// Convert from USD to target currency
ConvertedPrice result = currencyConversionService.convert(amountInUsd, toCurrency);

return ResponseEntity.ok(
responseBuilderService.buildUserResponse(result, HttpStatus.OK, "Currency converted"));
return currencyConversionService.convert(amountInUsd, toCurrency);
}

@Operation(summary = "Get exchange rates", description = "Returns exchange rates for all supported currencies relative to USD")
@GetMapping("/rates")
public ResponseEntity<ApiResponse<Map<String, Object>>> getRates() {
public Map<String, Object> getRates() {
Map<String, Object> ratesData = new LinkedHashMap<>();
ratesData.put("baseCurrency", "USD");

Expand All @@ -75,13 +66,12 @@ public ResponseEntity<ApiResponse<Map<String, Object>>> getRates() {
}
ratesData.put("rates", rates);

return ResponseEntity.ok(
responseBuilderService.buildUserResponse(ratesData, HttpStatus.OK, "Exchange rates retrieved"));
return ratesData;
}

@Operation(summary = "List supported currencies", description = "Returns all supported currencies with their codes, symbols, and names")
@GetMapping("/supported")
public ResponseEntity<ApiResponse<Map<String, Object>[]>> getSupportedCurrencies() {
public Map<String, Object>[] getSupportedCurrencies() {
@SuppressWarnings("unchecked")
Map<String, Object>[] currencies = new Map[SubscriptionCurrency.values().length];
int i = 0;
Expand All @@ -93,7 +83,6 @@ public ResponseEntity<ApiResponse<Map<String, Object>[]>> getSupportedCurrencies
currencies[i++] = entry;
}

return ResponseEntity.ok(
responseBuilderService.buildUserResponse(currencies, HttpStatus.OK, "Supported currencies retrieved"));
return currencies;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package com.xtraction.api.core.exceptions.custom;

import lombok.Getter;

@Getter
public class BadRequestException extends RuntimeException {
private final String errorCode;
public class BadRequestException extends BusinessException {

public BadRequestException(String message) {
super(message);
this.errorCode = null;
super(ErrorCode.BAD_REQUEST, message);
}

public BadRequestException(String message, String errorCode) {
super(message);
this.errorCode = errorCode;
public BadRequestException(ErrorCode errorCode, String message) {
super(errorCode, message);
}
}
Loading
Loading