# dnbhatt1991/courierapp architecture

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

- Interactive diagram: https://gitdiagram.com/dnbhatt1991/courierapp
- Repository: https://github.com/dnbhatt1991/courierapp

## Overview

CourierApp is a console tool that reads package records from a file or standard input, calculates each package’s discount and discounted cost, sorts the results by cost, and prints formatted rows. The main runtime stages are input selection and parsing, discount/result processing, sorter selection and ordering, and output. The README also documents QuickSorter as the default and BubbleSorter as an option. The graph follows the supplied entry-point and service source; no persistent store or external service is shown.

Main entry points: [`CourierApp/Program.cs`](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Program.cs) (Console entry point), [`CourierApp/Services/SortService.cs`](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/SortService.cs) (Sort service), [`CourierApp/Services/SorterFactory.cs`](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/SorterFactory.cs) (Sorter factory), [`CourierApp/Services/PackageDiscountCalculator.cs`](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/PackageDiscountCalculator.cs) (Discount calculator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input"]
  node_input_source["File or stdin"]
  node_program["Console entry point<br/>[Program.cs]"]
  node_package["Package<br/>[Package.cs]"]
end

subgraph group_processing["Discount Processing"]
  node_sort_service["Sort service<br/>[SortService.cs]"]
  node_discount_calculator["Discount calculator"]
  node_package_result["Package result<br/>[PackageResult.cs]"]
end

subgraph group_sorting["Sorting"]
  node_sorter_factory["Sorter factory<br/>[SorterFactory.cs]"]
  node_quick_sorter["Quick sorter<br/>[QuickSorter.cs]"]
  node_bubble_sorter["Bubble sorter<br/>[BubbleSorter.cs]"]
end

node_user(("CLI user"))
node_output(("Console output"))

node_user -->|"runs with args"| node_program
node_program -->|"reads lines"| node_input_source
node_program -->|"parses records"| node_package
node_program -->|"selects sorter"| node_sorter_factory
node_sorter_factory -->|"resolves default"| node_quick_sorter
node_sorter_factory -->|"resolves option"| node_bubble_sorter
node_program -->|"processes packages"| node_sort_service
node_sort_service -->|"calculates discount"| node_discount_calculator
node_discount_calculator -->|"reads package fields"| node_package
node_sort_service -->|"creates results"| node_package_result
node_sort_service -->|"sorts by cost"| node_quick_sorter
node_program -->|"prints results"| node_output

click node_program "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Program.cs"
click node_package "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Models/Package.cs"
click node_sort_service "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/SortService.cs"
click node_discount_calculator "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/PackageDiscountCalculator.cs"
click node_package_result "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Models/PackageResult.cs"
click node_sorter_factory "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/SorterFactory.cs"
click node_quick_sorter "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/QuickSorter.cs"
click node_bubble_sorter "https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/BubbleSorter.cs"

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_input_source,node_program,node_package,node_user toneBlue
class node_sort_service,node_discount_calculator,node_package_result toneAmber
class node_sorter_factory,node_quick_sorter,node_bubble_sorter toneMint
class node_output toneIndigo
```

## Components

### Input

- **File or stdin**
- [Console entry point](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Program.cs): `CourierApp/Program.cs`
- [Package](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Models/Package.cs): `CourierApp/Models/Package.cs`

### Discount Processing

- [Sort service](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/SortService.cs): `CourierApp/Services/SortService.cs`
- [Discount calculator](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/PackageDiscountCalculator.cs): `CourierApp/Services/PackageDiscountCalculator.cs`
- [Package result](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Models/PackageResult.cs): `CourierApp/Models/PackageResult.cs`

### Sorting

- [Sorter factory](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/SorterFactory.cs): `CourierApp/Services/SorterFactory.cs`
- [Quick sorter](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/QuickSorter.cs): `CourierApp/Services/QuickSorter.cs`
- [Bubble sorter](https://github.com/dnbhatt1991/courierapp/blob/main/CourierApp/Services/BubbleSorter.cs): `CourierApp/Services/BubbleSorter.cs`

### Other components

- **CLI user**
- **Console output**

## Connections

- CLI user → Console entry point: runs with args
- Console entry point → File or stdin: reads lines
- Console entry point → Package: parses records
- Console entry point → Sorter factory: selects sorter
- Sorter factory → Quick sorter: resolves default
- Sorter factory → Bubble sorter: resolves option
- Console entry point → Sort service: processes packages
- Sort service → Discount calculator: calculates discount
- Discount calculator → Package: reads package fields
- Sort service → Package result: creates results
- Sort service → Quick sorter: sorts by cost
- Console entry point → Console output: prints results
