# d4rr-code/r3pcr architecture

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

- Interactive diagram: https://gitdiagram.com/d4rr-code/r3pcr
- Repository: https://github.com/d4rr-code/r3pcr

## Overview

This Django application coordinates customs-shipment clearance among consignees, declarants, and supervisors. Consignees submit shipment details and documents; declarants claim shipments, extract document data, prepare computations, and advance clearance milestones; consignees review estimates, while supervisors monitor operations and provide analytics. The graph preserves the documented-in-source computation, OCR, advisory, tariff, reporting, audit, and notification areas. The README is empty, and several relationships rely on SOURCE INDEX references rather than inspected call sites, so unsupported connections are omitted.

Main entry points: [`apps/computation/views/compute.py`](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/compute.py) (Duty computation), [`apps/shipments/models.py`](https://github.com/d4rr-code/r3pcr/blob/main/apps/shipments/models.py) (Shipment records), [`apps/consignee/views/submissions.py`](https://github.com/d4rr-code/r3pcr/blob/main/apps/consignee/views/submissions.py) (Consignee submissions), [`apps/declarant/views/workflow.py`](https://github.com/d4rr-code/r3pcr/blob/main/apps/declarant/views/workflow.py) (Declarant workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and alerts"]
  node_users[("Accounts and users<br/>[models.py]")]
  node_auth["Authentication<br/>[auth.py]"]
  node_notifications["Notifications<br/>[utils.py]"]
end

subgraph group_clearance["Shipment clearance"]
  node_consignee["Consignee submissions<br/>[submissions.py]"]
  node_declarant["Declarant workflow<br/>[workflow.py]"]
  node_shipments[("Shipment records<br/>[models.py]")]
  node_milestones["Milestone rules<br/>[workflow.py]"]
end

subgraph group_customs["Customs computation"]
  node_ocr["Document OCR<br/>[engine.py]"]
  node_computation["Duty computation<br/>[compute.py]"]
  node_computation_data[("Computation records<br/>[models.py]")]
  node_advisory["Shipment advisory<br/>[advisory.py]"]
  node_ecdt["ECDT workspace<br/>[ecdt.py]"]
  node_hs_codes["HS code tools<br/>[hs_codes.py]"]
  node_wmcda["Decision scoring<br/>[wmcda.py]"]
  node_downloads["Computation downloads<br/>[downloads.py]"]
  node_drafts["Computation drafts<br/>[drafts.py]"]
end

subgraph group_operations["Supervisor operations"]
  node_supervisor["Supervisor analytics<br/>[analytics.py]"]
  node_intelligence["Risk intelligence<br/>[intelligence.py]"]
  node_reports["Operational reports<br/>[reports.py]"]
  node_audit["Audit logging<br/>[audit.py]"]
  node_supervisor_data[("Supervisor records<br/>[models.py]")]
end

node_consignee_actor(("Consignee"))
node_declarant_actor(("Declarant"))
node_supervisor_actor(("Supervisor"))

node_consignee_actor -->|"submits"| node_consignee
node_consignee -->|"creates records"| node_shipments
node_declarant_actor -->|"processes"| node_declarant
node_declarant -->|"updates"| node_shipments
node_declarant -->|"runs extraction"| node_ocr
node_declarant -->|"checks transitions"| node_milestones
node_milestones -->|"reads shipment state"| node_shipments
node_computation -->|"loads shipment"| node_shipments
node_computation -->|"saves estimate"| node_computation_data
node_computation -->|"requests suggestions"| node_hs_codes
node_computation -->|"uses advisory"| node_advisory
node_computation -->|"scores options"| node_wmcda
node_computation -->|"checks workflow"| node_milestones
node_consignee -->|"scores recommendations"| node_wmcda
node_consignee -->|"uses computation views"| node_computation
node_computation_data -->|"references shipment"| node_shipments
node_shipments -->|"references consignee"| node_users
node_auth -->|"authenticates"| node_users
node_auth -->|"records events"| node_audit
node_auth -->|"sends account email"| node_notifications
node_supervisor_actor -->|"reviews operations"| node_supervisor
node_supervisor -->|"serves report data"| node_reports
node_supervisor -.->|"reviews risk forecasts"| node_intelligence
node_intelligence -->|"analyzes shipments"| node_shipments
node_intelligence -->|"reviews code suggestions"| node_hs_codes
node_reports -->|"reads analytics"| node_supervisor
node_audit -->|"writes audit logs"| node_supervisor_data
node_computation -->|"records computation actions"| node_audit
node_declarant -->|"records workflow actions"| node_audit
node_consignee -->|"records submission actions"| node_audit
node_downloads -.->|"exports estimates"| node_computation_data
node_drafts -.->|"manages drafts"| node_computation_data
node_ecdt -.->|"supports clearance"| node_shipments
node_consignee -.->|"uses shipment alerts"| node_notifications
node_notifications -->|"looks up recipients"| node_users

click node_users "https://github.com/d4rr-code/r3pcr/blob/main/apps/accounts/models.py"
click node_auth "https://github.com/d4rr-code/r3pcr/blob/main/apps/accounts/views/auth.py"
click node_notifications "https://github.com/d4rr-code/r3pcr/blob/main/apps/notifications/utils.py"
click node_consignee "https://github.com/d4rr-code/r3pcr/blob/main/apps/consignee/views/submissions.py"
click node_declarant "https://github.com/d4rr-code/r3pcr/blob/main/apps/declarant/views/workflow.py"
click node_shipments "https://github.com/d4rr-code/r3pcr/blob/main/apps/shipments/models.py"
click node_milestones "https://github.com/d4rr-code/r3pcr/blob/main/apps/shipments/workflow.py"
click node_ocr "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/ocr/engine.py"
click node_computation "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/compute.py"
click node_computation_data "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/models.py"
click node_advisory "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/advisory.py"
click node_ecdt "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/ecdt.py"
click node_hs_codes "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/hs_codes.py"
click node_wmcda "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/wmcda.py"
click node_downloads "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/downloads.py"
click node_drafts "https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/drafts.py"
click node_supervisor "https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/views/analytics.py"
click node_intelligence "https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/views/intelligence.py"
click node_reports "https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/views/reports.py"
click node_audit "https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/audit.py"
click node_supervisor_data "https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/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_users,node_auth,node_notifications toneBlue
class node_consignee,node_declarant,node_shipments,node_milestones toneAmber
class node_ocr,node_computation,node_computation_data,node_advisory,node_ecdt,node_hs_codes,node_wmcda,node_downloads,node_drafts toneMint
class node_supervisor,node_intelligence,node_reports,node_audit,node_supervisor_data toneRose
class node_consignee_actor,node_declarant_actor,node_supervisor_actor toneIndigo
```

## Components

### Identity and alerts

- [Accounts and users](https://github.com/d4rr-code/r3pcr/blob/main/apps/accounts/models.py): `apps/accounts/models.py`
- [Authentication](https://github.com/d4rr-code/r3pcr/blob/main/apps/accounts/views/auth.py): `apps/accounts/views/auth.py`
- [Notifications](https://github.com/d4rr-code/r3pcr/blob/main/apps/notifications/utils.py): `apps/notifications/utils.py`

### Shipment clearance

- [Consignee submissions](https://github.com/d4rr-code/r3pcr/blob/main/apps/consignee/views/submissions.py): `apps/consignee/views/submissions.py`
- [Declarant workflow](https://github.com/d4rr-code/r3pcr/blob/main/apps/declarant/views/workflow.py): `apps/declarant/views/workflow.py`
- [Shipment records](https://github.com/d4rr-code/r3pcr/blob/main/apps/shipments/models.py): `apps/shipments/models.py`
- [Milestone rules](https://github.com/d4rr-code/r3pcr/blob/main/apps/shipments/workflow.py): `apps/shipments/workflow.py`

### Customs computation

- [Document OCR](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/ocr/engine.py): `apps/computation/ocr/engine.py`
- [Duty computation](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/compute.py): `apps/computation/views/compute.py`
- [Computation records](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/models.py): `apps/computation/models.py`
- [Shipment advisory](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/advisory.py): `apps/computation/views/advisory.py`
- [ECDT workspace](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/ecdt.py): `apps/computation/views/ecdt.py`
- [HS code tools](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/hs_codes.py): `apps/computation/views/hs_codes.py`
- [Decision scoring](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/wmcda.py): `apps/computation/wmcda.py`
- [Computation downloads](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/downloads.py): `apps/computation/views/downloads.py`
- [Computation drafts](https://github.com/d4rr-code/r3pcr/blob/main/apps/computation/views/drafts.py): `apps/computation/views/drafts.py`

### Supervisor operations

- [Supervisor analytics](https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/views/analytics.py): `apps/supervisor/views/analytics.py`
- [Risk intelligence](https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/views/intelligence.py): `apps/supervisor/views/intelligence.py`
- [Operational reports](https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/views/reports.py): `apps/supervisor/views/reports.py`
- [Audit logging](https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/audit.py): `apps/supervisor/audit.py`
- [Supervisor records](https://github.com/d4rr-code/r3pcr/blob/main/apps/supervisor/models.py): `apps/supervisor/models.py`

### Other components

- **Consignee**
- **Declarant**
- **Supervisor**

## Connections

- Consignee → Consignee submissions: submits (evidence: `apps/consignee/views/submissions.py`)
- Consignee submissions → Shipment records: creates records (evidence: `apps/consignee/views/submissions.py`)
- Declarant → Declarant workflow: processes (evidence: `apps/declarant/views/workflow.py`)
- Declarant workflow → Shipment records: updates (evidence: `apps/declarant/views/workflow.py`)
- Declarant workflow → Document OCR: runs extraction (evidence: `apps/declarant/views/workflow.py`)
- Declarant workflow → Milestone rules: checks transitions (evidence: `apps/declarant/views/workflow.py`)
- Milestone rules → Shipment records: reads shipment state (evidence: `apps/shipments/workflow.py`)
- Duty computation → Shipment records: loads shipment (evidence: `apps/computation/views/compute.py`)
- Duty computation → Computation records: saves estimate (evidence: `apps/computation/views/compute.py`)
- Duty computation → HS code tools: requests suggestions (evidence: `apps/computation/views/compute.py`)
- Duty computation → Shipment advisory: uses advisory (evidence: `apps/computation/views/compute.py`)
- Duty computation → Decision scoring: scores options (evidence: `apps/computation/views/compute.py`)
- Duty computation → Milestone rules: checks workflow (evidence: `apps/computation/views/compute.py`)
- Consignee submissions → Decision scoring: scores recommendations (evidence: `apps/consignee/views/submissions.py`)
- Consignee submissions → Duty computation: uses computation views (evidence: `apps/consignee/views/submissions.py`)
- Computation records → Shipment records: references shipment (evidence: `apps/computation/models.py`)
- Shipment records → Accounts and users: references consignee (evidence: `apps/shipments/models.py`)
- Authentication → Accounts and users: authenticates (evidence: `apps/accounts/views/auth.py`)
- Authentication → Audit logging: records events (evidence: `apps/accounts/views/auth.py`)
- Authentication → Notifications: sends account email
- Supervisor → Supervisor analytics: reviews operations
- Supervisor analytics → Operational reports: serves report data (evidence: `apps/supervisor/views/reports.py`)
- Supervisor analytics → Risk intelligence: reviews risk forecasts
- Risk intelligence → Shipment records: analyzes shipments (evidence: `apps/supervisor/views/intelligence.py`)
- Risk intelligence → HS code tools: reviews code suggestions (evidence: `apps/supervisor/views/intelligence.py`)
- Operational reports → Supervisor analytics: reads analytics (evidence: `apps/supervisor/views/reports.py`)
- Audit logging → Supervisor records: writes audit logs (evidence: `apps/supervisor/audit.py`)
- Duty computation → Audit logging: records computation actions (evidence: `apps/computation/views/compute.py`)
- Declarant workflow → Audit logging: records workflow actions (evidence: `apps/declarant/views/workflow.py`)
- Consignee submissions → Audit logging: records submission actions (evidence: `apps/consignee/views/submissions.py`)
- Computation downloads → Computation records: exports estimates
- Computation drafts → Computation records: manages drafts
- ECDT workspace → Shipment records: supports clearance
- Consignee submissions → Notifications: uses shipment alerts (evidence: `apps/consignee/views/submissions.py`)
- Notifications → Accounts and users: looks up recipients (evidence: `apps/notifications/utils.py`)
