← PORTAFOLIOPORTFOLIO / proyectos / escaneo-masivo

// PRJ_006 · 2024

Escaneo masivo de guíasBulk waybill scanning

Rendimiento · PostgreSQLPerformance · PostgreSQL

Registrar devoluciones guía por guía tomaba horas. Ahora se escanean con lector y se procesan más de 10.000 guías en segundos.Registering returns one waybill at a time took hours. Now they're scanned with a reader and 10,000+ waybills are processed in seconds.

En detalleIn detailMódulo de escaneo masivo con lectores de código para registrar condiciones de devolución (fraude, daño). Lo que antes tomaba horas ahora procesa más de 10.000 guías en segundos, con un stored procedure en PostgreSQL invocado desde NestJS.Bulk scanning module with barcode readers to register return conditions (fraud, damage). What used to take hours now processes over 10,000 waybills in seconds, through a PostgreSQL stored procedure called from NestJS.

RolRole
Desarrollador a cargoLead developer
AñoYear
2024
CódigoSource
privado — trabajo de empresaprivate — company work
Stack
NestJS · PostgreSQL · TypeScript

// IMPACTO// IMPACT

+10.000+10.000
guías por corridawaybills per run
horashoras
antesbefore
segundossegundos
ahoranow

El problemaThe problem

El registro de devoluciones se hacía guía por guía. Con lotes de miles, la operación se quedaba esperando al sistema, y las condiciones de devolución (fraude, daño) se anotaban aparte y después.Return registration was done waybill by waybill. With batches of thousands, operations sat waiting on the system, and return conditions (fraud, damage) were noted separately and after the fact.

Cómo lo resolvíHow I solved it

Moví el procesamiento a un stored procedure en PostgreSQL que trabaja por lote en vez de por fila, invocado desde NestJS. El escaneo con lectores entra directo y procesa más de 10.000 guías en segundos, cuando antes tomaba horas.I moved processing into a PostgreSQL stored procedure that works per batch instead of per row, called from NestJS. Reader scanning feeds in directly and processes over 10,000 waybills in seconds, where it used to take hours.

Arquitectura y stackArchitecture & stack

  1. [01]Lector de códigos
  2. [02]API NestJS
  3. [03]Casos de uso
  4. [04]Procedimientos PostgreSQL
  5. [05]Reportes
  • NestJS
  • PostgreSQL
  • TypeScript

Lo que aprendíWhat I learned

01 //

Por lote, no por fila

El salto de rendimiento vino de cambiar la forma de la consulta, no de agregar máquina.

02 //

Hexagonal para poder medir

Con el dominio aislado se podía probar la lógica de devolución sin levantar la base.

03 //

El hardware manda el ritmo

El lector define la cadencia de entrada; el backend tenía que absorberla sin pedir pausas.

01 //

Per batch, not per row

The performance jump came from changing the shape of the query, not from adding hardware.

02 //

Hexagonal to be able to measure

With the domain isolated, return logic could be tested without bringing up the database.

03 //

Hardware sets the pace

The reader defines the input cadence; the backend had to absorb it without asking for pauses.