# zinebni/uconnect architecture

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

- Interactive diagram: https://gitdiagram.com/zinebni/uconnect
- Repository: https://github.com/zinebni/uconnect

## Overview

##### Project Type & Purpose
- UConnecte is a full-stack web application built with Laravel 10.x that provides a private social network for a university community.
- It follows the MVC pattern on the server, uses Blade for server-rendered views, and enriches UX with Tailwind CSS, Alpine.js, and Axios.

##### Top-Level Components (to include
a. Client Tier
- Browser UI – Blade-generated HTML/CSS/JS, Alpine.js for interactivity, Tailwind CSS for styling, Axios calls for async updates.
- Assets Server – Vite or Laravel Mix bundle endpoints serving JS/CSS/images.
b. Web/API Tier
- Laravel HTTP Kernel – routes (web.php, auth.php), middleware (session, auth, CSRF).
- Controllers – Auth, Post, Comment, Like, Follow, Message, Notification, Profile, Search, Dashboard.
- Service Layer – FriendSuggestionService, Queue jobs for notifications and emails.
- Events & Listeners – PostCreated → CreatePostNotification, CommentLiked → notification, UserFollowed → notification.
- Queue Worker – Laravel Queues with Redis backend.
c. Data Tier
- MySQL – persistent storage for users, posts, comments, likes, follows, messages, notifications.
- Redis – cache layer (session, cache), queue broker.
d. Real-Time Tier
- Pusher (WebSocket) – push notifications and live messaging to connected clients.
e. External/DevOps
- SMTP/Mail Service – sending verification and notification emails.
- Storage – local filesystem or S3 for uploaded media.
- Deployment – PHP-FPM/Nginx, .env config, bootstrap, cache.

##### Relationships & Data Flows
- Client → HTTP(S) → Laravel Router → Controller → Model → MySQL
- Controller → dispatch Event → Queue (Redis) → Worker → Listener → Notification stored → Pusher → Client WebSocket
- Client uses Axios to POST comments/likes → Controller returns JSON → UI update
- Controller reads/writes cache in Redis for sessions or heavy-used queries
- Assets requests served by Vite/Mix pipeline in public/ directory

##### Architectural Patterns & Principles
- MVC (Models, Views, Controllers)
- Event-driven notifications (Events & Listeners)
- Service layer abstraction for business logic (FriendSuggestionService)
- Asynchronous processing with queues
- Modular directory layout (app/Models, app/Http, app/Services, database migrations/seeders)
- Separation of concerns: Blade for HTML, Alpine.js/Axios for dynamic behaviors

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client/UI Layer
    subgraph "Client/UI Layer"
        direction TB
        BladeViews["Blade Views\n(Blade templates)"]:::client
        AlpineJS["Alpine.js & Axios\n(JS interactivity)"]:::client
        Tailwind["Tailwind CSS"]:::client
        AssetsServer["Assets Server\n(Vite/Mix)"]:::client
    end

    %% Web/API Tier
    subgraph "Web/API Tier"
        direction TB
        HTTPKernel["HTTP Kernel & Middleware"]:::backend
        Controllers["Controllers"]:::backend
        Requests["Form Requests"]:::backend
        Services["Service Layer"]:::backend
        Events["Events"]:::backend
        Listeners["Listeners"]:::backend
        QueueConfig["Queue Configuration\n(Redis)"]:::backend
        Models["Models"]:::backend
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        MySQL["MySQL"]:::datastore
        Redis["Redis"]:::datastore
    end

    %% Real-Time / External Services
    subgraph "Real-Time & External"
        direction TB
        Pusher["Pusher\n(WebSocket)"]:::external
        MailService["SMTP/Mail Service"]:::external
        Storage["File Storage"]:::external
        EnvBoot["Env & Bootstrap\n(.env, bootstrap)"]:::external
        DevOps["Composer & Scripts"]:::external
    end

    %% Connections - Client to Web/API
    BladeViews -->|"HTTP GET/POST"| HTTPKernel
    AlpineJS -->|"AJAX via Axios"| HTTPKernel
    AssetsServer -->|"Serves assets"| BladeViews

    %% Web/API internal flows
    HTTPKernel -->|"routes"| Controllers
    Controllers -->|"validate"| Requests
    Controllers -->|"uses"| Services
    Controllers -->|"uses"| Models
    Controllers -->|"cache read/write"| Redis
    Controllers -.->|"Dispatch Event"| QueueConfig
    QueueConfig -.->|"Process Job"| Listeners
    Listeners -->|"store notifications"| MySQL
    Listeners -->|"Push to WebSocket"| Pusher
    Listeners -->|"send emails"| MailService
    Controllers -->|"file upload/download"| Storage

    %% Data connections
    Models -->|"CRUD"| MySQL
    HTTPKernel -->|"session/cache"| Redis

    %% Real-Time & External connections
    Pusher -->|"WebSocket messages"| BladeViews
    EnvBoot --> HTTPKernel
    EnvBoot --> QueueConfig

    %% Click Events
    click BladeViews "https://github.com/zinebni/uconnect/tree/main/application/resources/views"
    click AlpineJS "https://github.com/zinebni/uconnect/blob/main/application/resources/js/app.js"
    click AlpineJS "https://github.com/zinebni/uconnect/blob/main/application/resources/js/bootstrap.js"
    click Tailwind "https://github.com/zinebni/uconnect/blob/main/application/resources/css/app.css"
    click Tailwind "https://github.com/zinebni/uconnect/blob/main/application/tailwind.config.js"
    click AssetsServer "https://github.com/zinebni/uconnect/blob/main/application/vite.config.js"
    click AssetsServer "https://github.com/zinebni/uconnect/blob/main/application/public/index.php"
    click HTTPKernel "https://github.com/zinebni/uconnect/tree/main/application/app/Http"
    click HTTPKernel "https://github.com/zinebni/uconnect/blob/main/application/routes/web.php"
    click HTTPKernel "https://github.com/zinebni/uconnect/blob/main/application/routes/auth.php"
    click Controllers "https://github.com/zinebni/uconnect/tree/main/application/app/Http/Controllers"
    click Requests "https://github.com/zinebni/uconnect/tree/main/application/app/Http/Requests"
    click Services "https://github.com/zinebni/uconnect/blob/main/application/app/Services/FriendSuggestionService.php"
    click Events "https://github.com/zinebni/uconnect/tree/main/application/app/Events"
    click Listeners "https://github.com/zinebni/uconnect/tree/main/application/app/Listeners"
    click QueueConfig "https://github.com/zinebni/uconnect/blob/main/application/config/queue.php"
    click QueueConfig "https://github.com/zinebni/uconnect/blob/main/application/config/database.php"
    click MySQL "https://github.com/zinebni/uconnect/tree/main/application/database/migrations/*"
    click MySQL "https://github.com/zinebni/uconnect/tree/main/application/database/seeders/*"
    click Models "https://github.com/zinebni/uconnect/tree/main/application/app/Models"
    click Redis "https://github.com/zinebni/uconnect/blob/main/application/config/database.php"
    click Pusher "https://github.com/zinebni/uconnect/blob/main/application/config/broadcasting.php"
    click MailService "https://github.com/zinebni/uconnect/blob/main/application/config/mail.php"
    click MailService "https://github.com/zinebni/uconnect/blob/main/application/.env.example"
    click Storage "https://github.com/zinebni/uconnect/blob/main/application/config/filesystems.php"
    click Storage "https://github.com/zinebni/uconnect/tree/main/application/storage/app/public"
    click EnvBoot "https://github.com/zinebni/uconnect/blob/main/application/.env.example"
    click EnvBoot "https://github.com/zinebni/uconnect/blob/main/application/bootstrap/app.php"
    click EnvBoot "https://github.com/zinebni/uconnect/tree/main/application/bootstrap/cache"
    click DevOps "https://github.com/zinebni/uconnect/blob/main/application/composer.json"
    click DevOps "https://github.com/zinebni/uconnect/blob/main/application/package.json"
    click DevOps "https://github.com/zinebni/uconnect/blob/main/application/phpunit.xml"

    %% Styles
    classDef client fill:#e0f7fa,stroke:#0277bd,color:#000
    classDef backend fill:#e8f5e9,stroke:#2e7d32,color:#000
    classDef datastore fill:#fff3e0,stroke:#ef6c00,color:#000
    classDef external fill:#f3e5f5,stroke:#6a1b9a,color:#000
```
