# grgbrasil/procapi architecture

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

- Interactive diagram: https://gitdiagram.com/grgbrasil/procapi
- Repository: https://github.com/grgbrasil/procapi

## Overview

ProcAPI exposes judicial-process data through a read-only REST API and refreshes records asynchronously from Eproc. Existing process records provide cached results; requests for missing or stale records trigger creation or refresh. The task code stores the raw response and extracts process, event, and party data. The README also documents forced updates and retained responses for later processing. Arrows reflect the sampled routes, view logic, task calls, and service code; some internal task behavior was not sampled.

Main entry points: [`procapi/processo/tasks.py`](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/tasks.py) (Refresh tasks), [`procapi/processo/views.py`](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/views.py) (Process views), [`procapi/utils/services.py`](https://github.com/grgbrasil/procapi/blob/master/procapi/utils/services.py) (Eproc services), [`procapi/processo/models.py`](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py) (Process records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_routing["API routing<br/>[urls.py]"]
  node_process_views["Process views<br/>[views.py]"]
  node_serializers["JSON serializers<br/>[serializers.py]"]
end

subgraph group_refresh["Refresh workflow"]
  node_refresh_tasks["Refresh tasks<br/>[tasks.py]"]
  node_eproc_service["Eproc services<br/>[services.py]"]
end

subgraph group_data["Process data"]
  node_process_records[("Process records<br/>[models.py]")]
  node_raw_response[("Raw responses<br/>[models.py]")]
  node_events[("Events and documents<br/>[models.py]")]
  node_parties[("Parties and people<br/>[models.py]")]
  node_catalogs[("Reference catalogs<br/>[models.py]")]
end

subgraph group_runtime["Runtime configuration"]
  node_celery["Celery app<br/>[celery.py]"]
  node_settings["Application settings<br/>[common.py]"]
end

node_caller(("API client"))
node_mongodb[("MongoDB")]
node_eproc["Eproc service"]
node_task_broker["Task broker"]

node_caller -->|"requests"| node_routing
node_routing -->|"routes to"| node_process_views
node_process_views -->|"serializes with"| node_serializers
node_process_views -->|"queries"| node_process_records
node_process_views -->|"triggers refresh"| node_refresh_tasks
node_refresh_tasks -->|"consults"| node_eproc_service
node_refresh_tasks -->|"stores response"| node_raw_response
node_refresh_tasks -->|"updates"| node_process_records
node_refresh_tasks -->|"extracts"| node_events
node_refresh_tasks -->|"extracts"| node_parties
node_refresh_tasks -->|"looks up"| node_catalogs
node_eproc_service -->|"calls"| node_eproc
node_process_records -.->|"persists in"| node_mongodb
node_raw_response -.->|"persists in"| node_mongodb
node_events -.->|"persists in"| node_mongodb
node_parties -.->|"persists in"| node_mongodb
node_catalogs -.->|"persists in"| node_mongodb
node_celery -->|"loads"| node_settings
node_refresh_tasks -->|"registers tasks"| node_celery
node_refresh_tasks -.->|"dispatches tasks"| node_task_broker
node_settings -.->|"configures endpoints"| node_eproc_service

click node_routing "https://github.com/grgbrasil/procapi/blob/master/config/urls.py"
click node_process_views "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/views.py"
click node_serializers "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/serializers.py"
click node_refresh_tasks "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/tasks.py"
click node_eproc_service "https://github.com/grgbrasil/procapi/blob/master/procapi/utils/services.py"
click node_celery "https://github.com/grgbrasil/procapi/blob/master/procapi/taskapp/celery.py"
click node_settings "https://github.com/grgbrasil/procapi/blob/master/config/settings/common.py"
click node_process_records "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py"
click node_raw_response "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py"
click node_events "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py"
click node_parties "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py"
click node_catalogs "https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.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_routing,node_process_views,node_serializers,node_caller toneBlue
class node_refresh_tasks,node_eproc_service,node_mongodb toneAmber
class node_process_records,node_raw_response,node_events,node_parties,node_catalogs toneMint
class node_celery,node_settings,node_task_broker toneRose
class node_eproc toneIndigo
```

## Components

### REST API

- [API routing](https://github.com/grgbrasil/procapi/blob/master/config/urls.py): `config/urls.py`
- [Process views](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/views.py): `procapi/processo/views.py`
- [JSON serializers](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/serializers.py): `procapi/processo/serializers.py`

### Refresh workflow

- [Refresh tasks](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/tasks.py): `procapi/processo/tasks.py`
- [Eproc services](https://github.com/grgbrasil/procapi/blob/master/procapi/utils/services.py): `procapi/utils/services.py`

### Process data

- [Process records](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py): `procapi/processo/models.py`
- [Raw responses](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py): `procapi/processo/models.py`
- [Events and documents](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py): `procapi/processo/models.py`
- [Parties and people](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py): `procapi/processo/models.py`
- [Reference catalogs](https://github.com/grgbrasil/procapi/blob/master/procapi/processo/models.py): `procapi/processo/models.py`

### Runtime configuration

- [Celery app](https://github.com/grgbrasil/procapi/blob/master/procapi/taskapp/celery.py): `procapi/taskapp/celery.py`
- [Application settings](https://github.com/grgbrasil/procapi/blob/master/config/settings/common.py): `config/settings/common.py`

### Other components

- **API client**
- **MongoDB**
- **Eproc service**
- **Task broker**

## Connections

- API client → API routing: requests (evidence: `config/urls.py`)
- API routing → Process views: routes to (evidence: `config/urls.py`)
- Process views → JSON serializers: serializes with (evidence: `procapi/processo/views.py`)
- Process views → Process records: queries (evidence: `procapi/processo/views.py`)
- Process views → Refresh tasks: triggers refresh (evidence: `procapi/processo/views.py`)
- Refresh tasks → Eproc services: consults (evidence: `procapi/processo/tasks.py`)
- Refresh tasks → Raw responses: stores response (evidence: `procapi/processo/tasks.py`)
- Refresh tasks → Process records: updates (evidence: `procapi/processo/tasks.py`)
- Refresh tasks → Events and documents: extracts (evidence: `procapi/processo/tasks.py`)
- Refresh tasks → Parties and people: extracts (evidence: `procapi/processo/tasks.py`)
- Refresh tasks → Reference catalogs: looks up (evidence: `procapi/processo/tasks.py`)
- Eproc services → Eproc service: calls (evidence: `procapi/utils/services.py`)
- Process records → MongoDB: persists in
- Raw responses → MongoDB: persists in
- Events and documents → MongoDB: persists in
- Parties and people → MongoDB: persists in
- Reference catalogs → MongoDB: persists in
- Celery app → Application settings: loads (evidence: `procapi/taskapp/celery.py`)
- Refresh tasks → Celery app: registers tasks (evidence: `procapi/processo/tasks.py`)
- Refresh tasks → Task broker: dispatches tasks
- Application settings → Eproc services: configures endpoints
