A Spring Boot REST API for managing financial transactions with filtering, pagination, and classification capabilities.
Frontend Application: Transaction Frontend
A React-based frontend application that consumes this API to provide a user-friendly interface for managing transactions.
- Transaction Management: Fetch and manage financial transaction data
- Date Range Filtering: Filter transactions by start and end dates
- Pagination: Paginated response for efficient data handling
- Classification Updates: Update recipient classifications with validation
- CORS Support: Configured for frontend integration (localhost:5173)
- JSON Data Sources: Read and process JSON transaction data from files
- Input Validation: Comprehensive validation for API requests
- Java with Spring Boot
- Maven for dependency management
- Lombok for reducing boilerplate code
- Jackson for JSON processing (with JSR310 support for Java 8 date/time)
- Jakarta Validation for request validation
- Java 8 or higher
- Maven 3.6+
- Clone the repository:
git clone <repository-url>
cd transaction-api- Build the project:
mvn clean install- Run the application:
mvn spring-boot:runThe API will be available at http://localhost:8080
GET /api/transactions
Retrieves a paginated list of transactions with optional date filtering.
Query Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start |
LocalDate (yyyy-MM-dd) | No | - | Start date for filtering |
end |
LocalDate (yyyy-MM-dd) | No | - | End date for filtering |
page |
Integer | No | 0 | Page number (0-based) |
size |
Integer | No | 10 | Number of items per page |
Example Request:
GET /api/transactions?start=2023-01-01&end=2023-12-31&page=0&size=20Response:
{
"content": [
{
"date": "2023-06-15",
"recipientId": "RECIPIENT_001",
"description": "Coffee purchase",
"amount": 4.5,
"classification": "FOOD_AND_DINING"
}
],
"page": 0,
"size": 20,
"totalElements": 150,
"totalPages": 8
}POST /api/recipients/{recipientId}/classification
Updates the classification for a specific recipient.
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
recipientId |
String | Yes | Unique identifier for the recipient |
Request Body:
{
"classification": "FOOD_AND_DINING"
}Validation Rules:
- Classification must not be blank
- Must contain only uppercase letters and underscores
- Maximum 50 characters
Response: 204 No Content on success
The application is configured to accept cross-origin requests from the frontend development server:
@CrossOrigin(origins = "http://localhost:5173")This allows seamless integration with the frontend application during development.
The application reads transaction data from JSON files located in src/main/resources/:
transaction-service.json- Main transaction datarecipient-Ids.json- Recipient information
src/main/java/dev/transaction/api/
├── controller/ # REST endpoints and request handling
├── service/ # Business logic and data processing
├── repository/ # Data access and JSON file handling
├── model/ # Entity classes and response models
├── dto/ # Data Transfer Objects for requests
└── exception/ # Custom exceptions and global error handling
- Controller Layer: REST endpoints with validation and CORS configuration
- Service Layer: Business logic for transaction processing and classification updates
- Repository Layer: Data access abstraction for JSON file operations
- Model Layer: Entity classes with Lombok annotations for reduced boilerplate
- Exception Handling: Global exception handler for consistent error responses
jackson-datatype-jsr310- Java 8 LocalDate support in JSON serializationlombok- Reduces boilerplate code with annotationsjakarta.validation- Request validation framework
-
Start the backend API (this project):
mvn spring-boot:run
-
Clone and start the frontend:
git clone https://github.com/RickOliwer/transaction-frontend.git cd transaction-frontend npm install npm run dev
The frontend will be available at http://localhost:5173 and will communicate with this API at http://localhost:8080.
For detailed API documentation and testing, you can:
- Use the provided endpoint examples above
- Import the API into tools like Postman or Insomnia
- Check the frontend implementation for real-world usage examples
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.