# sahvsergio/treehouse_python_techdegree_unit2 architecture

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

- Interactive diagram: https://gitdiagram.com/sahvsergio/treehouse_python_techdegree_unit2
- Repository: https://github.com/sahvsergio/treehouse_python_techdegree_unit2

## Overview

##### Project type and purpose
- This is a console-based, single‐process Python utility (“Basketball Stats Tool”) that reads raw player data, cleans it, and divides players into balanced teams.
- Its purpose is to demonstrate Python data structures (lists, dictionaries) in a CLI context.

##### File structure
- Top‐level Python modules:
– app.py             ← main entry point that orchestrates the workflow
– greeter.py         ← handles user greetings/introduction
– data_cleaner.py    ← parses and sanitizes raw player data
– team_balancer.py   ← implements team assignment and statistics logic
– constants.py       ← stores configuration (e.g., raw data path, team sizes)
– team_balancer.txt  ← source of raw player data
– data_cleaner.log   ← log file for cleaning operations

##### README
- Confirms it’s a CLI tool built for the Treehouse Python Tech Degree, specializing in team statistics and balancing.

a. Main components
- User (CLI)
- CLI Controller (app.py)
- Greeter Module (greeter.py)
- Data Cleaner Module (data_cleaner.py)
- Team Balancer Module (team_balancer.py)
- Configuration (constants.py)
- Raw Data File (team_balancer.txt)
- Output / Logging (console output + data_cleaner.log)
b. Relationships and data flow
1. User starts the program via app.py
2. app.py → greeter.py to display welcome message and instructions
3. app.py loads constants (file path, parameters)
4. app.py calls data_cleaner.py, passing the raw data file path from constants.py
– data_cleaner.py reads team_balancer.txt, cleans/normalizes entries, writes any issues to data_cleaner.log, returns a cleaned list/dict of players
5. app.py passes cleaned data to team_balancer.py
– team_balancer.py divides players into teams, computes per‐team statistics
6. team_balancer.py returns results to app.py
7. app.py prints results to console
c. Architectural patterns & principles
- Modular separation of concerns (greeting, I/O, data cleaning, business logic)
- Single responsibility per module
- Linear, pipeline-style data flow
d. Key technologies
- Python 3.x
- Standard library (logging, file I/O)
- No external dependencies beyond stdlib

- Console I/O (User) as an actor on the left.
- Logging as a side-channel from data_cleaner to the log file.
– Controller (app.py): blue
– Utility modules (greeter, data_cleaner): green
– Business logic (team_balancer): orange
– Configuration/data (constants, team_balancer.txt): gray
- Notes or annotations for key interactions, error handling, and logs.

##### Final advice
- Be as granular as possible—each Python module is its own component.
- Data formats (e.g., list of dicts) in annotations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    User["User (CLI)"]:::actor

    %% Modules
    subgraph "Controller"
        App["app.py"]:::controller
    end

    subgraph "Utility Modules"
        Greeter["greeter.py"]:::utility
        DataCleaner["data_cleaner.py"]:::utility
    end

    subgraph "Business Logic"
        TeamBalancer["team_balancer.py"]:::logic
    end

    subgraph "Configuration & Data"
        Constants["constants.py"]:::data
        RawData[/"team_balancer.txt"/]:::data
        CleanLog[/"data_cleaner.log"/]:::data
    end

    Console["Console Output"]:::actor

    %% Flow
    User -->|"starts program"| App
    App -->|"display welcome"| Greeter
    App -->|"load config"| Constants
    App -->|"clean_data()"| DataCleaner
    DataCleaner -->|"reads data"| RawData
    DataCleaner -->|"log issues"| CleanLog
    DataCleaner -->|"returns cleaned list"| App
    App -->|"balance_teams()"| TeamBalancer
    TeamBalancer -->|"returns teams & stats"| App
    App -->|"print results"| Console

    %% Click Events
    click App "https://github.com/sahvsergio/treehouse_python_techdegree_unit2/blob/main/app.py"
    click Greeter "https://github.com/sahvsergio/treehouse_python_techdegree_unit2/blob/main/greeter.py"
    click DataCleaner "https://github.com/sahvsergio/treehouse_python_techdegree_unit2/blob/main/data_cleaner.py"
    click TeamBalancer "https://github.com/sahvsergio/treehouse_python_techdegree_unit2/blob/main/team_balancer.py"
    click Constants "https://github.com/sahvsergio/treehouse_python_techdegree_unit2/blob/main/constants.py"
    click RawData "https://github.com/sahvsergio/treehouse_python_techdegree_unit2/blob/main/team_balancer.txt"
    click CleanLog "https://github.com/sahvsergio/treehouse_python_techdegree_unit2/blob/main/data_cleaner.log"

    %% Styles
    classDef controller fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef utility fill:#d4edda,stroke:#333,stroke-width:1px
    classDef logic fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef data fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef actor fill:#f0f0f0,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
