Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.97 KB

File metadata and controls

53 lines (41 loc) · 1.97 KB

Setting Up the App

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 up

After the app is up and running you should be able to run tests with simple command:

docker-compose exec app python -u -m pytest -s

Scenario

Imagine 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:

  1. Listens to incoming events using a Kafka consumer, and extracts their value.
  2. Parses the JSON string into an object containing the fields id, merchantId, amount, currency, paymentMethod, and date.
  3. Saves the parsed data to the payments table in the database.

Tasks

Task 1: Code Review

Review the existing implementation.

Task 2: Implement storeId Handling

  • Extend the application to process the storeId field from incoming events.
  • Ensure the implementation is backward-compatible, avoiding any interruptions to services that currently use the payments table.
  • Test the solution thoroughly and include tests to validate both the existing and updated functionality.