# cadubra2/gestao-documentos-juridicos architecture

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

- Interactive diagram: https://gitdiagram.com/cadubra2/gestao-documentos-juridicos
- Repository: https://github.com/cadubra2/gestao-documentos-juridicos

## Overview

This is a Portuguese-language legal-document management app. Users upload PDFs through the web interface or place them in a watched inbox; either route extracts text, optionally classifies and summarizes it with Gemini, stores the file in the pending collection, and records metadata. The web workflow also lists, views, reclassifies, and completes documents. The graph shows those domain stages and the database layer. Source excerpts support the web and monitor flows; template internals and deployment wiring were not inspected.

Main entry points: [`app/web/server.py`](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/web/server.py) (Web API), [`app/monitor.py`](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/monitor.py) (Inbox monitor), [`app/router.py`](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/router.py) (Document operations), [`app/config.py`](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/config.py) (Incoming PDFs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Document intake"]
  node_monitor["Inbox monitor<br/>[monitor.py]"]
  node_inbox["Incoming PDFs<br/>[config.py]"]
  node_extract["PDF text extraction<br/>[pdf_processor.py]"]
  node_classifier["Document classification<br/>[ai_client.py]"]
end

subgraph group_web["Web experience"]
  node_webapi["Web API<br/>[server.py]"]
  node_templates["Web templates"]
end

subgraph group_domain["Document management"]
  node_router["Document operations<br/>[router.py]"]
end

subgraph group_storage["Persistence"]
  node_pending["Pending documents<br/>[config.py]"]
  node_completed["Completed documents<br/>[config.py]"]
  node_database[("Document database<br/>[db.py]")]
end

node_user(("Legal staff"))
node_gemini["Gemini API"]

node_user -->|"uses"| node_webapi
node_webapi -->|"renders"| node_templates
node_webapi -->|"extracts text"| node_extract
node_webapi -->|"classifies"| node_classifier
node_webapi -->|"stages upload"| node_inbox
node_webapi -->|"moves upload"| node_pending
node_webapi -->|"records upload"| node_database
node_user -.->|"drops PDF"| node_inbox
node_inbox -->|"watches files"| node_monitor
node_monitor -->|"extracts text"| node_extract
node_monitor -->|"classifies"| node_classifier
node_monitor -->|"moves PDF"| node_pending
node_monitor -->|"records document"| node_database
node_classifier -->|"requests analysis"| node_gemini
node_webapi -->|"dispatches actions"| node_router
node_router -->|"queries and updates"| node_database
node_router -->|"moves or reclassifies"| node_pending
node_router -->|"completes documents"| node_completed

click node_webapi "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/web/server.py"
click node_templates "https://github.com/cadubra2/gestao-documentos-juridicos/tree/main/app/web/templates"
click node_monitor "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/monitor.py"
click node_inbox "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/config.py"
click node_extract "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/pdf_processor.py"
click node_classifier "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/ai_client.py"
click node_pending "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/config.py"
click node_completed "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/config.py"
click node_router "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/router.py"
click node_database "https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/db.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_monitor,node_inbox,node_extract,node_classifier toneBlue
class node_webapi,node_templates toneAmber
class node_router,node_gemini toneMint
class node_pending,node_completed,node_database toneRose
class node_user toneIndigo
```

## Components

### Document intake

- [Inbox monitor](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/monitor.py): `app/monitor.py`
- [Incoming PDFs](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/config.py): `app/config.py`
- [PDF text extraction](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/pdf_processor.py): `app/pdf_processor.py`
- [Document classification](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/ai_client.py): `app/ai_client.py`

### Web experience

- [Web API](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/web/server.py): `app/web/server.py`
- [Web templates](https://github.com/cadubra2/gestao-documentos-juridicos/tree/main/app/web/templates): `app/web/templates`

### Document management

- [Document operations](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/router.py): `app/router.py`

### Persistence

- [Pending documents](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/config.py): `app/config.py`
- [Completed documents](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/config.py): `app/config.py`
- [Document database](https://github.com/cadubra2/gestao-documentos-juridicos/blob/main/app/db.py): `app/db.py`

### Other components

- **Legal staff**
- **Gemini API**

## Connections

- Legal staff → Web API: uses (evidence: `app/web/server.py`)
- Web API → Web templates: renders (evidence: `app/web/server.py`)
- Web API → PDF text extraction: extracts text (evidence: `app/web/server.py`)
- Web API → Document classification: classifies (evidence: `app/web/server.py`)
- Web API → Incoming PDFs: stages upload (evidence: `app/web/server.py`)
- Web API → Pending documents: moves upload (evidence: `app/web/server.py`)
- Web API → Document database: records upload (evidence: `app/web/server.py`)
- Legal staff → Incoming PDFs: drops PDF
- Incoming PDFs → Inbox monitor: watches files (evidence: `app/monitor.py`)
- Inbox monitor → PDF text extraction: extracts text (evidence: `app/monitor.py`)
- Inbox monitor → Document classification: classifies (evidence: `app/monitor.py`)
- Inbox monitor → Pending documents: moves PDF (evidence: `app/monitor.py`)
- Inbox monitor → Document database: records document (evidence: `app/monitor.py`)
- Document classification → Gemini API: requests analysis (evidence: `app/ai_client.py`)
- Web API → Document operations: dispatches actions (evidence: `app/web/server.py`)
- Document operations → Document database: queries and updates (evidence: `app/router.py`)
- Document operations → Pending documents: moves or reclassifies (evidence: `app/router.py`)
- Document operations → Completed documents: completes documents (evidence: `app/router.py`)
