# game7/sportified architecture

> Architecture diagram of the GitHub repository game7/sportified, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/game7/sportified
- Repository: https://github.com/game7/sportified

## Overview

##### Main Components

a. Frontend Layer:
- React/TypeScript components (in app/javascript)
- Asset pipeline (app/assets)
- View templates (app/views)
- Multiple theme support (shown in assets/stylesheets/themes)

b. Backend Layer:
- Rails controllers (organized by admin, API, and public interfaces)
- Models with complex relationships
- Background jobs and services
- Authentication system (Passwordless authentication visible in initializers)

c. External Services:
- Stripe integration (visible in migrations and controllers)
- Storage service (Active Storage configuration)
- Chromecast integration (shown in controllers and views)

##### Key Architectural Patterns to Highlight

a. Multi-tenancy Architecture:
- Tenant isolation
- Tenant-specific configurations
- Shared vs tenant-specific resources

b. Module Organization:
- League management
- Event management
- Registration system
- Product management
- User management

**[Client Layer]**
- Web Interface
- Admin Portal
- Public Pages
- Registration System
- Mobile Interface
- Chromecast Interface

**[Application Layer]**
- Controllers
- Admin Controllers
- API Controllers
- Public Controllers
- Services
- Payment Processing
- Event Management
- League Management
- Background Jobs

**[Data Layer]**
- Models
- Core (User, Tenant)
- League
- Events
- Products
- Active Storage
- Database (PostgreSQL)

**[External Services]**
- Stripe
- Storage Service
- Chromecast API

##### Integration Points

- API endpoints
- Webhook handlers
- External service connections

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WI[Web Interface]
        MI[Mobile Interface]
        CI[Chromecast Interface]
    end

    subgraph Frontend
        RC["React Components"]:::frontend
        VT["View Templates"]:::frontend
        TS["Theme System"]:::frontend
        AP["Asset Pipeline"]:::frontend
    end

    subgraph Controllers
        AC["Admin Controllers"]:::controller
        APIC["API Controllers"]:::controller
        PC["Public Controllers"]:::controller
    end

    subgraph Services
        PP["Payment Processing"]:::service
        EM["Event Management"]:::service
        LM["League Management"]:::service
        RS["Registration System"]:::service
        PM["Product Management"]:::service
        UM["User Management"]:::service
    end

    subgraph Data
        Models["Core Models"]:::data
        AS["Active Storage"]:::data
        DB[(PostgreSQL)]:::database
    end

    subgraph External
        Stripe["Stripe Payment"]:::external
        Storage["Storage Service"]:::external
        Cast["Chromecast API"]:::external
    end

    %% Client to Frontend
    WI --> RC
    WI --> VT
    MI --> APIC
    CI --> Cast

    %% Frontend to Controllers
    RC --> AC
    RC --> APIC
    RC --> PC
    VT --> AC
    VT --> PC

    %% Controllers to Services
    AC --> PP
    AC --> EM
    AC --> LM
    AC --> RS
    AC --> PM
    AC --> UM
    APIC --> PP
    APIC --> EM
    PC --> RS

    %% Services to Data
    PP --> Models
    EM --> Models
    LM --> Models
    RS --> Models
    PM --> Models
    UM --> Models
    Models --> DB
    Models --> AS

    %% External Connections
    PP --> Stripe
    AS --> Storage
    CI --> Cast

    %% Click Events
    click RC "https://github.com/game7/sportified/tree/master/app/javascript/components/"
    click VT "https://github.com/game7/sportified/tree/master/app/views/"
    click TS "https://github.com/game7/sportified/tree/master/app/assets/stylesheets/themes/"
    click AC "https://github.com/game7/sportified/tree/master/app/controllers/admin/"
    click APIC "https://github.com/game7/sportified/tree/master/app/controllers/api/"
    click PC "https://github.com/game7/sportified/tree/master/app/controllers/host/"
    click Models "https://github.com/game7/sportified/tree/master/app/models/"
    click PP "https://github.com/game7/sportified/blob/master/app/controllers/stripe_connects_controller.rb"
    click Cast "https://github.com/game7/sportified/blob/master/app/controllers/chromecasts_controller.rb"
    click RS "https://github.com/game7/sportified/blob/master/app/controllers/registrations_controller.rb"
    click EM "https://github.com/game7/sportified/tree/master/app/controllers/admin/events/"
    click PM "https://github.com/game7/sportified/tree/master/app/controllers/admin/products/"
    click UM "https://github.com/game7/sportified/tree/master/app/controllers/admin/users/"

    %% Styles
    classDef frontend fill:#a8d1ff
    classDef controller fill:#ffb3ba
    classDef service fill:#baffc9
    classDef data fill:#ffffba
    classDef database fill:#ffdfba
    classDef external fill:#e6e6e6

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        C[Controllers]:::controller
        S[Services]:::service
        D[Data]:::data
        DB2[(Database)]:::database
        E[External]:::external
    end
```
