# soumilk/smart-package architecture

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

- Interactive diagram: https://gitdiagram.com/soumilk/smart-package
- Repository: https://github.com/soumilk/smart-package

## Overview

Perfect Package is a web-based food-packaging optimizer. A user enters product properties; the Python service reads them from Firebase, evaluates material suitability and package orientations, estimates costs, then writes recommendations and arrangement results for the website to display. The README documents this workflow and broader material-selection goals; sampled Python shows the Firebase reads, calculations, and writes. Front-end page roles and result-reading code are not sampled, so those links reflect documented behavior rather than verified client-side calls.

Main entry points: [`packing.py`](https://github.com/soumilk/smart-package/blob/master/packing.py) (Packing service), [`codebase.py`](https://github.com/soumilk/smart-package/blob/master/codebase.py) (Material matching), [`new.html`](https://github.com/soumilk/smart-package/blob/master/new.html) (Product form), [`orientation.py`](https://github.com/soumilk/smart-package/blob/master/orientation.py) (Orientation analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_landing["Landing page<br/>[index.html]"]
  node_product_form["Product form<br/>[new.html]"]
  node_form_controls["Form controls<br/>[new.js]"]
  node_result_pages["Results pages<br/>[secondary.html]"]
  node_additional_results["Additional results<br/>[tertiary.html]"]
end

subgraph group_analysis["Packaging analysis"]
  node_material_match["Material matching<br/>[codebase.py]"]
  node_material_catalog["Material properties<br/>[codebase.py]"]
  node_orientation["Orientation analysis<br/>[orientation.py]"]
  node_arrangement_results["Arrangement results<br/>[orientation.py]"]
end

subgraph group_backend["Results service"]
  node_service["Packing service<br/>[packing.py]"]
  node_cost_rank["Cost ranking<br/>[packing.py]"]
end

node_user(("Product designer"))
node_firebase[("Firebase data")]

node_user -->|"opens"| node_landing
node_landing -->|"opens"| node_product_form
node_product_form -->|"uses controls"| node_form_controls
node_product_form -->|"submits properties"| node_firebase
node_service -->|"polls inputs"| node_firebase
node_service -->|"imports and uses"| node_material_match
node_material_match -->|"reads properties"| node_firebase
node_material_match -->|"compares against"| node_material_catalog
node_service -->|"imports and uses"| node_orientation
node_orientation -->|"reads properties"| node_firebase
node_orientation -->|"produces"| node_arrangement_results
node_service -->|"ranks costs"| node_cost_rank
node_cost_rank -->|"uses candidates"| node_material_match
node_cost_rank -->|"uses areas"| node_arrangement_results
node_service -->|"writes results"| node_firebase
node_result_pages -.->|"reads results"| node_firebase
node_additional_results -.->|"reads results"| node_firebase

click node_landing "https://github.com/soumilk/smart-package/blob/master/index.html"
click node_product_form "https://github.com/soumilk/smart-package/blob/master/new.html"
click node_form_controls "https://github.com/soumilk/smart-package/blob/master/new.js"
click node_result_pages "https://github.com/soumilk/smart-package/blob/master/secondary.html"
click node_additional_results "https://github.com/soumilk/smart-package/blob/master/tertiary.html"
click node_service "https://github.com/soumilk/smart-package/blob/master/packing.py"
click node_material_match "https://github.com/soumilk/smart-package/blob/master/codebase.py"
click node_material_catalog "https://github.com/soumilk/smart-package/blob/master/codebase.py"
click node_orientation "https://github.com/soumilk/smart-package/blob/master/orientation.py"
click node_cost_rank "https://github.com/soumilk/smart-package/blob/master/packing.py"
click node_arrangement_results "https://github.com/soumilk/smart-package/blob/master/orientation.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_landing,node_product_form,node_form_controls,node_result_pages,node_additional_results toneBlue
class node_material_match,node_material_catalog,node_orientation,node_arrangement_results,node_firebase toneAmber
class node_service,node_cost_rank toneMint
class node_user toneIndigo
```

## Components

### Web experience

- [Landing page](https://github.com/soumilk/smart-package/blob/master/index.html): `index.html`
- [Product form](https://github.com/soumilk/smart-package/blob/master/new.html): `new.html`
- [Form controls](https://github.com/soumilk/smart-package/blob/master/new.js): `new.js`
- [Results pages](https://github.com/soumilk/smart-package/blob/master/secondary.html): `secondary.html`
- [Additional results](https://github.com/soumilk/smart-package/blob/master/tertiary.html): `tertiary.html`

### Packaging analysis

- [Material matching](https://github.com/soumilk/smart-package/blob/master/codebase.py): `codebase.py`
- [Material properties](https://github.com/soumilk/smart-package/blob/master/codebase.py): `codebase.py`
- [Orientation analysis](https://github.com/soumilk/smart-package/blob/master/orientation.py): `orientation.py`
- [Arrangement results](https://github.com/soumilk/smart-package/blob/master/orientation.py): `orientation.py`

### Results service

- [Packing service](https://github.com/soumilk/smart-package/blob/master/packing.py): `packing.py`
- [Cost ranking](https://github.com/soumilk/smart-package/blob/master/packing.py): `packing.py`

### Other components

- **Product designer**
- **Firebase data**

## Connections

- Product designer → Landing page: opens
- Landing page → Product form: opens
- Product form → Form controls: uses controls
- Product form → Firebase data: submits properties
- Packing service → Firebase data: polls inputs
- Packing service → Material matching: imports and uses
- Material matching → Firebase data: reads properties
- Material matching → Material properties: compares against
- Packing service → Orientation analysis: imports and uses
- Orientation analysis → Firebase data: reads properties
- Orientation analysis → Arrangement results: produces
- Packing service → Cost ranking: ranks costs
- Cost ranking → Material matching: uses candidates
- Cost ranking → Arrangement results: uses areas
- Packing service → Firebase data: writes results
- Results pages → Firebase data: reads results
- Additional results → Firebase data: reads results
