# psacramento-gh/pixprivado architecture

> Architecture diagram of the GitHub repository psacramento-gh/pixprivado, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/psacramento-gh/pixprivado
- Repository: https://github.com/psacramento-gh/pixprivado

## Overview

Pix Privado is a browser-first Pix BR Code explorer. Users paste Copia e Cola text or upload a QR image; the app decodes the payload, validates and explains its nested fields, and can fetch dynamic-charge data. Separate lookup and enrichment branches support breach checks, Brazilian registry data, and location details. The README documents offline decoding and disabled network lookups in offline mode. Several central UI modules are indexed but unsampled, so their internal calls are not asserted beyond documented behavior.

Main entry points: [`src/components/decoder-app.tsx`](https://github.com/psacramento-gh/pixprivado/blob/main/src/components/decoder-app.tsx) (Decoder interface), [`src/app/api`](https://github.com/psacramento-gh/pixprivado/tree/main/src/app/api) (Brazil data endpoints), [`src/app/api/lookup/route.ts`](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/lookup/route.ts) (Lookup router), [`src/lib/breach/api-search.ts`](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/breach/api-search.ts) (Breach search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_decode["Decode and inspect"]
  node_decoder["Decoder interface<br/>[decoder-app.tsx]"]
  node_qrpreview["QR image preview"]
  node_qrdecode["QR decoding<br/>[decode-image.ts]"]
  node_payload["BR Code parsing<br/>[parse.ts]"]
  node_labels["Field labels<br/>[labels.ts]"]
  node_crc["CRC validation<br/>[crc.ts]"]
end

subgraph group_lookup["Search and lookup"]
  node_lookupui["Lookup panels"]
  node_lookupapi["Lookup router<br/>[route.ts]"]
  node_breach["Breach search<br/>[api-search.ts]"]
  node_receita["Receita Federal fetch<br/>[api-fetch.ts]"]
  node_portal["Transparency portal links<br/>[search-url.ts]"]
end

subgraph group_enrich["Payload enrichment"]
  node_location["Location proxy<br/>[route.ts]"]
  node_enrichapi["Brazil data endpoints"]
  node_cep["CEP lookup<br/>[route.ts]"]
  node_cnae["CNAE lookup<br/>[route.ts]"]
  node_ddd["DDD lookup<br/>[route.ts]"]
  node_municipios["Municipality lookup<br/>[route.ts]"]
  node_ip["IP lookup<br/>[route.ts]"]
end

subgraph group_offline["Offline runtime"]
  node_offlineui["Offline preference"]
  node_sw["Service worker<br/>[sw.js]"]
end

node_user(("User"))
node_dynamic["Dynamic charge host"]
node_hibp["HIBP API"]

node_user -->|"provides input"| node_decoder
node_decoder -.->|"decodes image"| node_qrdecode
node_qrpreview -->|"uses decoder"| node_qrdecode
node_decoder -.->|"parses payload"| node_payload
node_decoder -.->|"renders fields"| node_labels
node_decoder -.->|"validates checksum"| node_crc
node_decoder -->|"requests dynamic data"| node_location
node_location -->|"fetches charge"| node_dynamic
node_lookupui -.->|"requests lookup"| node_lookupapi
node_lookupapi -->|"searches breaches"| node_breach
node_breach -->|"queries API"| node_hibp
node_lookupapi -->|"fetches company"| node_receita
node_decoder -->|"opens CPF search"| node_portal
node_cep -.->|"provides endpoint"| node_enrichapi
node_cnae -.->|"provides endpoint"| node_enrichapi
node_ddd -.->|"provides endpoint"| node_enrichapi
node_municipios -.->|"provides endpoint"| node_enrichapi
node_ip -.->|"provides endpoint"| node_enrichapi
node_offlineui -.->|"supports offline shell"| node_sw
node_user -.->|"sets preference"| node_offlineui

click node_decoder "https://github.com/psacramento-gh/pixprivado/blob/main/src/components/decoder-app.tsx"
click node_qrpreview "https://github.com/psacramento-gh/pixprivado/blob/main/src/components/qr-image-preview.tsx"
click node_qrdecode "https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/qr/decode-image.ts"
click node_payload "https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/brcode/parse.ts"
click node_labels "https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/brcode/labels.ts"
click node_crc "https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/brcode/crc.ts"
click node_location "https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/location/route.ts"
click node_lookupui "https://github.com/psacramento-gh/pixprivado/blob/main/src/components/lookup/lookup-panel-stack.tsx"
click node_lookupapi "https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/lookup/route.ts"
click node_breach "https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/breach/api-search.ts"
click node_receita "https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/receita/api-fetch.ts"
click node_portal "https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/transparencia/search-url.ts"
click node_enrichapi "https://github.com/psacramento-gh/pixprivado/tree/main/src/app/api"
click node_cep "https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/cep/route.ts"
click node_cnae "https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/cnae/route.ts"
click node_ddd "https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/ddd/route.ts"
click node_municipios "https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/municipios/route.ts"
click node_ip "https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/ip/route.ts"
click node_offlineui "https://github.com/psacramento-gh/pixprivado/blob/main/src/components/offline-mode-provider.tsx"
click node_sw "https://github.com/psacramento-gh/pixprivado/blob/main/public/sw.js"

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_decoder,node_qrpreview,node_qrdecode,node_payload,node_labels,node_crc,node_user toneBlue
class node_lookupui,node_lookupapi,node_breach,node_receita,node_portal toneAmber
class node_location,node_enrichapi,node_cep,node_cnae,node_ddd,node_municipios,node_ip,node_hibp toneMint
class node_offlineui,node_sw toneRose
class node_dynamic toneIndigo
```

## Components

### Decode and inspect

- [Decoder interface](https://github.com/psacramento-gh/pixprivado/blob/main/src/components/decoder-app.tsx): `src/components/decoder-app.tsx`
- [QR image preview](https://github.com/psacramento-gh/pixprivado/blob/main/src/components/qr-image-preview.tsx): `src/components/qr-image-preview.tsx`
- [QR decoding](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/qr/decode-image.ts): `src/lib/qr/decode-image.ts`
- [BR Code parsing](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/brcode/parse.ts): `src/lib/brcode/parse.ts`
- [Field labels](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/brcode/labels.ts): `src/lib/brcode/labels.ts`
- [CRC validation](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/brcode/crc.ts): `src/lib/brcode/crc.ts`

### Search and lookup

- [Lookup panels](https://github.com/psacramento-gh/pixprivado/blob/main/src/components/lookup/lookup-panel-stack.tsx): `src/components/lookup/lookup-panel-stack.tsx`
- [Lookup router](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/lookup/route.ts): `src/app/api/lookup/route.ts`
- [Breach search](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/breach/api-search.ts): `src/lib/breach/api-search.ts`
- [Receita Federal fetch](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/receita/api-fetch.ts): `src/lib/receita/api-fetch.ts`
- [Transparency portal links](https://github.com/psacramento-gh/pixprivado/blob/main/src/lib/transparencia/search-url.ts): `src/lib/transparencia/search-url.ts`

### Payload enrichment

- [Location proxy](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/location/route.ts): `src/app/api/location/route.ts`
- [Brazil data endpoints](https://github.com/psacramento-gh/pixprivado/tree/main/src/app/api): `src/app/api`
- [CEP lookup](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/cep/route.ts): `src/app/api/cep/route.ts`
- [CNAE lookup](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/cnae/route.ts): `src/app/api/cnae/route.ts`
- [DDD lookup](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/ddd/route.ts): `src/app/api/ddd/route.ts`
- [Municipality lookup](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/municipios/route.ts): `src/app/api/municipios/route.ts`
- [IP lookup](https://github.com/psacramento-gh/pixprivado/blob/main/src/app/api/ip/route.ts): `src/app/api/ip/route.ts`

### Offline runtime

- [Offline preference](https://github.com/psacramento-gh/pixprivado/blob/main/src/components/offline-mode-provider.tsx): `src/components/offline-mode-provider.tsx`
- [Service worker](https://github.com/psacramento-gh/pixprivado/blob/main/public/sw.js): `public/sw.js`

### Other components

- **User**
- **Dynamic charge host**
- **HIBP API**

## Connections

- User → Decoder interface: provides input
- Decoder interface → QR decoding: decodes image
- QR image preview → QR decoding: uses decoder (evidence: `src/components/qr-image-preview.tsx`)
- Decoder interface → BR Code parsing: parses payload
- Decoder interface → Field labels: renders fields
- Decoder interface → CRC validation: validates checksum
- Decoder interface → Location proxy: requests dynamic data
- Location proxy → Dynamic charge host: fetches charge
- Lookup panels → Lookup router: requests lookup
- Lookup router → Breach search: searches breaches (evidence: `src/app/api/lookup/route.ts`)
- Breach search → HIBP API: queries API
- Lookup router → Receita Federal fetch: fetches company (evidence: `src/app/api/lookup/route.ts`)
- Decoder interface → Transparency portal links: opens CPF search
- CEP lookup → Brazil data endpoints: provides endpoint
- CNAE lookup → Brazil data endpoints: provides endpoint
- DDD lookup → Brazil data endpoints: provides endpoint
- Municipality lookup → Brazil data endpoints: provides endpoint
- IP lookup → Brazil data endpoints: provides endpoint
- Offline preference → Service worker: supports offline shell
- User → Offline preference: sets preference
