# tekshteint/shiftplotter architecture

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

- Interactive diagram: https://gitdiagram.com/tekshteint/shiftplotter
- Repository: https://github.com/tekshteint/shiftplotter

## Overview

##### Project type and purpose
- It takes user input (gear ratios, tire size, final drive ratios, or an existing file), computes speed vs. RPM for each gear, and renders a plot (on screen or as files in MatPlotLib’s formats or GML).

##### File structure
- Top level:
- shiftPlotter.py – contains all logic (CLI parsing, computation, plotting, exporting)
- README.md – usage, flags, example
- .gitignore / .gitattributes – standard repo configs
- No frontend/backend distinction – it’s a single-process CLI utility with internal modules (all in one file).

##### README for additional insights
- Flags handled:
- --save “filename.gml” → export a GML graph file
- --open “filename.gml” → re-open an existing graph
- Primary external libraries implied: MatPlotLib, possibly NetworkX (for GML export)

A. Command-Line Interface (argparse)
B. Input Loader / Parser (parses --open GML if requested)
C. Calculation Engine (computes RPM vs. speed trajectories per gear)
D. Plot Generator
- Delegates to MatPlotLib
E. GML Exporter / Importer
- Delegates to NetworkX or custom routines
F. Output Renderer
- On-screen interactive window or saved image (PNG/GML)

##### Relationships & data flow
- User → (1) CLI Parser
- CLI Parser → (2a) Input Loader OR (2b) Calculation Engine
- Calculation Engine → Plot Generator
- Plot Generator → MatPlotLib → Output Renderer
- CLI Parser → GML Exporter → File System (save .gml)
- File System → GML Importer → Calculation Engine (on --open)

##### Architectural patterns / design principles
- Single process, modular functional decomposition
- Clear separation between “compute” and “render”
- Extensibility point: add new exporters (e.g., SVG) or input file formats
- No persistent state beyond local files; stateless per invocation

##### Relevant technologies / libraries
- Python 3.x standard library: argparse, sys, math
- MatPlotLib for plotting
- (Optionally) NetworkX or built-in GML routines for file export/import

- Clear, concise labels for each internal module
- Internal modules (e.g., blue rectangles)
- External libraries (green rounded rectangles)

##### Final advice
- Be exhaustive but not overly granular—group related functions into these high-level components.
- Every logical step from user invocation to final output.
- Extensibility: if someone wants to add a new file format, where would it plug in?

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Layer"
        CLI["Command-Line Interface\n(argparse)"]:::internal
    end
    subgraph "Modules"
        Input["Input Loader / Parser"]:::internal
        Calc["Calculation Engine"]:::internal
        Plot["Plot Generator"]:::internal
        GMLExp["GML Exporter / Importer"]:::internal
        Render["Output Renderer"]:::internal
    end
    subgraph "External Libraries"
        Matplotlib["MatPlotLib"]:::external
        NetworkX["NetworkX"]:::external
    end
    FS[(GML File)]:::datastore
    subgraph "Project Documentation"
        README["README.md"]:::doc
        Gitignore[".gitignore"]:::doc
        Gitattributes[".gitattributes"]:::doc
    end

    CLI -->|"argv →"| Input
    CLI -->|"flags →"| GMLExp
    CLI -->|"compute →"| Calc
    Input -->|"open GML → graph"| Calc
    Calc -->|"RPM data →"| Plot
    Plot --> Matplotlib
    Plot -->|"plot →"| Render
    GMLExp -->|"export GML →"| FS
    Render -->|"display/save"| FS
    FS -->|"import GML →"| Input
    GMLExp -->|"uses"| NetworkX

    click CLI "https://github.com/tekshteint/shiftplotter/blob/main/shiftPlotter.py"
    click Input "https://github.com/tekshteint/shiftplotter/blob/main/shiftPlotter.py"
    click Calc "https://github.com/tekshteint/shiftplotter/blob/main/shiftPlotter.py"
    click Plot "https://github.com/tekshteint/shiftplotter/blob/main/shiftPlotter.py"
    click GMLExp "https://github.com/tekshteint/shiftplotter/blob/main/shiftPlotter.py"
    click Render "https://github.com/tekshteint/shiftplotter/blob/main/shiftPlotter.py"
    click README "https://github.com/tekshteint/shiftplotter/blob/main/README.md"
    click Gitignore "https://github.com/tekshteint/shiftplotter/blob/main/.gitignore"
    click Gitattributes "https://github.com/tekshteint/shiftplotter/blob/main/.gitattributes"

    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    classDef datastore fill:#FFD580,stroke:#000,stroke-width:1px
    classDef doc fill:#D3D33,font-style:italic,stroke:#000,stroke-width:1px
```
