How sahvsergio/treehouse_python_techdegree_unit2 works
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.