# bishesh009/assignment-2 architecture

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

- Interactive diagram: https://gitdiagram.com/bishesh009/assignment-2
- Repository: https://github.com/bishesh009/assignment-2

## Overview

This is a command-line Hare-Clark election program. It reads ballot data from a CSV file, builds an in-memory election, reports vote distributions and candidate preferences, then runs preference rounds until no further outcome is returned. The main stages are input, election setup, ballot storage, and tally/reporting; linked-list nodes support the storage layer. Interfaces are shown as contract components, but no implementation edges are claimed because the excerpts do not show those declarations. The README is empty, so the graph reflects the source excerpts and index only.

Main entry points: [`AssigTwo226.java`](https://github.com/bishesh009/assignment-2/blob/main/AssigTwo226.java) (Program harness), [`FileHandler.java`](https://github.com/bishesh009/assignment-2/blob/main/FileHandler.java) (CSV reader), [`Collection.java`](https://github.com/bishesh009/assignment-2/blob/main/Collection.java) (Election collection), [`Cluster.java`](https://github.com/bishesh009/assignment-2/blob/main/Cluster.java) (Candidate cluster)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Election workflow"]
  node_harness["Program harness<br/>[AssigTwo226.java]"]
  node_file_handler["CSV reader<br/>[FileHandler.java]"]
end

subgraph group_domain["Election data"]
  node_election["Election collection<br/>[Collection.java]"]
  node_ballot["Ballot state<br/>[Ballot.java]"]
  node_candidate_cluster["Candidate cluster<br/>[Cluster.java]"]
end

subgraph group_structures["Storage structures"]
  node_collection_nodes["Collection links<br/>[Node.java]"]
  node_cluster_nodes["Ballot links<br/>[Node.java]"]
end

subgraph group_contracts["API contracts"]
  node_file_contract["Reader contract"]
  node_collection_contract["Collection contract"]
  node_cluster_contract["Cluster contract"]
  node_ballot_contract["Ballot contract"]
  node_node_contract["Node contract<br/>[NodeInterface.java]"]
end

node_operator(("Operator"))
node_votes_csv["Ballot CSV<br/>[votes.csv]"]

node_operator -->|"runs"| node_harness
node_harness -->|"loads via"| node_file_handler
node_harness -->|"creates and tallies"| node_election
node_votes_csv -->|"supplies rows"| node_file_handler
node_file_handler -->|"adds ballots"| node_election
node_file_handler -->|"constructs"| node_ballot
node_election -->|"creates and searches"| node_candidate_cluster
node_election -->|"links candidates"| node_collection_nodes
node_candidate_cluster -->|"links ballots"| node_cluster_nodes
node_candidate_cluster -->|"transfers and counts"| node_ballot
node_harness -->|"prompts and reports"| node_operator

click node_votes_csv "https://github.com/bishesh009/assignment-2/blob/main/votes.csv"
click node_harness "https://github.com/bishesh009/assignment-2/blob/main/AssigTwo226.java"
click node_file_handler "https://github.com/bishesh009/assignment-2/blob/main/FileHandler.java"
click node_election "https://github.com/bishesh009/assignment-2/blob/main/Collection.java"
click node_ballot "https://github.com/bishesh009/assignment-2/blob/main/Ballot.java"
click node_candidate_cluster "https://github.com/bishesh009/assignment-2/blob/main/Cluster.java"
click node_collection_nodes "https://github.com/bishesh009/assignment-2/blob/main/Node.java"
click node_cluster_nodes "https://github.com/bishesh009/assignment-2/blob/main/Node.java"
click node_file_contract "https://github.com/bishesh009/assignment-2/blob/main/FileHandlerInterface.java"
click node_collection_contract "https://github.com/bishesh009/assignment-2/blob/main/CollectionInterface.java"
click node_cluster_contract "https://github.com/bishesh009/assignment-2/blob/main/ClusterInterface.java"
click node_ballot_contract "https://github.com/bishesh009/assignment-2/blob/main/BallotInterface.java"
click node_node_contract "https://github.com/bishesh009/assignment-2/blob/main/NodeInterface.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_harness,node_file_handler toneBlue
class node_election,node_ballot,node_candidate_cluster toneAmber
class node_collection_nodes,node_cluster_nodes toneMint
class node_file_contract,node_collection_contract,node_cluster_contract,node_ballot_contract,node_node_contract toneRose
class node_operator toneIndigo
class node_votes_csv toneTeal
```

## Components

### Election workflow

- [Program harness](https://github.com/bishesh009/assignment-2/blob/main/AssigTwo226.java): `AssigTwo226.java`
- [CSV reader](https://github.com/bishesh009/assignment-2/blob/main/FileHandler.java): `FileHandler.java`

### Election data

- [Election collection](https://github.com/bishesh009/assignment-2/blob/main/Collection.java): `Collection.java`
- [Ballot state](https://github.com/bishesh009/assignment-2/blob/main/Ballot.java): `Ballot.java`
- [Candidate cluster](https://github.com/bishesh009/assignment-2/blob/main/Cluster.java): `Cluster.java`

### Storage structures

- [Collection links](https://github.com/bishesh009/assignment-2/blob/main/Node.java): `Node.java`
- [Ballot links](https://github.com/bishesh009/assignment-2/blob/main/Node.java): `Node.java`

### API contracts

- [Reader contract](https://github.com/bishesh009/assignment-2/blob/main/FileHandlerInterface.java): `FileHandlerInterface.java`
- [Collection contract](https://github.com/bishesh009/assignment-2/blob/main/CollectionInterface.java): `CollectionInterface.java`
- [Cluster contract](https://github.com/bishesh009/assignment-2/blob/main/ClusterInterface.java): `ClusterInterface.java`
- [Ballot contract](https://github.com/bishesh009/assignment-2/blob/main/BallotInterface.java): `BallotInterface.java`
- [Node contract](https://github.com/bishesh009/assignment-2/blob/main/NodeInterface.java): `NodeInterface.java`

### Other components

- **Operator**
- [Ballot CSV](https://github.com/bishesh009/assignment-2/blob/main/votes.csv): `votes.csv`

## Connections

- Operator → Program harness: runs (evidence: `AssigTwo226.java`)
- Program harness → CSV reader: loads via (evidence: `AssigTwo226.java`)
- Program harness → Election collection: creates and tallies (evidence: `AssigTwo226.java`)
- Ballot CSV → CSV reader: supplies rows (evidence: `FileHandler.java`)
- CSV reader → Election collection: adds ballots (evidence: `FileHandler.java`)
- CSV reader → Ballot state: constructs (evidence: `FileHandler.java`)
- Election collection → Candidate cluster: creates and searches (evidence: `Collection.java`)
- Election collection → Collection links: links candidates (evidence: `Collection.java`)
- Candidate cluster → Ballot links: links ballots (evidence: `Cluster.java`)
- Candidate cluster → Ballot state: transfers and counts (evidence: `Cluster.java`)
- Program harness → Operator: prompts and reports (evidence: `AssigTwo226.java`)
