# sammig6i/swishpredict architecture

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

- Interactive diagram: https://gitdiagram.com/sammig6i/swishpredict
- Repository: https://github.com/sammig6i/swishpredict

## Overview

##### Main Components

a. Orchestration Layer:
- Apache Airflow as the central orchestrator
- DAG workflow for NBA data pipeline
- Task dependencies and scheduling

b. Data Services:
- Data Ingestion Service (Web Scraping)
- Data Processing Service
- Feature Generation Service
- Each service runs in its own Docker container

c. Storage Systems:
- MinIO for object storage
- PostgreSQL for structured data storage

d. Machine Learning Component:
- XGBoost model for predictions
- Model artifacts storage

**[Airflow Orchestrator]**

- ↓
**[Data Pipeline Services]**

- ↓         ↓         ↓
**[Ingestion] [Processing] [Feature Generation]**

- ↓         ↓         ↓
**[Storage Layer]**

- ↓         ↓
**[MinIO]    [PostgreSQL]**

- ┘
- ↓
**[XGBoost Model]**

- Data flow between components
- Service dependencies
- Pipeline execution order

##### Specific details
- Data sources (basketball-reference.com)
- File formats and data types
- Service configurations from config files
- Model performance metrics from model_metadata.yaml

##### Important architectural elements to highlight
- Modular service design with Docker
- Separation of concerns between services
- Data persistence strategy
- Pipeline scheduling and monitoring
- Model training and deployment flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Orchestration
        AF[Airflow Orchestrator]:::orchestrator
        DAG[NBA Pipeline DAG]:::orchestrator
    end

    subgraph Services
        direction TB
        DI[Data Ingestion Service]:::service
        DP[Data Processing Service]:::service
        FG[Feature Generation Service]:::service
    end

    subgraph Storage
        direction TB
        MIO[MinIO Object Storage]:::storage
        PSQL[PostgreSQL Database]:::storage
    end

    subgraph ML
        XGB[XGBoost Model]:::ml
    end

    subgraph Configuration
        direction TB
        SC[Service Config]:::config
        MC[Model Config]:::config
    end

    AF --> DAG
    DAG --> DI
    DAG --> DP
    DAG --> FG

    DI --> MIO
    DP --> MIO
    DP --> PSQL
    FG --> PSQL

    MIO --> XGB
    PSQL --> XGB

    SC --> DI
    SC --> DP
    SC --> FG
    MC --> XGB

    %% Click events for component mapping
    click AF "https://github.com/sammig6i/SwishPredict/blob/main/airflow/airflow.cfg"
    click DAG "https://github.com/sammig6i/SwishPredict/blob/main/airflow/dags/nba_data_pipeline.py"
    click DI "https://github.com/sammig6i/SwishPredict/tree/main/data_pipeline_services/data_ingestion"
    click DP "https://github.com/sammig6i/SwishPredict/tree/main/data_pipeline_services/data_processing"
    click FG "https://github.com/sammig6i/SwishPredict/tree/main/data_pipeline_services/feature_generation"
    click MIO "https://github.com/sammig6i/SwishPredict/blob/main/data_pipeline_services/minio_operations.py"
    click PSQL "https://github.com/sammig6i/SwishPredict/blob/main/data_pipeline_services/init.sql"
    click XGB "https://github.com/sammig6i/SwishPredict/blob/main/models/best_xgboost_model.joblib"
    click SC "https://github.com/sammig6i/SwishPredict/tree/main/data_pipeline_services/config"
    click MC "https://github.com/sammig6i/SwishPredict/blob/main/config/model_metadata.yaml"

    classDef orchestrator fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef ml fill:#9b59b6,stroke:#8e44ad,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1[Orchestration]:::orchestrator
        L2[Services]:::service
        L3[Storage]:::storage
        L4[Machine Learning]:::ml
        L5[Configuration]:::config
    end
```
