This repository contains the solution for the Technical Test Inc. payment processing microservice challenge.
Before running the microservice, ensure you have the following prerequisites installed:
- Java 11
- Docker
- Navigate to the project directory:
- Start the required Docker containers for PostgreSQL and Kafka: docker-compose up -d
- Build the Spring Boot application: mvn clean install
- Run the Spring Boot application: mvn spring-boot:run
- The microservice should now be running on http://localhost:8080.
- You can access the basic HTML interface by opening http://localhost:9000 in a web browser.
- To check if a payment is valid with third-party providers:
- curl -i --header "Content-Type: application/json" --request POST --data "{'payment_id': 'fdf50f69-a23a-4924-9276-9468a815443a', 'account_id': 1, 'payment_type': 'online','credit_card': '12345','amount':12}" http://localhost:9000/payment
- To store error logs:
- curl -i --header "Content-Type: application/json" --request POST --data "{'payment_id': 'fdf50f69-a23a-4924-9276-9468a815443a', 'error_type': 'network', 'error_description': 'Here some description'}" http://localhost:9000/log
- To start the technical test and produce payments data: curl http://localhost:9000/start
- To view error logs: curl http://localhost:9000/logs
-
The microservice is designed to handle two types of payments: online and offline.
-
It communicates with third-party providers for online payments and stores all payments in a PostgreSQL database.
-
When a payment is successfully stored, the account information is updated with the last payment date.
-
Errors are logged via a REST call to the Log System.
-
The microservice relies on Docker containers for PostgreSQL and Kafka, so make sure they are running before starting the application.
If you have more time or want to improve something, consider the following:
- Implement a more robust data model and database schema if needed for scalability and future requirements.
- Implement application-level monitoring using tools like Prometheus and Grafana to track performance metrics, error rates, and resource utilization. Set up automated alerts and notifications to respond to critical issues in real-time.
- Plan for scalability by implementing load balancing strategies to distribute incoming requests across multiple instances of the microservice. Explore container orchestration solutions like Kubernetes to manage scaling and deployments.
- Consider using caching mechanisms to reduce the load on the database.