# jrandallsexton/sports-data-core architecture

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

- Interactive diagram: https://gitdiagram.com/jrandallsexton/sports-data-core
- Repository: https://github.com/jrandallsexton/sports-data-core

## Overview

##### Main Components Identification
The system consists of several microservices, each with specific responsibilities:
- API Gateway (entry point)
- Provider Service (external data collection)
- Producer Service (data transformation)
- Domain-specific services:
- Contest Service
- Franchise Service
- Notification Service
- Player Service
- Season Service
- Venue Service
- Shared Core Library
- Data Storage Systems
- Message Queue System (SNS/SQS)

**Client Layer**
- Web Clients
- Mobile Clients
- API Clients (Postman)

**Service Layer**
- API Gateway
- Identity Service
- Microservices Network

**Infrastructure Layer**
- Databases
- Message Queue
- Data Lake

##### Key Relationships to Highlight

a. Data Flow:
- External Sources → Provider → Data Lake
- Data Lake → Producer → Domain Services
- All Services ↔ Message Queue
- API Gateway → All Services
- Clients → API Gateway

b. Event-Driven Architecture:
- Event publishing/subscription patterns
- Central role of SNS/SQS

##### Technical Details

**Infrastructure Components:**
- Databases: Show per-service databases
- Message Queue: SNS/SQS implementation
- Data Lake: Storage for raw external data
- Docker containers: Show containerization boundary
- Kubernetes cluster: Indicate deployment boundary

**Communication Patterns:**
**⇄ Bi-directional Communication**

##### Deployment Context

- Docker containers
- Kubernetes pods
- Network boundaries
- Load balancers
- Azure pipeline integration

##### Additional Documentation
Annotations for:
- Scaling points
- Failure recovery paths
- Data consistency boundaries
- Service discovery mechanisms
- Health check implementations

Remember to highlight the event-driven nature of the system and how the Provider and Producer services act as the backbone for data ingestion and transformation, while domain services handle specific business logic areas.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        WC[Web Clients]
        MC[Mobile Clients]
        AC[API Clients]
    end

    %% Service Layer
    subgraph Services
        AG[API Gateway]:::gateway
        click AG "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Api"

        subgraph "Data Ingestion"
            PS[Provider Service]:::service
            click PS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Provider"
            PRS[Producer Service]:::service
            click PRS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Producer"
        end

        subgraph "Domain Services"
            CS[Contest Service]:::service
            click CS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Contest"
            FS[Franchise Service]:::service
            click FS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Franchise"
            NS[Notification Service]:::service
            click NS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Notification"
            PLS[Player Service]:::service
            click PLS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Player"
            SS[Season Service]:::service
            click SS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Season"
            VS[Venue Service]:::service
            click VS "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Venue"
        end

        subgraph "Core Components"
            CL[Core Library]:::core
            click CL "https://github.com/jrandallsexton/sports-data-core/blob/main/src/SportsData.Core"
            HM[Health Monitoring]:::core
            click HM "https://github.com/jrandallsexton/sports-data-core/tree/main/src/SportsData.Core/Middleware/Health"
            SC[Service Clients]:::core
            click SC "https://github.com/jrandallsexton/sports-data-core/tree/main/src/SportsData.Core/Infrastructure/Clients"
        end
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        subgraph "Message Queue"
            SNS[SNS]:::queue
            SQS[SQS]:::queue
            EP[Event Publisher]:::queue
            click EP "https://github.com/jrandallsexton/sports-data-core/tree/main/src/SportsData.Core/Eventing/Publishers"
            EC[Event Consumer]:::queue
            click EC "https://github.com/jrandallsexton/sports-data-core/tree/main/src/SportsData.Core/Eventing/Consumers"
        end

        subgraph "Data Storage"
            DB[(Service DBs)]:::storage
            DL[(Data Lake)]:::storage
        end

        subgraph "External Sources"
            ESPN{ESPN API}:::external
            CBS{CBS API}:::external
            click ESPN "https://github.com/jrandallsexton/sports-data-core/tree/main/src/SportsData.Core/Infrastructure/DataSources/Espn"
        end
    end

    %% Relationships
    WC & MC & AC --> AG
    AG --> CS & FS & NS & PLS & SS & VS
    ESPN & CBS --> PS
    PS --> DL
    DL --> PRS
    PRS --> SNS
    SNS --> SQS
    EP --> SNS
    SQS --> EC
    CS & FS & NS & PLS & SS & VS --> DB
    CS & FS & NS & PLS & SS & VS --> EP
    EC --> CS & FS & NS & PLS & SS & VS

    %% Styles
    classDef service fill:#68a0cf,stroke:#333,stroke-width:2px
    classDef gateway fill:#f9a825,stroke:#333,stroke-width:2px
    classDef core fill:#81c784,stroke:#333,stroke-width:2px
    classDef queue fill:#ba68c8,stroke:#333,stroke-width:2px
    classDef storage fill:#4db6ac,stroke:#333,stroke-width:2px
    classDef external fill:#ef5350,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Service]:::service
        L2[Gateway]:::gateway
        L3[Core Component]:::core
        L4[Queue Component]:::queue
        L5[(Storage)]:::storage
        L6{External API}:::external
    end
```
