# sgtp3pp3r/archiva_gob architecture

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

- Interactive diagram: https://gitdiagram.com/sgtp3pp3r/archiva_gob
- Repository: https://github.com/sgtp3pp3r/archiva_gob

## Overview

This application turns uploaded PDFs into editable identification records and downloadable Word fichas. Its principal workflow is PDF reading, field extraction, normalization and validation, human review in the web interface, then DOCX generation; a direct PDF-to-Word endpoint is also available. The backend stages and editor interactions are visible in the excerpts. The upload page and some frontend wiring were not excerpted, so their relationships are left unasserted.

Main entry points: [`backend/app/api/routes/documents.py`](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/api/routes/documents.py) (Document endpoints), [`backend/app/services/word_generator.py`](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/word_generator.py) (Word generator), [`interfaz-carga-documentos/app/editar/page.tsx`](https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/app/editar/page.tsx) (Ficha editor), [`backend/app/schemas/ficha.py`](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/schemas/ficha.py) (Ficha model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_upload["Upload screen<br/>[page.tsx]"]
  node_editor["Ficha editor<br/>[page.tsx]"]
  node_pdf_store[("PDF storage<br/>[pdf-storage.ts]")]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["Document API"]
  node_server["FastAPI app<br/>[main.py]"]
  node_documents["Document endpoints<br/>[documents.py]"]
  node_config["API configuration<br/>[config.py]"]
end

subgraph group_processing["PDF processing"]
  node_pdf_reader["PDF reader<br/>[pdf_reader.py]"]
  node_extractor["Field extractor<br/>[data_extractor.py]"]
  node_schema["Ficha model<br/>[ficha.py]"]
end

subgraph group_output["Validation and output"]
  node_validator["Normalize and validate<br/>[validator.py]"]
  node_generator["Word generator<br/>[word_generator.py]"]
  node_template["DOCX template<br/>[ficha_base.docx]"]
end

node_user(("User"))

node_user -.->|"uploads PDF"| node_upload
node_user -->|"reviews ficha"| node_editor
node_editor -->|"loads source PDF"| node_pdf_store
node_editor -->|"submits ficha"| node_documents
node_server -->|"mounts router"| node_documents
node_documents -->|"reads upload limits"| node_config
node_documents -->|"reads PDF"| node_pdf_reader
node_documents -->|"extracts fields"| node_extractor
node_documents -->|"normalizes and validates"| node_validator
node_documents -->|"generates DOCX"| node_generator
node_extractor -->|"builds ficha"| node_schema
node_validator -->|"validates ficha"| node_schema
node_generator -->|"renders ficha"| node_schema
node_generator -->|"loads template path"| node_config
node_generator -->|"uses template"| node_template

click node_upload "https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/app/page.tsx"
click node_editor "https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/app/editar/page.tsx"
click node_pdf_store "https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/lib/pdf-storage.ts"
click node_api_client "https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/lib/api.ts"
click node_server "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/main.py"
click node_documents "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/api/routes/documents.py"
click node_config "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/config.py"
click node_pdf_reader "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/pdf_reader.py"
click node_extractor "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/data_extractor.py"
click node_schema "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/schemas/ficha.py"
click node_validator "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/validator.py"
click node_generator "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/word_generator.py"
click node_template "https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/templates/ficha_base.docx"

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_upload,node_editor,node_pdf_store,node_api_client,node_user toneBlue
class node_server,node_documents,node_config toneAmber
class node_pdf_reader,node_extractor,node_schema toneMint
class node_validator,node_generator,node_template toneRose
```

## Components

### Web interface

- [Upload screen](https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/app/page.tsx): `interfaz-carga-documentos/app/page.tsx`
- [Ficha editor](https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/app/editar/page.tsx): `interfaz-carga-documentos/app/editar/page.tsx`
- [PDF storage](https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/lib/pdf-storage.ts): `interfaz-carga-documentos/lib/pdf-storage.ts`
- [API client](https://github.com/sgtp3pp3r/archiva_gob/blob/main/interfaz-carga-documentos/lib/api.ts): `interfaz-carga-documentos/lib/api.ts`

### Document API

- [FastAPI app](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/main.py): `backend/main.py`
- [Document endpoints](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/api/routes/documents.py): `backend/app/api/routes/documents.py`
- [API configuration](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/config.py): `backend/app/config.py`

### PDF processing

- [PDF reader](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/pdf_reader.py): `backend/app/services/pdf_reader.py`
- [Field extractor](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/data_extractor.py): `backend/app/services/data_extractor.py`
- [Ficha model](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/schemas/ficha.py): `backend/app/schemas/ficha.py`

### Validation and output

- [Normalize and validate](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/validator.py): `backend/app/services/validator.py`
- [Word generator](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/services/word_generator.py): `backend/app/services/word_generator.py`
- [DOCX template](https://github.com/sgtp3pp3r/archiva_gob/blob/main/backend/app/templates/ficha_base.docx): `backend/app/templates/ficha_base.docx`

### Other components

- **User**

## Connections

- User → Upload screen: uploads PDF
- User → Ficha editor: reviews ficha (evidence: `interfaz-carga-documentos/app/editar/page.tsx`)
- Ficha editor → PDF storage: loads source PDF (evidence: `interfaz-carga-documentos/app/editar/page.tsx`)
- Ficha editor → Document endpoints: submits ficha (evidence: `interfaz-carga-documentos/app/editar/page.tsx`)
- FastAPI app → Document endpoints: mounts router (evidence: `backend/main.py`)
- Document endpoints → API configuration: reads upload limits (evidence: `backend/app/api/routes/documents.py`)
- Document endpoints → PDF reader: reads PDF (evidence: `backend/app/api/routes/documents.py`)
- Document endpoints → Field extractor: extracts fields (evidence: `backend/app/api/routes/documents.py`)
- Document endpoints → Normalize and validate: normalizes and validates (evidence: `backend/app/api/routes/documents.py`)
- Document endpoints → Word generator: generates DOCX (evidence: `backend/app/api/routes/documents.py`)
- Field extractor → Ficha model: builds ficha (evidence: `backend/app/services/data_extractor.py`)
- Normalize and validate → Ficha model: validates ficha (evidence: `backend/app/services/validator.py`)
- Word generator → Ficha model: renders ficha (evidence: `backend/app/services/word_generator.py`)
- Word generator → API configuration: loads template path (evidence: `backend/app/services/word_generator.py`)
- Word generator → DOCX template: uses template (evidence: `backend/app/services/word_generator.py`)
