# juliolimaal/central-certidoes architecture

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

- Interactive diagram: https://gitdiagram.com/juliolimaal/central-certidoes
- Repository: https://github.com/juliolimaal/central-certidoes

## Overview

Gestão de Certificados is a local Windows application for obtaining, organizing, and exporting six business-compliance documents. The user enters a CNPJ in the browser dashboard, starts a job, completes the two Receita Federal documents manually, and lets four other portal adapters run automatically, with manual recovery available after an error. The backend stores document results and history locally and offers integrity-checked PDF access and ZIP generation. The graph combines sampled source references with README-documented capabilities; some unsampled server and packaging details are therefore represented only at the documented subsystem level.

Main entry points: [`src/job-manager.ts`](https://github.com/juliolimaal/central-certidoes/blob/main/src/job-manager.ts) (Job orchestrator), [`src/services/sefaz-pb.service.ts`](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/sefaz-pb.service.ts) (SEFAZ/PB), [`src/server.ts`](https://github.com/juliolimaal/central-certidoes/blob/main/src/server.ts) (Local API), [`src/services/prefeitura-jp.service.ts`](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/prefeitura-jp.service.ts) (João Pessoa)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Local dashboard"]
  node_dashboard["Dashboard<br/>[app.js]"]
end

subgraph group_workflow["Document workflow"]
  node_orchestrator["Job orchestrator<br/>[job-manager.ts]"]
  node_manualportals["Manual portal guidance<br/>[manual-portals.ts]"]
  node_officialportals["Official portal registry"]
  node_receitacnpj["Receita CNPJ"]
  node_receitafederal["Federal certificate"]
  node_sefaz["SEFAZ/PB"]
  node_prefeitura["João Pessoa"]
  node_cndt["CNDT<br/>[cndt.service.ts]"]
  node_fgts["FGTS<br/>[fgts.service.ts]"]
  node_manualupload["Manual PDF checks"]
  node_rules["Document rules<br/>[document-rules.ts]"]
  node_capture["PDF capture<br/>[capture.ts]"]
  node_browser["Browser helpers<br/>[browser.ts]"]
  node_session["Portal sessions<br/>[portal-session.ts]"]
  node_wait["Portal waiting<br/>[manual-wait.ts]"]
end

subgraph group_persistence["Local records"]
  node_storage["Manual PDF storage"]
  node_manifest[("Artifact manifest")]
  node_history[("Job history<br/>[job-history.ts]")]
end

subgraph group_runtime["Application runtime"]
  node_server["Local API<br/>[server.ts]"]
  node_security["Local security<br/>[local-security.ts]"]
  node_runtimepaths["Runtime paths<br/>[runtime-paths.ts]"]
end

node_user(("User"))
node_portals["Official portals"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests jobs"| node_server
node_server -->|"checks requests"| node_security
node_server -->|"dispatches jobs"| node_orchestrator
node_server -->|"serves guidance"| node_manualportals
node_server -->|"serves verified PDFs"| node_manifest
node_server -->|"checks uploads"| node_manualupload
node_orchestrator -->|"runs adapter"| node_receitacnpj
node_orchestrator -.->|"runs adapter"| node_receitafederal
node_orchestrator -->|"runs adapter"| node_sefaz
node_orchestrator -->|"runs adapter"| node_prefeitura
node_orchestrator -->|"runs adapter"| node_cndt
node_orchestrator -->|"runs adapter"| node_fgts
node_orchestrator -->|"persists selected PDFs"| node_storage
node_storage -->|"validates files"| node_manualupload
node_orchestrator -->|"registers artifacts"| node_manifest
node_orchestrator -->|"saves jobs"| node_history
node_orchestrator -->|"resolves paths"| node_runtimepaths
node_sefaz -->|"opens session"| node_session
node_sefaz -->|"locates fields"| node_browser
node_sefaz -->|"uses portal URL"| node_officialportals
node_sefaz -->|"prepares capture"| node_capture
node_sefaz -.->|"waits for portal"| node_wait
node_prefeitura -->|"opens session"| node_session
node_prefeitura -->|"uses browser helpers"| node_browser
node_prefeitura -->|"captures document"| node_capture
node_prefeitura -->|"uses portal URL"| node_officialportals
node_cndt -->|"opens session"| node_session
node_cndt -->|"captures document"| node_capture
node_cndt -->|"uses portal URL"| node_officialportals
node_cndt -->|"applies rules"| node_rules
node_fgts -->|"opens session"| node_session
node_fgts -->|"captures document"| node_capture
node_fgts -->|"uses portal URL"| node_officialportals
node_fgts -->|"applies rules"| node_rules
node_receitacnpj -->|"opens session"| node_session
node_receitafederal -->|"opens session"| node_session
node_manualportals -->|"looks up URLs"| node_officialportals
node_portals -->|"serves portal"| node_sefaz
node_portals -->|"serves portal"| node_prefeitura
node_portals -->|"serves portal"| node_cndt
node_portals -->|"serves portal"| node_fgts
node_portals -->|"serves portal"| node_receitacnpj
node_portals -->|"serves portal"| node_receitafederal

click node_dashboard "https://github.com/juliolimaal/central-certidoes/blob/main/public/app.js"
click node_server "https://github.com/juliolimaal/central-certidoes/blob/main/src/server.ts"
click node_security "https://github.com/juliolimaal/central-certidoes/blob/main/src/local-security.ts"
click node_orchestrator "https://github.com/juliolimaal/central-certidoes/blob/main/src/job-manager.ts"
click node_manualportals "https://github.com/juliolimaal/central-certidoes/blob/main/src/manual-portals.ts"
click node_officialportals "https://github.com/juliolimaal/central-certidoes/blob/main/src/official-portals.ts"
click node_receitacnpj "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/receita-cnpj.service.ts"
click node_receitafederal "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/receita-federal.service.ts"
click node_sefaz "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/sefaz-pb.service.ts"
click node_prefeitura "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/prefeitura-jp.service.ts"
click node_cndt "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/cndt.service.ts"
click node_fgts "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/fgts.service.ts"
click node_manualupload "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/manual-upload.service.ts"
click node_storage "https://github.com/juliolimaal/central-certidoes/blob/main/src/manual-document-storage.ts"
click node_rules "https://github.com/juliolimaal/central-certidoes/blob/main/src/services/document-rules.ts"
click node_capture "https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/capture.ts"
click node_browser "https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/browser.ts"
click node_session "https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/portal-session.ts"
click node_wait "https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/manual-wait.ts"
click node_manifest "https://github.com/juliolimaal/central-certidoes/blob/main/src/artifact-manifest.ts"
click node_history "https://github.com/juliolimaal/central-certidoes/blob/main/src/job-history.ts"
click node_runtimepaths "https://github.com/juliolimaal/central-certidoes/blob/main/src/runtime-paths.ts"

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_dashboard,node_user toneBlue
class node_orchestrator,node_manualportals,node_officialportals,node_receitacnpj,node_receitafederal,node_sefaz,node_prefeitura,node_cndt,node_fgts,node_manualupload,node_rules,node_capture,node_browser,node_session,node_wait toneAmber
class node_storage,node_manifest,node_history toneMint
class node_server,node_security,node_runtimepaths toneRose
class node_portals toneIndigo
```

## Components

### Local dashboard

- [Dashboard](https://github.com/juliolimaal/central-certidoes/blob/main/public/app.js): `public/app.js`

### Document workflow

- [Job orchestrator](https://github.com/juliolimaal/central-certidoes/blob/main/src/job-manager.ts): `src/job-manager.ts`
- [Manual portal guidance](https://github.com/juliolimaal/central-certidoes/blob/main/src/manual-portals.ts): `src/manual-portals.ts`
- [Official portal registry](https://github.com/juliolimaal/central-certidoes/blob/main/src/official-portals.ts): `src/official-portals.ts`
- [Receita CNPJ](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/receita-cnpj.service.ts): `src/services/receita-cnpj.service.ts`
- [Federal certificate](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/receita-federal.service.ts): `src/services/receita-federal.service.ts`
- [SEFAZ/PB](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/sefaz-pb.service.ts): `src/services/sefaz-pb.service.ts`
- [João Pessoa](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/prefeitura-jp.service.ts): `src/services/prefeitura-jp.service.ts`
- [CNDT](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/cndt.service.ts): `src/services/cndt.service.ts`
- [FGTS](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/fgts.service.ts): `src/services/fgts.service.ts`
- [Manual PDF checks](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/manual-upload.service.ts): `src/services/manual-upload.service.ts`
- [Document rules](https://github.com/juliolimaal/central-certidoes/blob/main/src/services/document-rules.ts): `src/services/document-rules.ts`
- [PDF capture](https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/capture.ts): `src/utils/capture.ts`
- [Browser helpers](https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/browser.ts): `src/utils/browser.ts`
- [Portal sessions](https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/portal-session.ts): `src/utils/portal-session.ts`
- [Portal waiting](https://github.com/juliolimaal/central-certidoes/blob/main/src/utils/manual-wait.ts): `src/utils/manual-wait.ts`

### Local records

- [Manual PDF storage](https://github.com/juliolimaal/central-certidoes/blob/main/src/manual-document-storage.ts): `src/manual-document-storage.ts`
- [Artifact manifest](https://github.com/juliolimaal/central-certidoes/blob/main/src/artifact-manifest.ts): `src/artifact-manifest.ts`
- [Job history](https://github.com/juliolimaal/central-certidoes/blob/main/src/job-history.ts): `src/job-history.ts`

### Application runtime

- [Local API](https://github.com/juliolimaal/central-certidoes/blob/main/src/server.ts): `src/server.ts`
- [Local security](https://github.com/juliolimaal/central-certidoes/blob/main/src/local-security.ts): `src/local-security.ts`
- [Runtime paths](https://github.com/juliolimaal/central-certidoes/blob/main/src/runtime-paths.ts): `src/runtime-paths.ts`

### Other components

- **User**
- **Official portals**

## Connections

- User → Dashboard: uses (evidence: `README.md`)
- Dashboard → Local API: requests jobs (evidence: `README.md`)
- Local API → Local security: checks requests (evidence: `src/server.ts`)
- Local API → Job orchestrator: dispatches jobs (evidence: `src/server.ts`)
- Local API → Manual portal guidance: serves guidance (evidence: `src/server.ts`)
- Local API → Artifact manifest: serves verified PDFs (evidence: `src/server.ts`)
- Local API → Manual PDF checks: checks uploads (evidence: `src/server.ts`)
- Job orchestrator → Receita CNPJ: runs adapter (evidence: `src/job-manager.ts`)
- Job orchestrator → Federal certificate: runs adapter
- Job orchestrator → SEFAZ/PB: runs adapter (evidence: `src/job-manager.ts`)
- Job orchestrator → João Pessoa: runs adapter (evidence: `src/job-manager.ts`)
- Job orchestrator → CNDT: runs adapter (evidence: `src/job-manager.ts`)
- Job orchestrator → FGTS: runs adapter (evidence: `src/job-manager.ts`)
- Job orchestrator → Manual PDF storage: persists selected PDFs (evidence: `src/job-manager.ts`)
- Manual PDF storage → Manual PDF checks: validates files (evidence: `src/manual-document-storage.ts`)
- Job orchestrator → Artifact manifest: registers artifacts (evidence: `src/job-manager.ts`)
- Job orchestrator → Job history: saves jobs (evidence: `src/job-manager.ts`)
- Job orchestrator → Runtime paths: resolves paths (evidence: `src/job-manager.ts`)
- SEFAZ/PB → Portal sessions: opens session (evidence: `src/services/sefaz-pb.service.ts`)
- SEFAZ/PB → Browser helpers: locates fields (evidence: `src/services/sefaz-pb.service.ts`)
- SEFAZ/PB → Official portal registry: uses portal URL (evidence: `src/services/sefaz-pb.service.ts`)
- SEFAZ/PB → PDF capture: prepares capture (evidence: `src/services/sefaz-pb.service.ts`)
- SEFAZ/PB → Portal waiting: waits for portal (evidence: `src/services/sefaz-pb.service.ts`)
- João Pessoa → Portal sessions: opens session (evidence: `src/services/prefeitura-jp.service.ts`)
- João Pessoa → Browser helpers: uses browser helpers (evidence: `src/services/prefeitura-jp.service.ts`)
- João Pessoa → PDF capture: captures document (evidence: `src/services/prefeitura-jp.service.ts`)
- João Pessoa → Official portal registry: uses portal URL (evidence: `src/services/prefeitura-jp.service.ts`)
- CNDT → Portal sessions: opens session (evidence: `src/services/cndt.service.ts`)
- CNDT → PDF capture: captures document (evidence: `src/services/cndt.service.ts`)
- CNDT → Official portal registry: uses portal URL (evidence: `src/services/cndt.service.ts`)
- CNDT → Document rules: applies rules (evidence: `src/services/cndt.service.ts`)
- FGTS → Portal sessions: opens session (evidence: `src/services/fgts.service.ts`)
- FGTS → PDF capture: captures document (evidence: `src/services/fgts.service.ts`)
- FGTS → Official portal registry: uses portal URL (evidence: `src/services/fgts.service.ts`)
- FGTS → Document rules: applies rules (evidence: `src/services/fgts.service.ts`)
- Receita CNPJ → Portal sessions: opens session (evidence: `src/services/receita-cnpj.service.ts`)
- Federal certificate → Portal sessions: opens session (evidence: `src/services/receita-federal.service.ts`)
- Manual portal guidance → Official portal registry: looks up URLs (evidence: `src/manual-portals.ts`)
- Official portals → SEFAZ/PB: serves portal (evidence: `README.md`)
- Official portals → João Pessoa: serves portal (evidence: `README.md`)
- Official portals → CNDT: serves portal (evidence: `README.md`)
- Official portals → FGTS: serves portal (evidence: `README.md`)
- Official portals → Receita CNPJ: serves portal (evidence: `README.md`)
- Official portals → Federal certificate: serves portal (evidence: `README.md`)
