# k3vo2003/red_social architecture

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

- Interactive diagram: https://gitdiagram.com/k3vo2003/red_social
- Repository: https://github.com/k3vo2003/red_social

## Overview

##### Project Type and Purpose
- This is a monolithic, full-stack PHP social-network application (“red_social”) following an MVC pattern.
- Key features (inferred from Controllers and Models): user authentication (login/register), profiles, posting text and video, live streaming, comments/likes/follows, and payments/transactions.

##### High-Level Architecture Components
a. Client Layer
- Web browser or mobile webview sending HTTP(S) requests.
- Renders HTML/CSS/JS produced by the Views.
b. Web Server & PHP Runtime
- Apache/Nginx with mod_php or PHP-FPM processes.
- public/index.php as the front controller.
c. Routing & Configuration
- config/routes.php maps URIs to specific controller actions.
- config/*.php holds database, OAuth, and other environment settings.
d. Application Layer (MVC)
- Controllers (app/Controllers): AuthController, HomeController, PostController, VideoController, LiveController, PaymentController, ApiController, ProfileController.
- Models (app/Models): User, Post, Video, Live, Transaction, Comment, Like, Follower. These encapsulate database interactions (Active Record or similar).
- Views (app/Views): PHP templates under auth/, home/, posts/, videos/, live/, profile/ plus shared layouts.
e. Persistence Layer
- Relational database (MySQL/PostgreSQL) defined by SQL migrations in database/migrations/*.
f. External Services
- OAuth providers (configured via config/oauth.php) for social login.
- Payment gateway (e.g., Stripe/PayPal) invoked by PaymentController.
- Potential streaming server or CDN for live video (LiveController may interact with an RTMP/WebSocket service).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["Web Browser / Mobile WebView"]:::client
    end

    %% Web Server & PHP Runtime
    subgraph "Web Server & PHP Runtime"
        Server["Apache/Nginx + PHP-FPM"]:::server
        index["public/index.php"]:::server
        htaccess[".htaccess"]:::server
        Server --> index
    end

    Browser -->|"HTTP(S) Request"| Server
    index -->|"Front Controller"| configRoutes

    click index "https://github.com/k3vo2003/red_social/blob/main/public/index.php"
    click htaccess "https://github.com/k3vo2003/red_social/blob/main/public/.htaccess"

    %% Routing & Configuration
    subgraph "Routing & Configuration"
        configRoutes["config/routes.php"]:::router
        configGeneral["config/config.php"]:::router
        configDB["config/database.php"]:::router
        configOAuth["config/oauth.php"]:::router
    end

    click configRoutes "https://github.com/k3vo2003/red_social/blob/main/config/routes.php"
    click configGeneral "https://github.com/k3vo2003/red_social/blob/main/config/config.php"
    click configDB "https://github.com/k3vo2003/red_social/blob/main/config/database.php"
    click configOAuth "https://github.com/k3vo2003/red_social/blob/main/config/oauth.php"

    configRoutes --> Controllers

    %% Controllers Layer
    subgraph "Controllers"
        AuthC["AuthController"]:::controller
        HomeC["HomeController"]:::controller
        PostC["PostController"]:::controller
        VideoC["VideoController"]:::controller
        LiveC["LiveController"]:::controller
        ProfileC["ProfileController"]:::controller
        PaymentC["PaymentController"]:::controller
        ApiC["ApiController"]:::controller
    end

    click AuthC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/AuthController.php"
    click HomeC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/HomeController.php"
    click PostC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/PostController.php"
    click VideoC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/VideoController.php"
    click LiveC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/LiveController.php"
    click ProfileC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/ProfileController.php"
    click PaymentC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/PaymentController.php"
    click ApiC "https://github.com/k3vo2003/red_social/blob/main/app/Controllers/ApiController.php"

    %% Models Layer
    subgraph "Models"
        UserM["User"]:::model
        PostM["Post"]:::model
        VideoM["Video"]:::model
        LiveM["Live"]:::model
        TransactionM["Transaction"]:::model
        CommentM["Comment"]:::model
        LikeM["Like"]:::model
        FollowerM["Follower"]:::model
    end

    click UserM "https://github.com/k3vo2003/red_social/blob/main/app/Models/User.php"
    click PostM "https://github.com/k3vo2003/red_social/blob/main/app/Models/Post.php"
    click VideoM "https://github.com/k3vo2003/red_social/blob/main/app/Models/Video.php"
    click LiveM "https://github.com/k3vo2003/red_social/blob/main/app/Models/Live.php"
    click TransactionM "https://github.com/k3vo2003/red_social/blob/main/app/Models/Transaction.php"
    click CommentM "https://github.com/k3vo2003/red_social/blob/main/app/Models/Comment.php"
    click LikeM "https://github.com/k3vo2003/red_social/blob/main/app/Models/Like.php"
    click FollowerM "https://github.com/k3vo2003/red_social/blob/main/app/Models/Follower.php"

    %% Views Layer
    subgraph "Views"
        authLogin["login.php"]:::view
        authRegister["register.php"]:::view
        homeFeed["feed.php"]:::view
    end

    click authLogin "https://github.com/k3vo2003/red_social/blob/main/app/Views/auth/login.php"
    click authRegister "https://github.com/k3vo2003/red_social/blob/main/app/Views/auth/register.php"
    click homeFeed "https://github.com/k3vo2003/red_social/blob/main/app/Views/home/feed.php"

    %% Data Persistence
    subgraph "Persistence Layer"
        Database["Relational DB (MySQL/PostgreSQL)"]:::db
        Migrations["database/migrations/..."]:::db
    end

    click Migrations "https://github.com/k3vo2003/red_social/blob/main/database/migrations/001_create_users_table.sql"

    %% External Services
    subgraph "External Services"
        OAuth["OAuth Provider"]:::external
        PaymentGW["Payment Gateway"]:::external
        Streaming["Streaming Server / CDN"]:::external
    end

    %% Data Flows
    Controllers -->|"Render View"| Views
    Controllers -->|"Query/Update"| Models
    Models -->|"SQL"| Database
    Controllers -->|"Invoke"| OAuth
    Controllers -->|"Invoke"| PaymentGW
    LiveC -.->|"Streaming"| Streaming
    Database -->|"Response"| Controllers
    Controllers -->|"HTTP Response"| Browser

    %% Layer Connections
    configRoutes --> Controllers
    Controllers --> Views
    Controllers --> Models

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,color:#004085;
    classDef server fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef router fill:#d4edda,stroke:#155724,color:#155724;
    classDef controller fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
    classDef model fill:#fff3cd,stroke:#856404,color:#856404;
    classDef view fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef db fill:#ffeeba,stroke:#856404,color:#856404;
    classDef external fill:#e2d5f9,stroke:#6f42c1,color:#6f42c1;
```
