# bcanfield/southpaw architecture

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

- Interactive diagram: https://gitdiagram.com/bcanfield/southpaw
- Repository: https://github.com/bcanfield/southpaw

## Overview

##### Project Overview
- Southpaw is a Python package built as a wrapper around the Fanduel API.
- It enables users to authenticate with Fanduel (using email, password, and specific auth tokens) and provides a rich set of helper functions for retrieving contest data, fetching available players, and updating DFS lineups.
- It is intended for programmatic interactions with the Fanduel platform, essentially serving as an API client.

##### Main Components
a. Southpaw Package:
- Core Library: Represent the main library as the “Southpaw API Client.”
- This includes the entry point (southpaw/__init__.py) and the core functionality (southpaw/fanduel.py) responsible for interacting with the API.
- Authentication Module: Although not split into distinct files, the authentication process (e.g., providing email, password, Basic auth, and X-Auth-Token credentials for initial login and subsequent API requests) is a crucial element.

b. API Interaction:
- Two-step authentication mechanism updated in October 2023, where users have to manually retrieve auth headers.

c. External Dependencies & Packaging:
- Setup and Distribution: Incorporate build-related components like setup.py, pyproject.toml, and requirements.txt. This shows how the package is packaged, distributed, and installed via pip.
- GitHub Workflows and CI/CD: Briefly note the existence of CI/CD pipelines (from the .github/workflows) to verify, test, and release the package.

d. Testing Framework:
- Unit Tests: Represent the tests directory (southpaw/tests) that includes unit tests (e.g., test_fanduel.py and test data under testData).
- This component ensures that the Southpaw client works correctly and interacts with the Fanduel API as expected.

##### Relationships and Interactions
- Data flow back from the Fanduel API to the client.
- Connections between the client and test suite, emphasizing that the tests simulate and verify these interactions.

##### Architectural Patterns and Principles
- Separation of concerns:
- Authentication and API interaction are managed within the Southpaw client.
- Testing components are isolated in a separate tests directory.
- The use of a wrapper/wrapper pattern for the Fanduel API can be highlighted as it abstracts away the complex API details.
- Mention that the design caters for ease-of-maintenance and extensibility (e.g., adding helper functions or supporting additional endpoints in the future).

## Diagram (Mermaid)

```mermaid
graph TD
    Developer["Developer/User"]:::user

    subgraph "Southpaw Package"
        APIClient["Southpaw API Client"]:::client
        Auth["Authentication Module"]:::auth
        APIClient -->|"manages"| Auth
    end

    Developer -->|"initializes"| APIClient

    APIClient -->|"sends_request_with_auth"| FanduelAPI["Fanduel API"]:::external
    FanduelAPI -->|"returns_response"| APIClient

    subgraph "Packaging & Distribution"
        Packaging["Packaging Components"]:::packaging
    end

    APIClient -->|"utilizes"| Packaging

    subgraph "CI/CD Pipelines"
        CICD["CI/CD Pipelines"]:::cicd
    end

    Packaging -->|"triggers"| CICD

    subgraph "Testing Environment"
        Testing["Testing Suite"]:::testing
    end

    Testing -->|"invokes_functions"| APIClient

    %% Click Events
    click APIClient "https://github.com/bcanfield/southpaw/blob/main/southpaw/fanduel.py"
    click APIClient "https://github.com/bcanfield/southpaw/blob/main/southpaw/__init__.py"
    click Packaging "https://github.com/bcanfield/southpaw/blob/main/setup.py"
    click Packaging "https://github.com/bcanfield/southpaw/blob/main/pyproject.toml"
    click Packaging "https://github.com/bcanfield/southpaw/blob/main/requirements.txt"
    click CICD "https://github.com/bcanfield/southpaw/blob/main/.github/workflows/release.yml"
    click CICD "https://github.com/bcanfield/southpaw/blob/main/.github/dependabot.yml"
    click Testing "https://github.com/bcanfield/southpaw/tree/main/southpaw/tests"
    click Testing "https://github.com/bcanfield/southpaw/blob/main/southpaw/tests/test_fanduel.py"
    click Testing "https://github.com/bcanfield/southpaw/tree/main/southpaw/tests/testData"

    %% Styles
    classDef user fill:#ADD8E6,stroke:#000,stroke-width:2px
    classDef client fill:#90EE90,stroke:#000,stroke-width:2px
    classDef auth fill:#FDFD96,stroke:#000,stroke-width:2px
    classDef external fill:#FFCCCB,stroke:#000,stroke-width:2px,stroke-dasharray: 5 5
    classDef packaging fill:#DDA0DD,stroke:#000,stroke-width:2px
    classDef cicd fill:#FFA07A,stroke:#000,stroke-width:2px
    classDef testing fill:#87CEFA,stroke:#000,stroke-width:2px
```
