# cadubra2/redator-de-pecas-multiagente architecture

> Architecture diagram of the GitHub repository cadubra2/redator-de-pecas-multiagente, 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/redator-de-pecas-multiagente
- Repository: https://github.com/cadubra2/redator-de-pecas-multiagente

## Overview

This is a multi-agent legal-brief drafting and evaluation system. A case’s source materials and the firm’s writing guidance feed a drafting loop: a redactor produces a brief, a code-based style checker and reviewer/cr critic cycle refine it, and three blind judges score it. The orchestrator aggregates their assessments into consensus feedback, keeps the highest-scoring version, and writes results. The README documents the major capabilities and flow; sampled source confirms key orchestration, provider, and consensus behavior, but not every prompt or stopping rule.

Main entry points: [`orquestrador/loop.py`](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/loop.py) (Drafting loop), [`orquestrador/provedores.py`](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/provedores.py) (LLM providers), [`skill/SKILL.md`](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/skill/SKILL.md) (Firm voice skill), [`orquestrador/__main__.py`](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/__main__.py) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_drafting["Drafting workflow"]
  node_case_sources["Case sources"]
  node_redactor["Redator"]
  node_style_check["Style checker<br/>[verificar.py]"]
  node_reviewer["Revisor"]
  node_critic["Crítico"]
end

subgraph group_guidance["Writing guidance"]
  node_skill["Firm voice skill<br/>[SKILL.md]"]
  node_skill_references["Style references"]
  node_rubric["Scoring rubric<br/>[rubrica.md]"]
end

subgraph group_orchestration["Orchestration"]
  node_orchestrator["Drafting loop<br/>[loop.py]"]
  node_cli["CLI entry<br/>[__main__.py]"]
  node_providers["LLM providers<br/>[provedores.py]"]
end

subgraph group_evaluation["Evaluation and results"]
  node_judges["Blind judges<br/>[juiz-cego.md]"]
  node_consensus["Consensus grouping<br/>[consenso.py]"]
  node_best_version["Best-version selection<br/>[loop.py]"]
  node_run_results[("Run results<br/>[loop.py]")]
  node_sample_evolution["Sample evolution"]
end

node_user(("Lawyer"))
node_llm_service["LLM services"]

node_user -->|"starts run"| node_cli
node_cli -->|"configures and runs"| node_orchestrator
node_orchestrator -->|"reads case facts"| node_case_sources
node_orchestrator -->|"requests draft"| node_redactor
node_orchestrator -->|"provides guidance"| node_skill
node_orchestrator -->|"uses writing guidance"| node_skill_references
node_orchestrator -->|"checks draft"| node_style_check
node_orchestrator -->|"requests revisions"| node_reviewer
node_orchestrator -->|"requests approval"| node_critic
node_orchestrator -->|"requests blind scores"| node_judges
node_orchestrator -->|"supplies scoring rubric"| node_rubric
node_orchestrator -->|"routes role calls"| node_providers
node_providers -->|"calls configured model"| node_llm_service
node_providers -.->|"reads recorded replies"| node_run_results
node_orchestrator -->|"groups judge findings"| node_consensus
node_consensus -->|"formats revision feedback"| node_redactor
node_orchestrator -->|"compares round scores"| node_best_version
node_best_version -->|"writes best brief"| node_run_results
node_orchestrator -->|"writes scores and notes"| node_run_results
node_sample_evolution -->|"illustrates score history"| node_user
node_skill -.->|"supplemented by"| node_skill_references

click node_case_sources "https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/casos"
click node_redactor "https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/papeis"
click node_style_check "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/skill/scripts/verificar.py"
click node_reviewer "https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/papeis"
click node_critic "https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/papeis"
click node_skill "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/skill/SKILL.md"
click node_skill_references "https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/skill/references"
click node_rubric "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/rubrica/rubrica.md"
click node_orchestrator "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/loop.py"
click node_cli "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/__main__.py"
click node_providers "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/provedores.py"
click node_judges "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/papeis/juiz-cego.md"
click node_consensus "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/consenso.py"
click node_best_version "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/loop.py"
click node_run_results "https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/loop.py"
click node_sample_evolution "https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/exemplos/evolucao-parnaiba"

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_case_sources,node_redactor,node_style_check,node_reviewer,node_critic toneBlue
class node_skill,node_skill_references,node_rubric toneAmber
class node_orchestrator,node_cli,node_providers toneMint
class node_judges,node_consensus,node_best_version,node_run_results,node_sample_evolution toneRose
class node_user,node_llm_service toneIndigo
```

## Components

### Drafting workflow

- [Case sources](https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/casos): `casos`
- [Redator](https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/papeis): `papeis`
- [Style checker](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/skill/scripts/verificar.py): `skill/scripts/verificar.py`
- [Revisor](https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/papeis): `papeis`
- [Crítico](https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/papeis): `papeis`

### Writing guidance

- [Firm voice skill](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/skill/SKILL.md): `skill/SKILL.md`
- [Style references](https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/skill/references): `skill/references`
- [Scoring rubric](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/rubrica/rubrica.md): `rubrica/rubrica.md`

### Orchestration

- [Drafting loop](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/loop.py): `orquestrador/loop.py`
- [CLI entry](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/__main__.py): `orquestrador/__main__.py`
- [LLM providers](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/provedores.py): `orquestrador/provedores.py`

### Evaluation and results

- [Blind judges](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/papeis/juiz-cego.md): `papeis/juiz-cego.md`
- [Consensus grouping](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/consenso.py): `orquestrador/consenso.py`
- [Best-version selection](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/loop.py): `orquestrador/loop.py`
- [Run results](https://github.com/cadubra2/redator-de-pecas-multiagente/blob/main/orquestrador/loop.py): `orquestrador/loop.py`
- [Sample evolution](https://github.com/cadubra2/redator-de-pecas-multiagente/tree/main/exemplos/evolucao-parnaiba): `exemplos/evolucao-parnaiba`

### Other components

- **Lawyer**
- **LLM services**

## Connections

- Lawyer → CLI entry: starts run (evidence: `README.md`)
- CLI entry → Drafting loop: configures and runs (evidence: `orquestrador/__main__.py`)
- Drafting loop → Case sources: reads case facts (evidence: `orquestrador/loop.py`)
- Drafting loop → Redator: requests draft (evidence: `README.md`)
- Drafting loop → Firm voice skill: provides guidance (evidence: `orquestrador/loop.py`)
- Drafting loop → Style references: uses writing guidance (evidence: `README.md`)
- Drafting loop → Style checker: checks draft (evidence: `orquestrador/loop.py`)
- Drafting loop → Revisor: requests revisions (evidence: `README.md`)
- Drafting loop → Crítico: requests approval (evidence: `README.md`)
- Drafting loop → Blind judges: requests blind scores (evidence: `orquestrador/loop.py`)
- Drafting loop → Scoring rubric: supplies scoring rubric (evidence: `orquestrador/loop.py`)
- Drafting loop → LLM providers: routes role calls (evidence: `orquestrador/loop.py`)
- LLM providers → LLM services: calls configured model (evidence: `orquestrador/provedores.py`)
- LLM providers → Run results: reads recorded replies (evidence: `orquestrador/provedores.py`)
- Drafting loop → Consensus grouping: groups judge findings (evidence: `orquestrador/loop.py`)
- Consensus grouping → Redator: formats revision feedback (evidence: `orquestrador/consenso.py`)
- Drafting loop → Best-version selection: compares round scores (evidence: `orquestrador/loop.py`)
- Best-version selection → Run results: writes best brief (evidence: `orquestrador/loop.py`)
- Drafting loop → Run results: writes scores and notes (evidence: `orquestrador/loop.py`)
- Sample evolution → Lawyer: illustrates score history (evidence: `README.md`)
- Firm voice skill → Style references: supplemented by
