# bonsaijoe878/portfolio2 architecture

> Architecture diagram of the GitHub repository bonsaijoe878/portfolio2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bonsaijoe878/portfolio2
- Repository: https://github.com/bonsaijoe878/portfolio2

## Overview

This repository appears to be a small Python application for solving a transport-routing problem, likely centered on computing routes over a graph and then presenting the result visually.

1. **Overall shape**
   - The project is organized as a single Python pipeline rather than a multi-service system.
   - The core flow is: **load or build transport data → represent it as graph/matrix structures → run a TSP-style solver → produce an output map or visualization**.

2. **Entry point**
   - `main.py` is the orchestration layer.
   - It likely wires together the transport model, solver, and output generation.
   - For an architecture diagram, treat this as the application boundary where execution starts.

3. **Transport domain model**
   - `transport_graph.py` is the graph-based representation of the transport network.
   - It likely models nodes, edges, and distances/costs between locations.
   - This is the primary domain abstraction if the problem is expressed as a route network.

4. **Matrix representation**
   - `transport_matrix.py` likely provides an adjacency or cost matrix derived from the graph.
   - This suggests the solver may prefer matrix-based access for distance lookups or optimization.
   - In the diagram, this is a transformation layer between graph data and the algorithm.

5. **Optimization / route solving**
   - `tsp_solver.py` is the algorithmic core.
   - The file name strongly suggests a Traveling Salesman Problem solver or a close variant.
   - This component probably consumes the matrix or graph-derived distances and outputs an ordered route.

6. **Local business rules**
   - `local_logic.py` likely contains problem-specific rules, heuristics, or glue code that are not generic graph/solver logic.
   - This is where application-specific decisions probably live, such as filtering nodes, selecting a starting point, or adapting solver results.

7. **Output / visualization**
   - `map_output.py` is the presentation/export boundary.
   - It likely renders the computed route onto a map, or writes an artifact that can be viewed externally.
   - This is the final stage of the pipeline and separates computation from presentation.

8. **Data flow between modules**
   - A typical flow is:
     - `main.py` initializes the run
     - `transport_graph.py` captures the network
     - `transport_matrix.py` extracts the cost structure
     - `tsp_solver.py` computes the best route
     - `map_output.py` formats the result for display or export
   - `local_logic.py` likely influences multiple stages, especially preprocessing and postprocessing.

9. **Likely architecture boundaries**
   - **Input/model boundary:** transport data becomes a graph
   - **Algorithm boundary:** the solver operates on a normalized matrix or graph abstraction
   - **Presentation boundary:** route results become a map or output artifact
   - These are the main layers to show in a diagram.

10. **Technology profile**
   - The repository is Python-based.
   - There is no sign of a web framework, database, or distributed infrastructure from the file list alone.
   - This looks like a self-contained analytical/optimization tool rather than a service application.

11. **What to emphasize in a diagram**
   - Put `main.py` at the top as the orchestrator.
   - Show `transport_graph.py` and `transport_matrix.py` as core domain/data transformation modules.
   - Place `tsp_solver.py` as the central computation engine.
   - Show `map_output.py` as the terminal output layer.
   - `local_logic.py` should be shown as a supporting rules/coordination module feeding into the pipeline.

12. **Confidence note**
   - This architecture is inferred from filenames and repository shape only, since the README contains no additional detail.
   - The structure strongly suggests a route-optimization project with graph/matrix modeling and a TSP-style solver.

Main entry points: [`local_logic.py`](https://github.com/bonsaijoe878/portfolio2/blob/main/local_logic.py) (Local Logic), [`tsp_solver.py`](https://github.com/bonsaijoe878/portfolio2/blob/main/tsp_solver.py) (TSP Solver), [`main.py`](https://github.com/bonsaijoe878/portfolio2/blob/main/main.py) (Main), [`map_output.py`](https://github.com/bonsaijoe878/portfolio2/blob/main/map_output.py) (Map Output)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_main["Main<br/>orchestrator<br/>[main.py]"]
node_logic["Local Logic<br/>rules<br/>[local_logic.py]"]
node_graph[("Transport Graph<br/>domain graph<br/>[transport_graph.py]")]
node_matrix[("Transport Matrix<br/>cost matrix")]
node_solver["TSP Solver<br/>optimizer<br/>[tsp_solver.py]"]
node_output["Map Output<br/>presentation<br/>[map_output.py]"]

node_main -->|"uses"| node_logic
node_main -->|"loads"| node_graph
node_graph -->|"derives"| node_matrix
node_matrix -->|"feeds"| node_solver
node_logic -->|"guides"| node_solver
node_solver -->|"returns"| node_logic
node_solver -->|"routes"| node_output
node_logic -->|"formats"| node_output
node_main -->|"emits"| node_output

click node_main "https://github.com/bonsaijoe878/portfolio2/blob/main/main.py"
click node_logic "https://github.com/bonsaijoe878/portfolio2/blob/main/local_logic.py"
click node_graph "https://github.com/bonsaijoe878/portfolio2/blob/main/transport_graph.py"
click node_matrix "https://github.com/bonsaijoe878/portfolio2/blob/main/transport_matrix.py"
click node_solver "https://github.com/bonsaijoe878/portfolio2/blob/main/tsp_solver.py"
click node_output "https://github.com/bonsaijoe878/portfolio2/blob/main/map_output.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_main,node_logic,node_graph,node_matrix,node_solver,node_output toneNeutral
```

## Components

### Other components

- [Main](https://github.com/bonsaijoe878/portfolio2/blob/main/main.py): orchestrator · Application entry point and pipeline coordinator. · `main.py`
- [Local Logic](https://github.com/bonsaijoe878/portfolio2/blob/main/local_logic.py): rules · Problem-specific glue, heuristics, and run-time decisions. · `local_logic.py`
- [Transport Graph](https://github.com/bonsaijoe878/portfolio2/blob/main/transport_graph.py): domain graph · Graph model of the transport network and distances. · `transport_graph.py`
- [Transport Matrix](https://github.com/bonsaijoe878/portfolio2/blob/main/transport_matrix.py): cost matrix · Matrix representation derived from the transport graph. · `transport_matrix.py`
- [TSP Solver](https://github.com/bonsaijoe878/portfolio2/blob/main/tsp_solver.py): optimizer · Route optimization engine that computes an ordered tour. · `tsp_solver.py`
- [Map Output](https://github.com/bonsaijoe878/portfolio2/blob/main/map_output.py): presentation · Formats or renders the computed route as a map or artifact. · `map_output.py`

## Connections

- Main → Local Logic: uses · Main delegates application-specific decisions to local logic.
- Main → Transport Graph: loads · Main initializes or receives the transport network model.
- Transport Graph → Transport Matrix: derives · Graph structure is converted into a matrix for lookup and solving.
- Transport Matrix → TSP Solver: feeds · Matrix data supplies the optimization algorithm.
- Local Logic → TSP Solver: guides · Local rules influence solver setup and interpretation.
- TSP Solver → Local Logic: returns · Solver results are adapted by local logic where needed.
- TSP Solver → Map Output: routes · Computed route is handed to the output layer.
- Local Logic → Map Output: formats · Local rules may affect final presentation or export.
- Main → Map Output: emits · Main triggers final output generation.
