# centtttt/connectfriend architecture

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

- Interactive diagram: https://gitdiagram.com/centtttt/connectfriend
- Repository: https://github.com/centtttt/connectfriend

## Overview

##### Project Type and Purpose
- This is a full-stack Laravel web application implementing typical social and transactional features:
- User authentication/registration (LoginController, RegisterController, etc.)
- User profiles and friend relationships (ProfileController, FriendProfileController)
- Real-time‐style messaging and notifications (MessageController, NotificationController)
- Payment and top-up flows (PaymentController, TopUpController)
- The file tree follows Laravel’s default MVC+structure: controllers under app/Http/Controllers, Eloquent models under app/Models, Blade views under resources/views, routes in routes/web.php, migrations in database/migrations, front-end assets in resources/js and resources/css, compiled via Vite/post-CSS/bootstrap.

##### Key Architectural Components
a. Client Tier
- Web browser (HTML/CSS/JS delivered by public/).
- Assets built by Vite (resources/js/app.js, resources/css/app.css) and Bootstrap.
b. Web Tier
- Web server (Apache/Nginx pointing to public/index.php).
- Laravel front‐controller (public/index.php ➔ bootstrap/app.php ➔ app/Http Kernel).
- Middleware pipeline (e.g., SetLocale, checkUserStatus).
- HTTP Controllers (Auth, Profile, Message, Payment, etc.).
c. Application Tier
- Service Container & Providers (app/Providers/AppServiceProvider).
- Eloquent ORM (app/Models + migrations).
- Blade templating engine (resources/views).
- Background jobs & queues (config/queue.php, Jobs table).
d. Data Tier
- Relational database (MySQL/PostgreSQL configured in config/database.php).
- File storage (local or cloud via config/filesystems.php for uploads/profile photos).
- Cache/session stores (Redis or DB via config/cache.php, config/session.php).
e. External Services
- Payment gateway (integration via config/services.php).
- Mail service (SMTP or third-party via config/mail.php).
- Optional SMS/Push for notifications.

##### Relationships and Interactions
- Client sends HTTP requests ➔ Web Server ➔ Laravel Kernel
- Kernel dispatches through Middleware ➔ Routes ➔ Controllers
- Controllers invoke Services/Repositories (business logic) ➔ Eloquent Models ➔ Database
- Controllers return Blade views or JSON API responses ➔ Client renders UI
- Certain operations enqueue Jobs ➔ Queue Worker processes jobs asynchronously
- File uploads stored in Storage ➔ can be served via public symlink
- PaymentController communicates with external payment gateway via HTTPS APIs
- NotificationController may push real-time events (e.g., Laravel Echo) or send emails

##### Architectural Patterns & Principles
- MVC: Separation of Models (app/Models), Views (resources/views), Controllers (app/Http/Controllers)
- Middleware pipeline for cross-cutting concerns (authentication, localization, feature flags)
- Service Container / Dependency Injection via Providers
- Repository/Service layer (if custom) for business logic separation
- Queue pattern for asynchronous tasks (emails, notifications, payment callbacks)
- Configuration‐over-convention: config/*.php holds environment‐specific settings

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["User Browser"]:::ui
        Assets["Vite-built Assets\nresources/js/app.js\nresources/css/app.css"]:::ui
        Browser -->|loads assets| Assets
    end

    %% Web/API Layer
    subgraph "Web/API Layer"
        WebServer["Nginx/Apache\npublic/index.php"]:::service
        Kernel["Laravel Kernel\nbootstrap/app.php"]:::service
        Browser -->|HTTP Request| WebServer
        WebServer -->|front-controller| Kernel
    end

    %% Middleware Pipeline
    subgraph "Middleware Pipeline"
        SetLocale["SetLocale"]:::service
        CheckUser["checkUserStatus"]:::service
        CheckStatus["checkStatus"]:::service
        CheckPay["checkPaymentStatus"]:::service
        Kernel --> SetLocale
        SetLocale --> CheckUser
        CheckUser --> CheckStatus
        CheckStatus --> CheckPay
    end

    %% Application Layer
    subgraph "Controllers" 
        AuthCtrls["Auth Controllers"]:::service
        RegCtrl["Registration Controller"]:::service
        ProfileCtrls["Profile Controllers"]:::service
        MessageCtrl["Message Controller"]:::service
        NotifCtrl["Notification Controller"]:::service
        PaymentCtrls["Payment/TopUp Controllers"]:::service
        HomeCtrl["Home/Dashboard Controller"]:::service

        CheckPay --> AuthCtrls
        CheckPay --> RegCtrl
        CheckPay --> ProfileCtrls
        CheckPay --> MessageCtrl
        CheckPay --> NotifCtrl
        CheckPay --> PaymentCtrls
        CheckPay --> HomeCtrl
    end

    subgraph "Services & ORM"
        ServiceContainer["Service Container\nAppServiceProvider"]:::service
        Eloquent["Eloquent ORM\napp/Models"]:::service
        Blade["Blade Templating\nresources/views"]:::service
        Queues["Queues & Jobs"]:::service

        Controllers --> ServiceContainer
        ServiceContainer --> Eloquent
        Eloquent --> Blade
        Eloquent --> Queues
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["MySQL/PostgreSQL"]:::data
        Cache["Redis Cache"]:::data
        Storage["File Storage"]:::data
        DB <-- Eloquent
        Queues --> DB
        Blade --> Storage
    end

    %% External Services
    subgraph "External Services"
        PayGateway["Payment Gateway"]:::ext
        MailService["Mail Service"]:::ext
        SMSPush["SMS/Push Service"]:::ext
        PaymentCtrls -->|HTTPS API| PayGateway
        NotifCtrl -->|SMTP/API| MailService
        NotifCtrl -->|Push| SMSPush
    end

    %% Click Events
    click RegCtrl "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/RegistrationController.php"
    click ProfileCtrls "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/ProfileController.php"
    click ProfileCtrls "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/FriendProfileController.php"
    click MessageCtrl "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/MessageController.php"
    click NotifCtrl "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/NotificationController.php"
    click PaymentCtrls "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/PaymentController.php"
    click PaymentCtrls "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/TopUpController.php"
    click HomeCtrl "https://github.com/centtttt/connectfriend/blob/main/app/Http/Controllers/HomeController.php"
    click SetLocale "https://github.com/centtttt/connectfriend/blob/main/app/Http/Middleware/SetLocale.php"
    click CheckUser "https://github.com/centtttt/connectfriend/blob/main/app/Http/Middleware/checkUserStatus.php"
    click CheckStatus "https://github.com/centtttt/connectfriend/blob/main/app/Http/Middleware/checkStatus.php"
    click CheckPay "https://github.com/centtttt/connectfriend/blob/main/app/Http/Middleware/checkPaymentStatus.php"
    click ServiceContainer "https://github.com/centtttt/connectfriend/blob/main/app/Providers/AppServiceProvider.php"
    click DB "https://github.com/centtttt/connectfriend/blob/main/config/database.php"
    click Cache "https://github.com/centtttt/connectfriend/blob/main/config/cache.php"
    click Storage "https://github.com/centtttt/connectfriend/blob/main/config/filesystems.php"
    click PayGateway "https://github.com/centtttt/connectfriend/blob/main/config/services.php"
    click MailService "https://github.com/centtttt/connectfriend/blob/main/config/mail.php"
    click Queues "https://github.com/centtttt/connectfriend/blob/main/config/queue.php"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085;
    classDef service fill:#d4edda,stroke:#155724,color:#155724;
    classDef data fill:#fff3cd,stroke:#856404,color:#856404;
    classDef ext fill:#ffe5b4,stroke:#e69500,color:#e69500;
```
