# santi-macagno/tp-final-pcyp-thread-ators architecture

> Architecture diagram of the GitHub repository santi-macagno/tp-final-pcyp-thread-ators, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/santi-macagno/tp-final-pcyp-thread-ators
- Repository: https://github.com/santi-macagno/tp-final-pcyp-thread-ators

## Overview

This Java program simulates a payment-processing system as a Petri net, coordinating worker threads through a concurrency monitor. The principal workflow is: Main initializes the net and workers; workers repeatedly request transitions; the monitor serializes firing, waits for enabled transitions and minimum delays, and dispatches waiting workers using a policy. The run ends after the configured number of completed invariants, then the program validates the firing sequence and writes summaries and logs. The README documents the payment-flow branches; sampled implementation evidence is strongest for orchestration, synchronization, recording, and validation.

Main entry points: [`src/Main.java`](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Main.java) (Run coordinator), [`src/Monitor.java`](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Monitor.java) (Fair monitor), [`src/Registro.java`](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Registro.java) (Run recorder), [`src/Segmento.java`](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Segmento.java) (Transition workers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Run orchestration"]
  node_main["Run coordinator<br/>[Main.java]"]
  node_workers["Transition workers<br/>[Segmento.java]"]
end

subgraph group_model["Payment model"]
  node_petri["Petri payment model<br/>[RedDePetri.java]"]
end

subgraph group_sync["Concurrency control"]
  node_monitor_api["Monitor interface"]
  node_monitor["Fair monitor<br/>[Monitor.java]"]
  node_policy_api["Scheduling policy<br/>[Politica.java]"]
  node_random_policy["Random selection"]
  node_priority_policy["Risk priority"]
end

subgraph group_results["Validation and results"]
  node_registry["Run recorder<br/>[Registro.java]"]
  node_regex["Invariant validator<br/>[Regex.java]"]
  node_logfiles["Run log files"]
end

node_cli(("CLI user"))

node_cli -->|"starts run"| node_main
node_main -->|"initializes net"| node_petri
node_main -->|"creates recorder"| node_registry
node_main -->|"creates monitor"| node_monitor
node_main -->|"selects policy"| node_priority_policy
node_main -->|"starts workers"| node_workers
node_workers -->|"requests firing"| node_monitor_api
node_monitor -->|"implements"| node_monitor_api
node_monitor -->|"fires transitions"| node_petri
node_monitor -->|"chooses waiter"| node_policy_api
node_priority_policy -->|"falls back"| node_random_policy
node_random_policy -->|"implements choice"| node_policy_api
node_monitor -->|"records events"| node_registry
node_main -->|"reads run data"| node_registry
node_main -->|"validates sequence"| node_regex
node_main -->|"writes results"| node_logfiles

click node_main "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Main.java"
click node_workers "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Segmento.java"
click node_monitor_api "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/MonitorInterface.java"
click node_monitor "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Monitor.java"
click node_petri "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/RedDePetri.java"
click node_policy_api "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Politica.java"
click node_random_policy "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/PoliticaAleatoria.java"
click node_priority_policy "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/PoliticaPriorizada.java"
click node_registry "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Registro.java"
click node_regex "https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Regex.java"

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_main,node_workers,node_cli toneBlue
class node_petri toneAmber
class node_monitor_api,node_monitor,node_policy_api,node_random_policy,node_priority_policy toneMint
class node_registry,node_regex,node_logfiles toneRose
```

## Components

### Run orchestration

- [Run coordinator](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Main.java): `src/Main.java`
- [Transition workers](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Segmento.java): `src/Segmento.java`

### Payment model

- [Petri payment model](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/RedDePetri.java): `src/RedDePetri.java`

### Concurrency control

- [Monitor interface](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/MonitorInterface.java): `src/MonitorInterface.java`
- [Fair monitor](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Monitor.java): `src/Monitor.java`
- [Scheduling policy](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Politica.java): `src/Politica.java`
- [Random selection](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/PoliticaAleatoria.java): `src/PoliticaAleatoria.java`
- [Risk priority](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/PoliticaPriorizada.java): `src/PoliticaPriorizada.java`

### Validation and results

- [Run recorder](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Registro.java): `src/Registro.java`
- [Invariant validator](https://github.com/santi-macagno/tp-final-pcyp-thread-ators/blob/main/src/Regex.java): `src/Regex.java`
- **Run log files**

### Other components

- **CLI user**

## Connections

- CLI user → Run coordinator: starts run (evidence: `README.md`)
- Run coordinator → Petri payment model: initializes net (evidence: `src/Main.java`)
- Run coordinator → Run recorder: creates recorder (evidence: `src/Main.java`)
- Run coordinator → Fair monitor: creates monitor (evidence: `src/Main.java`)
- Run coordinator → Risk priority: selects policy (evidence: `src/Main.java`)
- Run coordinator → Transition workers: starts workers (evidence: `src/Main.java`)
- Transition workers → Monitor interface: requests firing (evidence: `src/Segmento.java`)
- Fair monitor → Monitor interface: implements (evidence: `src/Monitor.java`)
- Fair monitor → Petri payment model: fires transitions (evidence: `src/Monitor.java`)
- Fair monitor → Scheduling policy: chooses waiter (evidence: `src/Monitor.java`)
- Risk priority → Random selection: falls back (evidence: `src/PoliticaPriorizada.java`)
- Random selection → Scheduling policy: implements choice (evidence: `src/PoliticaAleatoria.java`)
- Fair monitor → Run recorder: records events (evidence: `src/Monitor.java`)
- Run coordinator → Run recorder: reads run data (evidence: `src/Main.java`)
- Run coordinator → Invariant validator: validates sequence (evidence: `src/Main.java`)
- Run coordinator → Run log files: writes results (evidence: `src/Main.java`)
