How shunaaaaabbbbb/nba_analysis works
Project Type and Purpose
• This is a full‐stack, single‐page web application built with Streamlit.
• Purpose: Let users select an NBA game or player and render shot charts and comparative statistics by fetching data from the official NBA API.
File Structure
• Entry point: main.py – launches the Streamlit server and handles page routing.
• analysis_pages/ – modules that implement individual analysis screens (shot charts, player comparison, stats).
• nba_api_utils/ – data‐access layer wrapping NBA API endpoints (game, player, team, seasons, shot charts, etc.).
• utils/ – shared helper functions: constants, UI helpers, generic visualizations, business‐logic helpers.
• nba_stats_app/ – package folder (empty __init__.py) for distributing or namespacing the app.
• tests/ – unit tests for core logic.
• notebook/ – exploratory Jupyter notebook used during development.
• pyproject.toml – project metadata and dependency declarations.
Key Architecture Insights from README
• The app is deployed on Streamlit Cloud (URL given).
• Users interact via a sidebar to choose analysis type and parameters (player name, date, etc.).
• Outputs are visual: shot chart overlays, bar charts, tables.
Main Components
A. Client Layer
– Web Browser / Streamlit Frontend UI
B. Application Layer
1. Streamlit Server (main.py)
2. Analysis Pages (analysis_pages/*.py)
• nba_shotchart.py, player_comparison.py, show_stats.py
3. Utility Modules (utils/*.py)
• constants.py, helpers.py, ui_helpers.py, visualizations.py
C. Data Access Layer
– NBA API Utilities (nba_api_utils/*.py)
• game.py, player.py, team.py, seasons.py, shot_chart.py, input_data.py, button.py
D. External Services
– Official NBA REST API (external HTTP endpoints)
E. Supporting Components (non‐runtime)
– Tests (tests/)
– Development Notebook (notebook/)
Relationships and Data Flows
• Browser → Streamlit Server: user input, page navigation.
• Streamlit Server → Analysis Pages: invokes the correct page module based on user selection.
• Analysis Pages → Utils: calls helper functions for data transformation and chart creation.
• Analysis Pages → NBA API Utils: requests raw data (games, shot locations, stats).
• NBA API Utils → External NBA API: HTTP calls to fetch JSON data.
• Data flows back up: External NBA API → NBA API Utils → Analysis Pages → Streamlit UI → Browser.
Architectural Patterns and Principles
• Layered Architecture (Presentation → Business Logic → Data Access).
• Separation of Concerns:
– analysis_pages handles page‐specific logic,
– utils holds cross‐cutting helpers,
– nba_api_utils isolates all external API calls.
• Modular Design: each functional area lives in its own directory.
• Testability: core logic is covered by unit tests in tests/.