How chaharudin202-rgb/paper-bag-calculator works
This repo is a single-service Streamlit web application (an MVP) that runs locally (or on a simple PaaS) and provides:
• Cost/quotation calculation for paper bag production
• Plano nesting/layout optimization (maximize pieces per sheet, include 90° rotation)
• 2D technical pattern generation (Matplotlib)
• 3D mockup preview (Plotly)
There’s no evidence of a separate backend, database, message bus, or multi-service topology. The “system” is essentially a Python app process with UI + domain logic + visualization, invoked by an end user in a browser.
File-tree driven architecture reading (what to extract into components)
From the tree:
• app.py
Likely the primary Streamlit entrypoint (UI + orchestration). This is the “web server” process for Streamlit.
• en_app.py
Likely an English variant of the UI (or alternate entrypoint). Treat as either:
• a second entrypoint (two deployable variants), or
• a language-specific UI module (same app, different locale).
• requirements.txt
Dependencies boundary: Streamlit, Matplotlib, Plotly, plus any numeric libs.
• .devcontainer/devcontainer.json
• LICENSE, README.md
Not runtime components.
Domain / Core Logic
• Cost Calculator
• Inputs: quantity, paper cost, print cost, finishing, etc.
• Outputs: cost breakdown + final price/quote
• Plano Optimizer (Nesting Algorithm)
• Inputs: plano size, bag pattern footprint, rotation allowed
• Outputs: pieces-per-sheet, layout plan, waste/efficiency metrics
• Pattern Generator (2D)
• Inputs: bag dimensions (L/W/H)
• Outputs: 2D technical pattern geometry (lines/polygons), ready for Matplotlib render
• 3D Model Builder
• Inputs: bag dimensions and/or pattern
• Outputs: 3D mesh/plot primitives for Plotly
Visualization / Rendering
• Matplotlib Renderer
• Consumes 2D pattern geometry
• Produces figure displayed in Streamlit
• Plotly Renderer
• Consumes 3D model primitives
• Produces interactive 3D view embedded in Streamlit
Runtime / Hosting (minimal but include it)
• Python Runtime / Streamlit Server Process
• Single process handling UI + compute
• Localhost :8501 by default
Only if the project is deployed there; README suggests local run, but the devcontainer hints container-based dev.
External dependencies (as “supporting systems”)
From README:
• Streamlit
• Matplotlib
• Plotly
(Plus any typical numeric stack inferred from requirements—only include if actually present once you open requirements.txt.)
User Browser → Streamlit UI
• “Enter dimensions, quantity, costs”
Streamlit UI → Domain Logic
• Calls:
• Cost Calculator
• Plano Optimizer
• Pattern Generator (2D)
• 3D Model Builder
Domain Logic → Visualization
• Pattern Generator → Matplotlib Renderer → Streamlit UI (figure)
• 3D Model Builder → Plotly Renderer → Streamlit UI (interactive 3D)
Domain Logic → Streamlit UI
• Cost breakdown results to tables/metrics
Streamlit UI → User Browser
• Rendered outputs
• BagDimensions{L,W,H}
• PlanoSheet{width,height}
• CostConfig{paper,print,finishing}
• PatternGeometry
• LayoutPlan
• CostBreakdown
• PlotlyFigure / MatplotlibFigure
User ↔ Streamlit App (Python) ↔ Visualization libs (supporting)
Break Streamlit App into: UI, optimizer, cost engine, 2D generator, 3D generator, renderers.
Also explicitly represent en_app.py as:
• either “Alternative UI entrypoint (English)” with a note “shares same logic” (if true),
• or “Separate deployment variant” (if it’s meant to be run separately).