# renan3172/nfe-extractor2 architecture

> Architecture diagram of the GitHub repository renan3172/nfe-extractor2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/renan3172/nfe-extractor2
- Repository: https://github.com/renan3172/nfe-extractor2

## Overview

This is a small fiscal-document lookup application: a user submits an image and Gemini API key, the service reads the access key, then queries public consultation services for the document. The source also contains XML/PDF response handling and fiscal entity extraction. The excerpt does not show the full route implementation or frontend behavior, so those links are left unverified; the graph reflects only visible calls and documented workflow stages.

Main entry points: [`api/index.py`](https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py) (Fiscal document lookup), [`public/index.html`](https://github.com/renan3172/nfe-extractor2/blob/main/public/index.html) (Upload page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_web["Upload page<br/>[index.html]"]
end

subgraph group_service["Document service"]
  node_api["Processing route<br/>[index.py]"]
  node_keyread["Image key reading<br/>[index.py]"]
  node_consult["Fiscal document lookup<br/>[index.py]"]
  node_response["XML/PDF handling<br/>[index.py]"]
  node_fiscalparse["Fiscal entity extraction<br/>[index.py]"]
end

subgraph group_integrations["External services"]
  node_gemini{{"Gemini API"}}
  node_publicsite{{"Public consultation site"}}
  node_publicapi{{"Consultation API"}}
end

node_user(("User"))

node_user -.->|"submits image"| node_web
node_web -.->|"sends document"| node_api
node_api -.->|"reads key"| node_keyread
node_keyread -->|"requests reading"| node_gemini
node_api -->|"queries document"| node_consult
node_consult -->|"posts access key"| node_publicsite
node_consult -->|"posts access key"| node_publicapi
node_consult -->|"handles responses"| node_response
node_response -.->|"extracts entities"| node_fiscalparse

click node_web "https://github.com/renan3172/nfe-extractor2/blob/main/public/index.html"
click node_api "https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py"
click node_keyread "https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py"
click node_consult "https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py"
click node_response "https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py"
click node_fiscalparse "https://github.com/renan3172/nfe-extractor2/blob/main/api/index.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_web,node_user toneBlue
class node_api,node_keyread,node_consult,node_response,node_fiscalparse toneAmber
class node_gemini,node_publicsite,node_publicapi toneMint
```

## Components

### User interface

- [Upload page](https://github.com/renan3172/nfe-extractor2/blob/main/public/index.html): `public/index.html`

### Document service

- [Processing route](https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py): `api/index.py`
- [Image key reading](https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py): `api/index.py`
- [Fiscal document lookup](https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py): `api/index.py`
- [XML/PDF handling](https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py): `api/index.py`
- [Fiscal entity extraction](https://github.com/renan3172/nfe-extractor2/blob/main/api/index.py): `api/index.py`

### External services

- **Gemini API**
- **Public consultation site**
- **Consultation API**

### Other components

- **User**

## Connections

- User → Upload page: submits image
- Upload page → Processing route: sends document
- Processing route → Image key reading: reads key (evidence: `api/index.py`)
- Image key reading → Gemini API: requests reading (evidence: `api/index.py`)
- Processing route → Fiscal document lookup: queries document (evidence: `api/index.py`)
- Fiscal document lookup → Public consultation site: posts access key (evidence: `api/index.py`)
- Fiscal document lookup → Consultation API: posts access key (evidence: `api/index.py`)
- Fiscal document lookup → XML/PDF handling: handles responses (evidence: `api/index.py`)
- XML/PDF handling → Fiscal entity extraction: extracts entities (evidence: `api/index.py`)
