# bilistic/knapsack_solutions architecture

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

- Interactive diagram: https://gitdiagram.com/bilistic/knapsack_solutions
- Repository: https://github.com/bilistic/knapsack_solutions

## Overview

This repository combines a knapsack-algorithm benchmark generator with a small Flask results viewer. The principal workflow generates task sets, runs several solvers and records timing/results in an Excel workbook; the viewer reads that workbook and serves raw or per-node-count averages to a page. The README also documents comparative analysis of Greedy, Generate & Test, Branch and Bound, and Backtracking. Source excerpts do not show the template’s client-side behavior, so no browser-to-endpoint interaction is asserted.

Main entry points: [`Knapsack_Problem.py`](https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py) (Benchmark runner), [`DataServer.py`](https://github.com/bilistic/knapsack_solutions/blob/master/DataServer.py) (Flask routes), [`Main.cpp`](https://github.com/bilistic/knapsack_solutions/blob/master/Main.cpp) (C++ solver examples), [`templates/data.html`](https://github.com/bilistic/knapsack_solutions/blob/master/templates/data.html) (HTML page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_benchmark["Benchmark and solvers"]
  node_tasks["Task generation"]
  node_greedy["Greedy solver"]
  node_exact["Exact solvers"]
  node_benchmark_run["Benchmark runner"]
  node_workbook[("Results workbook")]
  node_cpp_solvers["C++ solver examples<br/>[Main.cpp]"]
end

subgraph group_viewer["Results viewer"]
  node_flask["Flask routes<br/>[DataServer.py]"]
  node_aggregation["Average aggregation<br/>[DataServer.py]"]
  node_template["HTML page<br/>[data.html]"]
  node_style["Page styling<br/>[style2.css]"]
end

node_engineer(("User"))

node_engineer -->|"runs benchmark"| node_benchmark_run
node_benchmark_run -->|"generates tasks"| node_tasks
node_benchmark_run -->|"runs solver"| node_greedy
node_benchmark_run -->|"runs solvers"| node_exact
node_benchmark_run -->|"writes results"| node_workbook
node_engineer -.->|"requests page/data"| node_flask
node_flask -->|"renders page"| node_template
node_flask -->|"reads workbook"| node_workbook
node_flask -->|"computes averages"| node_aggregation
node_cpp_solvers -.->|"implements algorithms"| node_cpp_solvers

click node_tasks "https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py"
click node_greedy "https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py"
click node_exact "https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py"
click node_benchmark_run "https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py"
click node_cpp_solvers "https://github.com/bilistic/knapsack_solutions/blob/master/Main.cpp"
click node_flask "https://github.com/bilistic/knapsack_solutions/blob/master/DataServer.py"
click node_aggregation "https://github.com/bilistic/knapsack_solutions/blob/master/DataServer.py"
click node_template "https://github.com/bilistic/knapsack_solutions/blob/master/templates/data.html"
click node_style "https://github.com/bilistic/knapsack_solutions/blob/master/static/style2.css"

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_tasks,node_greedy,node_exact,node_benchmark_run,node_workbook,node_cpp_solvers,node_engineer toneBlue
class node_flask,node_aggregation,node_template,node_style toneAmber
```

## Components

### Benchmark and solvers

- [Task generation](https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py): `Knapsack_Problem.py`
- [Greedy solver](https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py): `Knapsack_Problem.py`
- [Exact solvers](https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py): `Knapsack_Problem.py`
- [Benchmark runner](https://github.com/bilistic/knapsack_solutions/blob/master/Knapsack_Problem.py): `Knapsack_Problem.py`
- **Results workbook**
- [C++ solver examples](https://github.com/bilistic/knapsack_solutions/blob/master/Main.cpp): `Main.cpp`

### Results viewer

- [Flask routes](https://github.com/bilistic/knapsack_solutions/blob/master/DataServer.py): `DataServer.py`
- [Average aggregation](https://github.com/bilistic/knapsack_solutions/blob/master/DataServer.py): `DataServer.py`
- [HTML page](https://github.com/bilistic/knapsack_solutions/blob/master/templates/data.html): `templates/data.html`
- [Page styling](https://github.com/bilistic/knapsack_solutions/blob/master/static/style2.css): `static/style2.css`

### Other components

- **User**

## Connections

- User → Benchmark runner: runs benchmark (evidence: `Knapsack_Problem.py`)
- Benchmark runner → Task generation: generates tasks (evidence: `Knapsack_Problem.py`)
- Benchmark runner → Greedy solver: runs solver (evidence: `Knapsack_Problem.py`)
- Benchmark runner → Exact solvers: runs solvers (evidence: `Knapsack_Problem.py`)
- Benchmark runner → Results workbook: writes results (evidence: `Knapsack_Problem.py`)
- User → Flask routes: requests page/data
- Flask routes → HTML page: renders page (evidence: `DataServer.py`)
- Flask routes → Results workbook: reads workbook (evidence: `DataServer.py`)
- Flask routes → Average aggregation: computes averages (evidence: `DataServer.py`)
- C++ solver examples → C++ solver examples: implements algorithms (evidence: `Main.cpp`)
