# eliotmortimore/production_line architecture

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

- Interactive diagram: https://gitdiagram.com/eliotmortimore/production_line
- Repository: https://github.com/eliotmortimore/production_line

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User["User"]:::user
    CLI["CLI Interface"]:::code
    Settings["Settings Menu"]:::code
    README["Documentation (README.md)"]:::doc

    %% Core Modules
    Engine["Simulation Engine"]:::code
    Config["Configuration Store\n(variables.py)"]:::code
    Renderer["Terminal Dashboard Renderer"]:::code

    %% Pipeline Stages
    subgraph "Processing Pipeline"
        direction TB
        Raw["Raw Materials\n(injection)"]:::stage
        Forming["Forming Stage\n(queue)"]:::stage
        CNC["CNC Stage\n(queue)"]:::stage
        Buffing["Buffing Stage\n(queue)"]:::stage
        Completed["Completed Stage\n(queue)"]:::stage
    end

    %% Connections
    User -->|"keystrokes/commands"| CLI
    CLI -->|"open settings"| Settings
    CLI -->|"advance turn"| Engine
    CLI -->|"view docs"| README

    Settings -->|"update config"| Config

    Engine -->|"read/write state"| Config
    Engine -->|"inject materials"| Raw
    Raw -->|"enqueue items"| Forming
    Forming -->|"process items\n(random min/max)"| CNC
    CNC -->|"process items\n(random min/max)"| Buffing
    Buffing -->|"process items\n(random min/max)"| Completed
    Completed -->|"update totals"| Config

    Config -->|"state snapshot"| Renderer
    Renderer -->|"render dashboard"| User

    %% Click Events
    click CLI "https://github.com/eliotmortimore/production_line/blob/main/production_line.py"
    click Settings "https://github.com/eliotmortimore/production_line/blob/main/production_line.py"
    click Engine "https://github.com/eliotmortimore/production_line/blob/main/production_line.py"
    click Renderer "https://github.com/eliotmortimore/production_line/blob/main/production_line.py"
    click Config "https://github.com/eliotmortimore/production_line/blob/main/variables.py"
    click README "https://github.com/eliotmortimore/production_line/blob/main/README.md"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#0000FF,color:#000000
    classDef stage fill:#90EE90,stroke:#008000,color:#000000
    classDef user fill:#FFA500,stroke:#FF8C00,color:#000000
    classDef doc fill:#FFFFE0,stroke:#CCCC00,color:#000000
```
