This project implements a serverless data processing pipeline that handles daily CSV file uploads and transforms them into structured JSON messages for downstream consumption.
An external client uploads four CSV files to an S3 bucket daily. The files follow a naming convention of {TYPE}_{DATE}.csv (e.g., clients_20200130.csv).
The system processes four types of CSV files:
- clients: List of all clients. A client can have multiple portfolios.
- portfolios: List of all portfolios managed for clients.
- accounts: List of all bank accounts. Each portfolio has exactly one bank account.
- transactions: List of all transactions on managed portfolios.
Once all four files are uploaded for a given day, the system automatically processes them and generates JSON messages that are sent to a message queue.
The system generates the following message types:
- Client messages: Exactly one message per client
- Aggregates
taxes_paidacross all accounts held by the client
- Aggregates
- Portfolio messages: Exactly one message per portfolio
- Contains portfolio-level financial information
- Error messages: Generated for any unexpected inputs or validation failures
record_id,first_name,last_name,client_reference,tax_free_allowance
1,Frida,Muller,9e40659b-8b9f-4fc4-814b-5a7b5a23b64,801
2,Fritz,Maier,f4a0cc2c-d0b4-4f14-b202-c8a5e45e90e7,0record_id,account_number,portfolio_reference,client_reference,agent_code
1,12345678,90755e32-7438-4354-ad37-ad900e297844,9e40659b-8b9f-4fc4-814b-5a7b5a23b64,EREZBT
2,123456789,439695b4-508d-4562-8576-670e70024627,f4a0cc2c-d0b4-4f14-b202-c8a5e45e90e7,SFOJFKrecord_id,account_number,cash_balance,currency,taxes_paid
1,12345678,15000.00,EUR,0.00
2,123456789,-56.00,EUR,789.56record_id,account_number,transaction_reference,amount,keyword
1,12345678,14e56786,5000,DEPOSIT
2,123456789,dfeb5fe13cd4,-786.56,TAX{
"type": "client_message",
"client_reference": "9e40659b-8b9f-4fc4-814b-5a7b5a23b64",
"tax_free_allowance": 801,
"taxes_paid": 0
}{
"type": "portfolio_message",
"portfolio_reference": "90755e32-7438-4354-ad37-ad900e297844",
"cash_balance": 15000,
"number_of_transactions": 15,
"sum_of_deposits": 5000
}{
"type": "error_message",
"client_reference": null,
"portfolio_reference": "90755e32-7438-4354-ad37-ad900e297844",
"message": "Something went wrong!"
}