RESTful API designed to handle custom sales data from a high-value customer operating across multiple EU countries. This module processes CSV files containing sales representatives' contacts and sales records, storing them in a structured database and exposing the data via API.
- Handles CSV files with hundreds to tens of thousands of records
- Automated data processing upon file upload
- Categorized data: Seller, Contact, and Sale
- REST API for easy data retrieval
- Laravel 11
- PHP 8.4
- MySQL 8
- Redis
- Docker
- PHPUnit
Clone the git repository:
git clone git@github.com:freelancerwebro/sellers-service.git
cd sellers-service
Run the following command to build the service:
./deploy.sh
- POST
/load
: Upload a CSV file - GET
/sellers/{id}
: Provide complete seller data via id - GET
/sellers/{id}/contacts
: Provide a list of all contacts established by the seller. - GET
/sellers/{id}/sales
: Provide a list of all sales data accomplished by the seller. - GET
/sales/{year}
: Provide an object with two properties: stats (netAmount, grossAmount, taxAmount, profit, % profit) and sales (list of the all sales matching the period).
Background jobs efficiently process CSV data in chunks. Each chunk consists of 1,000 rows, allowing for asynchronous processing. For example, a CSV file with 6,500 rows will be split into 7 chunks, with each chunk handled by a separate background job to optimize performance and scalability.
php artisan queue:work --tries=3
composer test
composer cs
Sample csv files: 2_records.csv, 1000_records.csv, 5000_records.csv, 10000_records.csv, 50000_records.csv, 100000_records.csv
http://localhost:8083