# informatica3crcsc/rpa-jucesc architecture

> Architecture diagram of the GitHub repository informatica3crcsc/rpa-jucesc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/informatica3crcsc/rpa-jucesc
- Repository: https://github.com/informatica3crcsc/rpa-jucesc

## Overview

Serviço HTTP e interface Web para consultar fichas cadastrais da JUCESC por CNPJ e disponibilizar PDFs e CSVs. O fluxo principal aceita CNPJs digitados ou enviados em TXT/CSV, valida solicitante e entradas, executa a automação Playwright e devolve resultados identificados por consulta, com links para listar e baixar arquivos. O mapa separa entrada, validação, automação e armazenamento/entrega. As relações entre módulos amostrados seguem as chamadas visíveis; integrações externas e capacidades descritas apenas no README são identificadas como documentadas.

Main entry points: [`src/api.py`](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/api.py) (Rotas FastAPI), [`consulta_fichas_jucesc.py`](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/consulta_fichas_jucesc.py) (Motor Playwright), [`src/static/app.js`](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/static/app.js) (Interface Web), [`src/rpa_jucesc.py`](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/rpa_jucesc.py) (Adaptador RPA)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrada["Entrada e interface"]
  node_ui["Interface Web<br/>[app.js]"]
  node_web_document["Página Web<br/>[index.html]"]
end

subgraph group_api["API e validação"]
  node_api_entry["Rotas FastAPI<br/>[api.py]"]
  node_config["Configuração<br/>[config.py]"]
  node_models["Contratos API<br/>[models.py]"]
  node_input_parse["Leitura TXT/CSV<br/>[api.py]"]
  node_applicant_validation["Validação solicitante"]
end

subgraph group_automacao["Automação JUCESC"]
  node_cnpj_validation["Normalização CNPJ<br/>[rpa_jucesc.py]"]
  node_rpa_adapter["Adaptador RPA<br/>[rpa_jucesc.py]"]
  node_engine["Motor Playwright"]
end

subgraph group_arquivos["Resultados e arquivos"]
  node_storage["Pastas de consulta<br/>[storage.py]"]
  node_generated["PDFs e CSV"]
  node_file_delivery["Listagem e download<br/>[api.py]"]
end

node_usuario(("Usuário Web"))
node_cliente(("Cliente HTTP"))
node_playwright["Playwright"]
node_jucesc["Site JUCESC"]

node_usuario -->|"usa"| node_ui
node_cliente -->|"envia requisição"| node_api_entry
node_ui -->|"envia consulta"| node_api_entry
node_api_entry -->|"serve página"| node_web_document
node_api_entry -->|"carrega configuração"| node_config
node_api_entry -->|"usa contratos"| node_models
node_api_entry -->|"interpreta arquivo"| node_input_parse
node_api_entry -->|"valida solicitante"| node_applicant_validation
node_api_entry -->|"valida CNPJs"| node_cnpj_validation
node_api_entry -->|"cria pasta"| node_storage
node_api_entry -->|"executa automação"| node_rpa_adapter
node_rpa_adapter -->|"delegates consulta"| node_engine
node_engine -.->|"automatiza navegador"| node_playwright
node_engine -->|"consulta fichas"| node_jucesc
node_engine -->|"gera resultados"| node_generated
node_api_entry -->|"informa links"| node_generated
node_api_entry -->|"expõe rotas"| node_file_delivery
node_file_delivery -->|"lista e verifica"| node_storage
node_file_delivery -->|"serve arquivos"| node_generated

click node_ui "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/static/app.js"
click node_web_document "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/static/index.html"
click node_api_entry "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/api.py"
click node_config "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/config.py"
click node_models "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/models.py"
click node_input_parse "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/api.py"
click node_applicant_validation "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/consulta_fichas_jucesc.py"
click node_cnpj_validation "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/rpa_jucesc.py"
click node_rpa_adapter "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/rpa_jucesc.py"
click node_engine "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/consulta_fichas_jucesc.py"
click node_storage "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/storage.py"
click node_generated "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/consulta_fichas_jucesc.py"
click node_file_delivery "https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/api.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui,node_web_document,node_cliente toneBlue
class node_api_entry,node_config,node_models,node_input_parse,node_applicant_validation toneAmber
class node_cnpj_validation,node_rpa_adapter,node_engine toneMint
class node_storage,node_generated,node_file_delivery toneRose
class node_usuario,node_playwright,node_jucesc toneIndigo
```

## Components

### Entrada e interface

- [Interface Web](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/static/app.js): `src/static/app.js`
- [Página Web](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/static/index.html): `src/static/index.html`

### API e validação

- [Rotas FastAPI](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/api.py): `src/api.py`
- [Configuração](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/config.py): `src/config.py`
- [Contratos API](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/models.py): `src/models.py`
- [Leitura TXT/CSV](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/api.py): `src/api.py`
- [Validação solicitante](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/consulta_fichas_jucesc.py): `consulta_fichas_jucesc.py`

### Automação JUCESC

- [Normalização CNPJ](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/rpa_jucesc.py): `src/rpa_jucesc.py`
- [Adaptador RPA](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/rpa_jucesc.py): `src/rpa_jucesc.py`
- [Motor Playwright](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/consulta_fichas_jucesc.py): `consulta_fichas_jucesc.py`

### Resultados e arquivos

- [Pastas de consulta](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/storage.py): `src/storage.py`
- [PDFs e CSV](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/consulta_fichas_jucesc.py): `consulta_fichas_jucesc.py`
- [Listagem e download](https://github.com/informatica3crcsc/rpa-jucesc/blob/main/src/api.py): `src/api.py`

### Other components

- **Usuário Web**
- **Cliente HTTP**
- **Playwright**
- **Site JUCESC**

## Connections

- Usuário Web → Interface Web: usa (evidence: `README.md`)
- Cliente HTTP → Rotas FastAPI: envia requisição (evidence: `README.md`)
- Interface Web → Rotas FastAPI: envia consulta (evidence: `src/static/app.js`)
- Rotas FastAPI → Página Web: serve página (evidence: `src/api.py`)
- Rotas FastAPI → Configuração: carrega configuração (evidence: `src/api.py`)
- Rotas FastAPI → Contratos API: usa contratos (evidence: `src/api.py`)
- Rotas FastAPI → Leitura TXT/CSV: interpreta arquivo (evidence: `src/api.py`)
- Rotas FastAPI → Validação solicitante: valida solicitante (evidence: `src/api.py`)
- Rotas FastAPI → Normalização CNPJ: valida CNPJs (evidence: `src/api.py`)
- Rotas FastAPI → Pastas de consulta: cria pasta (evidence: `src/api.py`)
- Rotas FastAPI → Adaptador RPA: executa automação (evidence: `src/api.py`)
- Adaptador RPA → Motor Playwright: delegates consulta (evidence: `src/rpa_jucesc.py`)
- Motor Playwright → Playwright: automatiza navegador (evidence: `README.md`)
- Motor Playwright → Site JUCESC: consulta fichas (evidence: `README.md`)
- Motor Playwright → PDFs e CSV: gera resultados (evidence: `README.md`)
- Rotas FastAPI → PDFs e CSV: informa links (evidence: `src/api.py`)
- Rotas FastAPI → Listagem e download: expõe rotas (evidence: `src/api.py`)
- Listagem e download → Pastas de consulta: lista e verifica (evidence: `src/api.py`)
- Listagem e download → PDFs e CSV: serve arquivos (evidence: `README.md`)
