# cadubra2/central-de-andamentos architecture

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

- Interactive diagram: https://gitdiagram.com/cadubra2/central-de-andamentos
- Repository: https://github.com/cadubra2/central-de-andamentos

## Overview

Central de Andamentos is a legal-process monitoring dashboard. Incoming court notices and CNJ data are collected, parsed into normalized events, persisted and classified; lawyers review pending items and use the dashboard’s divergence, deadline, source-health and urgency-rule views. The graph reflects the README and shown imports/calls; some collectors and UI internals were not sampled, so their links rely on documented behavior or are omitted.

Main entry points: [`lib/ingestao.ts`](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/ingestao.ts) (Ingestion and deduplication), [`lib/consultas.ts`](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/consultas.ts) (Dashboard queries), [`db/schema.ts`](https://github.com/cadubra2/central-de-andamentos/blob/main/db/schema.ts) (Postgres event store), [`lib/coleta/datajud.ts`](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/coleta/datajud.ts) (DataJud collection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Collection and ingestion"]
  node_receive_api["Notice receive API<br/>[route.ts]"]
  node_imap_api["IMAP collection API<br/>[route.ts]"]
  node_djen_api["DJEN receive API<br/>[route.ts]"]
  node_datajud_api["DataJud receive API<br/>[route.ts]"]
  node_imap_collection["IMAP collector<br/>[imap.ts]"]
  node_djen_collection["DJEN collection<br/>[djen.ts]"]
  node_datajud_collection["DataJud collection<br/>[datajud.ts]"]
end

subgraph group_domain["Event processing"]
  node_ingest["Ingestion and deduplication<br/>[ingestao.ts]"]
  node_parsers["Notice parsers"]
  node_urgency["Urgency classification<br/>[classificacao.ts]"]
  node_publication_merge["Duplicate publication matching"]
  node_cross_source["Push versus diary<br/>[cruzamento.ts]"]
  node_calendar["Forensic deadline calendar"]
end

subgraph group_storage["Persistence"]
  node_database[("Postgres event store<br/>[schema.ts]")]
  node_queries["Dashboard queries<br/>[consultas.ts]"]
end

subgraph group_dashboard["Lawyer dashboard"]
  node_pending["Pending items panel<br/>[page.tsx]"]
  node_divergences["Divergence view<br/>[page.tsx]"]
  node_deadlines["Deadlines view<br/>[page.tsx]"]
  node_sources["Source health view<br/>[page.tsx]"]
  node_rules["Urgency rules view<br/>[page.tsx]"]
  node_actions["Event actions<br/>[acoes.ts]"]
end

subgraph group_access["Access control"]
  node_auth["Session authorization<br/>[sessao.ts]"]
  node_login["Login page<br/>[page.tsx]"]
end

node_lawyer(("Lawyer"))
node_gmail[("Gmail mailbox")]
node_djen_service["CNJ DJEN"]
node_datajud_service["CNJ DataJud"]

node_gmail -->|"sends notices"| node_receive_api
node_gmail -.->|"alternative collection"| node_imap_api
node_djen_service -->|"supplies communications"| node_djen_api
node_datajud_service -->|"supplies movements"| node_datajud_api
node_imap_api -->|"delegates collection"| node_imap_collection
node_receive_api -->|"ingests notices"| node_ingest
node_imap_collection -->|"ingests messages"| node_ingest
node_djen_api -->|"receives batch"| node_djen_collection
node_djen_collection -->|"ingests communications"| node_ingest
node_datajud_api -->|"receives batch"| node_datajud_collection
node_datajud_collection -->|"ingests movements"| node_ingest
node_ingest -->|"parses messages"| node_parsers
node_ingest -->|"classifies events"| node_urgency
node_ingest -->|"matches duplicates"| node_publication_merge
node_ingest -->|"writes events"| node_database
node_datajud_collection -->|"updates process status"| node_database
node_queries -->|"reads records"| node_database
node_queries -->|"computes divergences"| node_cross_source
node_pending -->|"loads pending items"| node_queries
node_divergences -->|"loads comparisons"| node_queries
node_deadlines -->|"loads deadline items"| node_queries
node_sources -->|"loads source status"| node_queries
node_rules -->|"loads rule data"| node_queries
node_rules -->|"updates rules"| node_actions
node_actions -->|"updates event state"| node_database
node_pending -->|"handles event actions"| node_actions
node_deadlines -.->|"uses deadline calculations"| node_calendar
node_lawyer -->|"reviews matters"| node_pending
node_lawyer -->|"reviews mismatches"| node_divergences
node_lawyer -->|"checks deadlines"| node_deadlines
node_lawyer -->|"checks source health"| node_sources
node_lawyer -->|"edits urgency rules"| node_rules
node_lawyer -->|"signs in"| node_login
node_login -.->|"starts session"| node_auth

click node_receive_api "https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/receber/route.ts"
click node_imap_api "https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/coleta/route.ts"
click node_djen_api "https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/receber/djen/route.ts"
click node_datajud_api "https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/receber/datajud/route.ts"
click node_imap_collection "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/coleta/imap.ts"
click node_djen_collection "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/coleta/djen.ts"
click node_datajud_collection "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/coleta/datajud.ts"
click node_ingest "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/ingestao.ts"
click node_parsers "https://github.com/cadubra2/central-de-andamentos/tree/main/lib/parsers"
click node_urgency "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/classificacao.ts"
click node_publication_merge "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/mesma-publicacao.ts"
click node_cross_source "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/cruzamento.ts"
click node_calendar "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/calendario-forense.ts"
click node_database "https://github.com/cadubra2/central-de-andamentos/blob/main/db/schema.ts"
click node_queries "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/consultas.ts"
click node_pending "https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/(caixa)/page.tsx"
click node_divergences "https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/divergencias/page.tsx"
click node_deadlines "https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/prazos/page.tsx"
click node_sources "https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/fontes/page.tsx"
click node_rules "https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/regras/page.tsx"
click node_actions "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/acoes.ts"
click node_auth "https://github.com/cadubra2/central-de-andamentos/blob/main/lib/sessao.ts"
click node_login "https://github.com/cadubra2/central-de-andamentos/blob/main/app/login/page.tsx"

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_receive_api,node_imap_api,node_djen_api,node_datajud_api,node_imap_collection,node_djen_collection,node_datajud_collection toneBlue
class node_ingest,node_parsers,node_urgency,node_publication_merge,node_cross_source,node_calendar,node_gmail toneAmber
class node_database,node_queries toneMint
class node_pending,node_divergences,node_deadlines,node_sources,node_rules,node_actions toneRose
class node_auth,node_login,node_lawyer,node_djen_service,node_datajud_service toneIndigo
```

## Components

### Collection and ingestion

- [Notice receive API](https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/receber/route.ts): `app/api/receber/route.ts`
- [IMAP collection API](https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/coleta/route.ts): `app/api/coleta/route.ts`
- [DJEN receive API](https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/receber/djen/route.ts): `app/api/receber/djen/route.ts`
- [DataJud receive API](https://github.com/cadubra2/central-de-andamentos/blob/main/app/api/receber/datajud/route.ts): `app/api/receber/datajud/route.ts`
- [IMAP collector](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/coleta/imap.ts): `lib/coleta/imap.ts`
- [DJEN collection](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/coleta/djen.ts): `lib/coleta/djen.ts`
- [DataJud collection](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/coleta/datajud.ts): `lib/coleta/datajud.ts`

### Event processing

- [Ingestion and deduplication](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/ingestao.ts): `lib/ingestao.ts`
- [Notice parsers](https://github.com/cadubra2/central-de-andamentos/tree/main/lib/parsers): `lib/parsers`
- [Urgency classification](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/classificacao.ts): `lib/classificacao.ts`
- [Duplicate publication matching](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/mesma-publicacao.ts): `lib/mesma-publicacao.ts`
- [Push versus diary](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/cruzamento.ts): `lib/cruzamento.ts`
- [Forensic deadline calendar](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/calendario-forense.ts): `lib/calendario-forense.ts`

### Persistence

- [Postgres event store](https://github.com/cadubra2/central-de-andamentos/blob/main/db/schema.ts): `db/schema.ts`
- [Dashboard queries](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/consultas.ts): `lib/consultas.ts`

### Lawyer dashboard

- [Pending items panel](https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/(caixa)/page.tsx): `app/(painel)/(caixa)/page.tsx`
- [Divergence view](https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/divergencias/page.tsx): `app/(painel)/divergencias/page.tsx`
- [Deadlines view](https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/prazos/page.tsx): `app/(painel)/prazos/page.tsx`
- [Source health view](https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/fontes/page.tsx): `app/(painel)/fontes/page.tsx`
- [Urgency rules view](https://github.com/cadubra2/central-de-andamentos/blob/main/app/(painel)/regras/page.tsx): `app/(painel)/regras/page.tsx`
- [Event actions](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/acoes.ts): `lib/acoes.ts`

### Access control

- [Session authorization](https://github.com/cadubra2/central-de-andamentos/blob/main/lib/sessao.ts): `lib/sessao.ts`
- [Login page](https://github.com/cadubra2/central-de-andamentos/blob/main/app/login/page.tsx): `app/login/page.tsx`

### Other components

- **Lawyer**
- **Gmail mailbox**
- **CNJ DJEN**
- **CNJ DataJud**

## Connections

- Gmail mailbox → Notice receive API: sends notices (evidence: `README.md`)
- Gmail mailbox → IMAP collection API: alternative collection (evidence: `README.md`)
- CNJ DJEN → DJEN receive API: supplies communications (evidence: `README.md`)
- CNJ DataJud → DataJud receive API: supplies movements (evidence: `README.md`)
- IMAP collection API → IMAP collector: delegates collection (evidence: `app/api/coleta/route.ts`)
- Notice receive API → Ingestion and deduplication: ingests notices (evidence: `README.md`)
- IMAP collector → Ingestion and deduplication: ingests messages (evidence: `README.md`)
- DJEN receive API → DJEN collection: receives batch (evidence: `app/api/receber/djen/route.ts`)
- DJEN collection → Ingestion and deduplication: ingests communications (evidence: `lib/coleta/djen.ts`)
- DataJud receive API → DataJud collection: receives batch (evidence: `app/api/receber/datajud/route.ts`)
- DataJud collection → Ingestion and deduplication: ingests movements (evidence: `lib/coleta/datajud.ts`)
- Ingestion and deduplication → Notice parsers: parses messages (evidence: `lib/ingestao.ts`)
- Ingestion and deduplication → Urgency classification: classifies events (evidence: `lib/ingestao.ts`)
- Ingestion and deduplication → Duplicate publication matching: matches duplicates (evidence: `lib/ingestao.ts`)
- Ingestion and deduplication → Postgres event store: writes events (evidence: `lib/ingestao.ts`)
- DataJud collection → Postgres event store: updates process status (evidence: `lib/coleta/datajud.ts`)
- Dashboard queries → Postgres event store: reads records (evidence: `lib/consultas.ts`)
- Dashboard queries → Push versus diary: computes divergences (evidence: `lib/consultas.ts`)
- Pending items panel → Dashboard queries: loads pending items (evidence: `app/(painel)/(caixa)/page.tsx`)
- Divergence view → Dashboard queries: loads comparisons (evidence: `app/(painel)/divergencias/page.tsx`)
- Deadlines view → Dashboard queries: loads deadline items (evidence: `app/(painel)/prazos/page.tsx`)
- Source health view → Dashboard queries: loads source status (evidence: `app/(painel)/fontes/page.tsx`)
- Urgency rules view → Dashboard queries: loads rule data (evidence: `app/(painel)/regras/page.tsx`)
- Urgency rules view → Event actions: updates rules (evidence: `app/(painel)/regras/page.tsx`)
- Event actions → Postgres event store: updates event state (evidence: `lib/acoes.ts`)
- Pending items panel → Event actions: handles event actions
- Deadlines view → Forensic deadline calendar: uses deadline calculations (evidence: `README.md`)
- Lawyer → Pending items panel: reviews matters (evidence: `README.md`)
- Lawyer → Divergence view: reviews mismatches (evidence: `README.md`)
- Lawyer → Deadlines view: checks deadlines (evidence: `README.md`)
- Lawyer → Source health view: checks source health (evidence: `README.md`)
- Lawyer → Urgency rules view: edits urgency rules (evidence: `README.md`)
- Lawyer → Login page: signs in (evidence: `README.md`)
- Login page → Session authorization: starts session
