# codedbankai/ecopack_deploy architecture

> Architecture diagram of the GitHub repository codedbankai/ecopack_deploy, 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/codedbankai/ecopack_deploy
- Repository: https://github.com/codedbankai/ecopack_deploy

## Overview

This is a Flask service for recommending sustainable packaging. A user supplies product category, subcategory, weight, fragility, and eco preference; the service scores candidate materials using trained cost and CO₂ models, returns the top recommendations, and attempts to save the leading result to PostgreSQL. The graph follows the calls visible in app.py. The template and model artifacts are present in the tree, but their internals and the template’s request wiring were not sampled.

Main entry points: [`app.py`](https://github.com/codedbankai/ecopack_deploy/blob/main/app.py) (Recommendation logic), [`templates/index.html`](https://github.com/codedbankai/ecopack_deploy/blob/main/templates/index.html) (Recommendation page), [`final_engineered_dataset.csv`](https://github.com/codedbankai/ecopack_deploy/blob/main/final_engineered_dataset.csv) (Candidate dataset), [`le_cat.pkl`](https://github.com/codedbankai/ecopack_deploy/blob/main/le_cat.pkl) (Category encoders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_webapp["Flask routes<br/>[app.py]"]
  node_page["Recommendation page<br/>[index.html]"]
end

subgraph group_recommend["Recommendation"]
  node_logic["Recommendation logic<br/>[app.py]"]
  node_dataset[("Candidate dataset")]
end

subgraph group_models["Prediction models"]
  node_encoders["Category encoders<br/>[le_cat.pkl]"]
  node_subencoder["Subcategory encoder<br/>[le_sub.pkl]"]
  node_pipeline["Feature pipeline<br/>[pipeline.pkl]"]
  node_costmodel["Cost model<br/>[rf_cost_model.pkl]"]
  node_co2model["CO2 model<br/>[xgb_co2_model.pkl]"]
end

subgraph group_history["History storage"]
  node_historymodel["History model<br/>[app.py]"]
  node_postgres[("PostgreSQL")]
end

node_user(("User"))

node_user -.->|"submits request"| node_webapp
node_webapp -->|"renders"| node_page
node_page -.->|"sends request"| node_webapp
node_webapp -->|"gets recommendations"| node_logic
node_logic -->|"reads candidates"| node_dataset
node_logic -->|"encodes category"| node_encoders
node_logic -->|"encodes subcategory"| node_subencoder
node_logic -->|"transforms features"| node_pipeline
node_logic -->|"predicts cost"| node_costmodel
node_logic -->|"predicts CO2"| node_co2model
node_logic -->|"returns results"| node_webapp
node_webapp -->|"creates entry"| node_historymodel
node_historymodel -->|"commits history"| node_postgres

click node_webapp "https://github.com/codedbankai/ecopack_deploy/blob/main/app.py"
click node_page "https://github.com/codedbankai/ecopack_deploy/blob/main/templates/index.html"
click node_logic "https://github.com/codedbankai/ecopack_deploy/blob/main/app.py"
click node_dataset "https://github.com/codedbankai/ecopack_deploy/blob/main/final_engineered_dataset.csv"
click node_encoders "https://github.com/codedbankai/ecopack_deploy/blob/main/le_cat.pkl"
click node_subencoder "https://github.com/codedbankai/ecopack_deploy/blob/main/le_sub.pkl"
click node_pipeline "https://github.com/codedbankai/ecopack_deploy/blob/main/pipeline.pkl"
click node_costmodel "https://github.com/codedbankai/ecopack_deploy/blob/main/rf_cost_model.pkl"
click node_co2model "https://github.com/codedbankai/ecopack_deploy/blob/main/xgb_co2_model.pkl"
click node_historymodel "https://github.com/codedbankai/ecopack_deploy/blob/main/app.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_webapp,node_page,node_user toneBlue
class node_logic,node_dataset toneAmber
class node_encoders,node_subencoder,node_pipeline,node_costmodel,node_co2model toneMint
class node_historymodel,node_postgres toneRose
```

## Components

### Web interface

- [Flask routes](https://github.com/codedbankai/ecopack_deploy/blob/main/app.py): `app.py`
- [Recommendation page](https://github.com/codedbankai/ecopack_deploy/blob/main/templates/index.html): `templates/index.html`

### Recommendation

- [Recommendation logic](https://github.com/codedbankai/ecopack_deploy/blob/main/app.py): `app.py`
- [Candidate dataset](https://github.com/codedbankai/ecopack_deploy/blob/main/final_engineered_dataset.csv): `final_engineered_dataset.csv`

### Prediction models

- [Category encoders](https://github.com/codedbankai/ecopack_deploy/blob/main/le_cat.pkl): `le_cat.pkl`
- [Subcategory encoder](https://github.com/codedbankai/ecopack_deploy/blob/main/le_sub.pkl): `le_sub.pkl`
- [Feature pipeline](https://github.com/codedbankai/ecopack_deploy/blob/main/pipeline.pkl): `pipeline.pkl`
- [Cost model](https://github.com/codedbankai/ecopack_deploy/blob/main/rf_cost_model.pkl): `rf_cost_model.pkl`
- [CO2 model](https://github.com/codedbankai/ecopack_deploy/blob/main/xgb_co2_model.pkl): `xgb_co2_model.pkl`

### History storage

- [History model](https://github.com/codedbankai/ecopack_deploy/blob/main/app.py): `app.py`
- **PostgreSQL**

### Other components

- **User**

## Connections

- User → Flask routes: submits request
- Flask routes → Recommendation page: renders (evidence: `app.py`)
- Recommendation page → Flask routes: sends request
- Flask routes → Recommendation logic: gets recommendations (evidence: `app.py`)
- Recommendation logic → Candidate dataset: reads candidates (evidence: `app.py`)
- Recommendation logic → Category encoders: encodes category (evidence: `app.py`)
- Recommendation logic → Subcategory encoder: encodes subcategory (evidence: `app.py`)
- Recommendation logic → Feature pipeline: transforms features (evidence: `app.py`)
- Recommendation logic → Cost model: predicts cost (evidence: `app.py`)
- Recommendation logic → CO2 model: predicts CO2 (evidence: `app.py`)
- Recommendation logic → Flask routes: returns results (evidence: `app.py`)
- Flask routes → History model: creates entry (evidence: `app.py`)
- History model → PostgreSQL: commits history (evidence: `app.py`)
