Back to portfolio
IntegrationClient work

Farmadati Laravel API

Integration backend that pulls Farmadati nomenclatures via SOAP, downloads paginated datasets, streams XML parsing, normalizes the schema, and persists products, manufacturers, descriptions, and image metadata for API consumption.

Farmadati Laravel API

Core stack

PHP 8.2
Laravel 11
Eloquent ORM
Laravel Query Builder
SOAP / SoapClientXMLReaderSimpleXMLZipArchiveSQLiteVite 5PHPUnit 11

The challenge

The challenge was turning external pharmaceutical datasets, delivered via SOAP as ZIP archives containing XML with their own schemas, into a predictable, queryable local model. The import had to be able to process large data pages without loading the entire XML into memory, preserve the unique codes and the relationships between products and auxiliary nomenclatures, and be re-runnable without duplicating records.

The solution

The solution centralizes SOAP access and schema translation in an ImportService, and each nomenclature has an import controller that downloads the pages, extracts the archive, parses the XML with XMLReader, and performs batched upserts into a dedicated table. Migrations define the unique keys used for reconciliation, Eloquent links the product to its long description, manufacturer, and image, and the API offers lookup by code and paginated listing with eager-loaded relationships. The full import orchestrates the modules in an explicit order.

Notable complexity

Farmadati Laravel API is a backend service built to turn Farmadati datasets into a local structure that is easier for web applications or internal services to consume. The integration starts from the Farmadati SOAP service: the application can query the enabled datasets, request a dataset's schema, and download its corresponding data pages. Provider credentials are read from the environment and are not hardcoded in the repository.

The main import flow is an ETL pipeline. For each dataset, the application downloads the binary response as a ZIP archive, extracts it into storage, reads the XML with XMLReader, and maps the provider's technical keys to English names. The names are then normalized for SQL columns, and records are written in batches via upsert. Product import uses batches of 2,500 records, while long descriptions use smaller batches of 100, showing an explicit adjustment for heavier payloads.

The local model separates products from manufacturers, short descriptions, long descriptions, and image metadata. Product links the long description, manufacturer, and image through keys coming from the nomenclature, and the main codes are protected by unique constraints in the migrations. The API exposes an exact lookup by product_code and a paginated listing that eager-loads the relationships used in the response. Short-description import exists and persists data separately, but the relationship is not wired into the main Product response in the analyzed snapshot.

The full import sequentially orchestrates products, manufacturers, images, and both description types, and reconnects the database between stages. XML processing is streamed, and writes are bulk upserts inside transactions, avoiding both loading the entire XML file into memory and inserting row by row. On the other hand, imports run directly inside HTTP requests with an extended timeout rather than through queue workers, there is no formal retry/backoff for SOAP calls, and there is no locking against two concurrent imports.

The version saved in the repository should be treated as a functional/prototype integration backend, not as a hardened public surface. The import routes, schema, and even the execution of an Artisan command are exposed in web routes without authentication or dedicated rate limiting. In addition, the SOAP client uses an HTTP endpoint, and error branches can display the SOAP request/response when trace is enabled. For production, the natural next steps are isolating administrative operations into CLI/queue, authentication and authorization, an operation allowlist, pagination parameter validation, HTTPS for the provider where available, and removing sensitive data from error output.

The repository contains no CI/CD, Docker, or reproducible deployment configuration. Laravel provides the standard /up endpoint, and Vite and the welcome page exist as scaffolding, but there is no custom Farmadati frontend in the analyzed code. The available history is also a single backup commit, so the contribution can be described through the custom logic present in the service, controllers, models, migrations, and routes, rather than through a full development timeline.

Key results

  • SOAP integration with the Farmadati service for listing enabled datasets, reading schemas, and downloading data
  • Separate import for products, manufacturers, images, short descriptions, and long descriptions
  • Streamed XML processing via XMLReader
  • Pagination of Farmadati datasets until the provider's pages are exhausted
  • Normalization of schema keys from Italian descriptions into English-named SQL columns
  • Transactional batched upsert allowing imports to be re-run without duplicating unique keys
  • SQL model with distinct tables and unique codes for products, manufacturers, descriptions, and images
  • API lookup by product_code with eager-loaded relationships for long description, manufacturer, and image
  • Paginated product listing via the API
  • Import-all orchestration for sequentially running the import modules
  • Standard Laravel health-check endpoint at /up

Related projects

Want something similar?

Start with the estimate wizard — answer a few questions and get a realistic price range and timeline.