Asynchronous CNPJ Query API
A FastAPI service that queues CNPJ queries, processes Sintegra Goiás lookups asynchronously, and exposes temporary results through a task-based API.
Technologies
- Python
- FastAPI
- Celery
- RabbitMQ
- Redis
- Selenium
Overview
The API receives a CNPJ through a POST endpoint and returns a task identifier. Clients can later query the task status and temporary result through a separate endpoint.
Asynchronous workflow
FastAPI validates and submits the request to RabbitMQ. A Celery worker consumes the task, uses Selenium to perform the lookup, and stores the result temporarily in Redis. The API then reports pending, completed, not-found, or invalid-task states to clients.
Quality and operational considerations
The project separates API and worker tests, documents Docker Compose startup, and uses a one-hour Redis TTL for task results. The temporary cache policy keeps completed query data from being retained indefinitely.