# bquochuy1514/sportiverse_backend architecture

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

- Interactive diagram: https://gitdiagram.com/bquochuy1514/sportiverse_backend
- Repository: https://github.com/bquochuy1514/sportiverse_backend

## Overview

##### Project type and purpose
- This is a Laravel-based headless e-commerce API. There is no monolithic “blade” frontend in the repo; instead you expose JSON endpoints (in routes/api.php) for products, categories, carts, coupons, sports, users and auth. SocialiteController hints at social login.

##### File structure
- Top‐level “app” directory contains your HTTP controllers (app/Http/Controllers/Api/*), middleware, models, policies and service providers.
- “routes/api.php” defines your REST endpoints.
- “database” holds migrations & seeders for users, categories, products, cart, coupons, etc.
- “config/*.php” files configure database, cache, session, queue, services (Socialite), Sanctum, etc.
- “public/index.php” is your API entry point.
- “storage” + “bootstrap/cache” handle caches, compiled views, logs, sessions, and file uploads.
- You have queue infrastructure (jobs table migration + queue.php config) and filesystem abstraction.

##### Final guidance
- Be exhaustive: include every model, service, and external dependency.
- How middleware and policies guard your endpoints.
- Async boundaries (where you hand off work to the queue).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        ClientApp["SPA/Mobile App"]:::external
    end

    %% Presentation/API Layer
    subgraph "Presentation/API Layer"
        direction TB
        APIGateway["API Gateway\n(public/index.php)"]:::compute
        Kernel["HTTP Kernel\n(bootstrap/app.php)"]:::compute
        Middleware["Global & Route Middleware"]:::compute
        Router["Routing\n(routes/api.php)"]:::compute
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Controllers["API Controllers"]:::compute
        BaseController["Base Controller"]:::compute
        SocialiteCtrl["SocialiteController"]:::compute
        Policies["Authorization Policies"]:::compute
        ServiceProvider["AppServiceProvider\n(DI)"]:::compute
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Models["Eloquent Models"]:::compute
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        DB["MySQL/PostgreSQL\n(config/database.php)"]:::store
        Cache["Redis/File Cache\n(config/cache.php)"]:::store
        QueueSystem["Queue System\n(config/queue.php)"]:::store
        FileStorage["Filesystem\n(config/filesystems.php)"]:::store
        OAuthProvider["External OAuth Provider"]:::external
    end

    %% Flow
    ClientApp -->|"HTTPS JSON" | APIGateway
    APIGateway --> Kernel
    Kernel --> Middleware
    Middleware --> Router
    Router --> Controllers
    Controllers --> BaseController
    Controllers --> SocialiteCtrl
    Controllers --> Policies
    Controllers --> Models
    Controllers --> Cache
    Controllers --> FileStorage
    Controllers -->|"dispatch Job"| QueueSystem
    QueueSystem -->|"worker picks job"| Controllers
    Models --> DB
    QueueSystem --> DB
    FileStorage --> DB
    SocialiteCtrl --> OAuthProvider

    %% Click Events
    click APIGateway "https://github.com/bquochuy1514/sportiverse_backend/blob/master/public/index.php"
    click Kernel "https://github.com/bquochuy1514/sportiverse_backend/blob/master/bootstrap/app.php"
    click Middleware "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Middleware/AdminMiddleware.php"
    click Middleware "https://github.com/bquochuy1514/sportiverse_backend/blob/master/config/cors.php"
    click Router "https://github.com/bquochuy1514/sportiverse_backend/blob/master/routes/api.php"
    click Controllers "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Api/AuthController.php"
    click Controllers "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Api/CartController.php"
    click Controllers "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Api/CategoryController.php"
    click Controllers "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Api/CouponController.php"
    click Controllers "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Api/ProductController.php"
    click Controllers "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Api/SportController.php"
    click Controllers "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Api/UserController.php"
    click SocialiteCtrl "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/SocialiteController.php"
    click BaseController "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Http/Controllers/Controller.php"
    click Policies "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Policies/ProductPolicy.php"
    click ServiceProvider "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Providers/AppServiceProvider.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/User.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/Product.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/Category.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/Cart.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/CartItem.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/Coupon.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/Sport.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/ProductImage.php"
    click Models "https://github.com/bquochuy1514/sportiverse_backend/blob/master/app/Models/SocialAccount.php"
    click DB "https://github.com/bquochuy1514/sportiverse_backend/blob/master/config/database.php"
    click Cache "https://github.com/bquochuy1514/sportiverse_backend/blob/master/config/cache.php"
    click QueueSystem "https://github.com/bquochuy1514/sportiverse_backend/blob/master/config/queue.php"
    click QueueSystem "https://github.com/bquochuy1514/sportiverse_backend/blob/master/database/migrations/0001_01_01_000002_create_jobs_table.php"
    click FileStorage "https://github.com/bquochuy1514/sportiverse_backend/blob/master/config/filesystems.php"

    %% Styles
    classDef compute fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef store fill:#D0FFD0,stroke:#333,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#333,stroke-width:1px
```
