To set up the application, ensure you have Docker installed and working.
Before running Docker container copy docker-compose.override.dist.yml to docker-compose.override.yml and replace default values
so you are sure everything will work properly.
Then, start the application by running the following command in your terminal from the project root directory:
docker-compose upAfter the app is up and running you should be able to run tests with simple command:
docker-compose exec app python -u -m pytest -sImagine you are working on a service that transforms events from Kafka and stores them in a database (in the payments table).
This data will later be used by other services (not in the scope of this task).
Currently, the application processes events from a single Kafka topic: payments.updated.
Events in this topic represent either the creation or update of a payment.
The event value is a JSON string containing the following fields:
{
"id": string (UUIDv4),
"merchantId": string (UUIDv4),
"storeId": string (UUIDv4),
"amount": number (integer),
"currency": string,
"paymentMethod": string,
"date": string (ISO 8601 Date),
"time": string (ISO 8601 Time)
}The application currently:
- Listens to incoming events using a Kafka consumer, and extracts their value.
- Parses the JSON string into an object containing the fields
id,merchantId,amount,currency,paymentMethod, anddate. - Saves the parsed data to the
paymentstable in the database.
Review the existing implementation.
- Extend the application to process the
storeIdfield from incoming events. - Ensure the implementation is backward-compatible, avoiding any interruptions to services that currently use the
paymentstable. - Test the solution thoroughly and include tests to validate both the existing and updated functionality.