Skip to content

caiqso/transaction-statistics-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Transaction Statistics API


🇺🇸 Overview

This project is a high-performance REST API built to process financial transactions and compute real-time statistics based on the last 60 seconds.

Developed as part of Itaú backend engineering challenge, the system focuses on:

  • Performance (in-memory processing)
  • Clean architecture
  • Thread safety
  • Real-time computation

🇧🇷 Visão Geral

Este projeto é uma API REST de alta performance para processamento de transações financeiras e cálculo de estatísticas em tempo real com base nos últimos 60 segundos.

O foco foi:

  • Performance (dados em memória)
  • Código limpo
  • Concorrência segura
  • Cálculo em tempo real

🧰 Tech Stack

  • Java 17
  • Spring Boot
  • Maven
  • JUnit / MockMvc
  • ConcurrentLinkedDeque

📡 API Endpoints

➕ POST /transacao

Creates a new transaction

{
  "valor": 100.0,
  "dataHora": "2026-04-16T20:00:00-03:00"
}

Responses:

  • 201 Created → Success
  • 422 Unprocessable Entity → Invalid data
  • 400 Bad Request → Malformed JSON

🧹 DELETE /transacao

Clears all transactions

  • 200 OK

📊 GET /estatistica

Returns statistics from last 60 seconds

{
  "count": 5,
  "sum": 500.0,
  "avg": 100.0,
  "min": 50.0,
  "max": 200.0
}

⚙️ How to Run

./mvnw spring-boot:run

App runs at:

http://localhost:8080

🧪 Running Tests

./mvnw test

🧠 Architecture

  • Controller → handles HTTP layer
  • Service → business rules
  • DTO → validation and transport
  • Model → core data

⚡ Performance Strategy

  • In-memory storage (no DB)
  • O(n) filtering limited to 60 seconds
  • Thread-safe structure (ConcurrentLinkedDeque)
  • Zero I/O bottlenecks

🛡️ Error Handling

  • Global exception handler (@RestControllerAdvice)
  • Proper HTTP status codes
  • Clear error responses

👨‍💻 Author

Caíque


⭐ Final Thoughts

This project demonstrates the ability to design and implement a robust backend system under constraints, focusing on performance, clarity, and real-world engineering practices.


About

High-performance REST API for processing financial transactions and computing real-time statistics (Java + Spring Boot)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages