How eliotmortimore/production_line works
Project Type & Purpose
• Type: Monolithic, CLI-based simulation tool
• Purpose: Simulate a multi-stage manufacturing line (Forming → CNC → Buffing → Completed), let the user step through “turns,” adjust parameters, and observe bottlenecks/throughput.
File Structure
• production_line.py – Contains the main loop, CLI parsing, display logic, simulation engine.
• variables.py – Holds all global state and configuration (queues, min/max ranges, turn count).
There are no external services, databases, or separate front/back ends. Everything runs in one process and outputs to the terminal.
Architectural Patterns
• Pipeline (queue → process → next queue) for each stage.
• MVC-ish separation:
– Model: variables.py (state + config)
– Controller/Engine: simulation logic in production_line.py
• Command-pattern for user interactions (Enter, run, settings, reset, quit).
Main Components
1) User & CLI Interface
– Accepts keystrokes/commands
– Passes control to the simulation engine or settings module
2) Simulation Engine
– Orchestrates one “turn”:
a) Injects new raw materials into Forming queue
b) Processes Forming → CNC → Buffing → Completed using randomized outputs
c) Updates global state (queues, totals, turn counter)
3) Configuration Store
– variables.py module: holds materials-per-turn, stage min/max, current queues, etc.
– Read/Write by Engine and Settings UI
4) Terminal Dashboard Renderer
– Updates on demand or each turn
(Optional: break out Settings Menu logic as a sub-component of the CLI.)
Relationships & Data Flows
• User Input → CLI Interface →
• either Settings Menu → updates Configuration Store
• or “Advance Turn” → Simulation Engine
• Simulation Engine reads Configuration Store, updates queues & counters in Configuration Store
• Terminal Renderer reads Configuration Store after each turn or on “show” → redraws dashboard
– Control flow from User to CLI → Engine/Settings → Store → Renderer → User
Architectural Patterns & Principles
• Single Responsibility: each module handles one concern (state, logic, UI)
• Pipeline Pattern: clearly show how items flow through each stage queue
• Stateless engine logic (stateless between turns except via the global state container)
• Extensibility: adding new stages is just adding another queue + process step
Technologies & Frameworks
• Python 3.10+
• Built-in modules only: os, random
• No external dependencies
Final Checklist
• [ ] All modules/components labeled
• [ ] Arrowheads indicate flow & direction
• [ ] Pipeline of stages laid out in the center as the “heart” of the system