# richardktran/elteam architecture

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

- Interactive diagram: https://gitdiagram.com/richardktran/elteam
- Repository: https://github.com/richardktran/elteam

## Overview

##### Project Type and Purpose
- The project is a full-stack web application built on the Laravel PHP framework.
- Its purpose is to manage course-related functionalities—evident from controllers like CourseController, GroupController, TaskController, CurriculumController, and more.
- The frontend is organized in resources/js, containing components, pages, state management (store), routing, and API services, suggesting interactive user interfaces and SPA behavior.

##### Key Components
a. Client (Frontend):
- The browser acting as the client.
- Frontend application assets located in public/assets and resources/js.
- SPA modules (components, pages, layout) along with routing (resources/js/src/router/Router.js) and state management (store).
- Asset management using Laravel Mix (webpack.mix.js) for compiling CSS and JavaScript.

b. Web Server / Load Balancer:
- The Nginx container (under docker/nginx) which serves the application.
- Its reverse proxy role for routing HTTP requests to the Laravel backend and serving static assets.

c. Application Server (Laravel Backend):
- All core application logic is encapsulated in the app directory.
- Controllers (including Auth, Course, Group, Task, etc.) handle the incoming HTTP requests.
- Middleware, Exception Handling, and Request validation (located in app/Http/Middleware and app/Http/Requests) indicate the use of the MVC pattern.
- The event-driven architecture using Events, Listeners, and Console Commands (e.g., app/Console, app/Events, app/Listeners) is utilized for background job processing and notifications.
- Supporting services, Utilities, and response formatting (app/Services, app/Supports) round out the business logic.
- Console commands and scheduling for tasks like processing student invitations or task creation.

d. Database:
- Managed by MySQL (docker/mysql) as configured in config/database.php.
- Migrations (database/migrations) and Factories/Seeders for initial data setup.

e. Queue/Message Broker:
- RabbitMQ container (docker/rabbitmq) for background jobs and real-time event broadcasting.
- Events and Listeners (such as EmailCourseInvitationListener and GenerateGroupsEvent) that may interact asynchronously.

f. External Integrations:
- Third-party authentication from Google (app/Http/Controllers/Auth/GoogleController.php) indicating integration with external OAuth services.
- Email services (app/Mail) used to send course invitations and notifications.

##### Relationships and Interactions
- The web client makes HTTP/HTTPS requests (AJAX calls or form submissions) routed through Nginx to the Laravel backend.
- The backend uses controllers within the MVC pattern to process requests, utilizing Models, Services, and supporting utilities.
- Events triggered in the backend cause asynchronous processing via the message broker (RabbitMQ) and scheduled console commands.
- The backend communicates with the MySQL database for persistent storage.
- The frontend interacts indirectly with backend APIs through the resources/js/api modules that wrap Axios or similar HTTP clients.
- Frontend state management (using Redux or similar in resources/js/src/store) manages user interaction and updates from API responses.

##### Architectural Patterns and Principles
- MVC architectural pattern is used on the backend; separation of concerns is maintained between Controllers, Models, and Views.
- The application leverages event-driven design with event broadcasting, listeners, and background queue processing.
- Clear separation between frontend and backend logic ensures maintainability and scalability.
- Docker is used for containerization of services like PHP, Nginx, MySQL, and RabbitMQ to ensure consistent deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Client"
        FC1["Browser"]:::frontend
        FA1["Static Assets"]:::frontend
        FA2["SPA Application"]:::frontend
    end

    %% Asset Management Layer
    subgraph "Asset Management"
        AM1["Asset Management"]:::tools
    end

    %% Web Server Layer
    subgraph "Web Server Layer"
        WS1["Nginx Web Server"]:::server
    end

    %% Application Server Layer
    subgraph "Application Server Layer"
        AS1["Laravel Application Server"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB1["DB Configuration"]:::database
        DB2["DB Migrations"]:::database
        DB3["DB Container Config"]:::database
    end

    %% Queue/Message Broker Layer
    subgraph "Queue/Message Broker"
        QM1["RabbitMQ / Queue Broker"]:::queue
    end

    %% External Integrations
    subgraph "External Integrations"
        EX1["Google Authentication"]:::external
        EX2["Email Services"]:::external
    end

    %% Connections between layers
    FC1 -->|"HTTP_request"| WS1
    WS1 -->|"Routes_to"| AS1
    WS1 -->|"Serves_static"| FA1
    FA2 -->|"API_calls"| AS1
    AM1 -->|"Compiles_assets"| FA1
    AM1 -->|"Compiles_assets"| FA2
    AS1 -->|"DB_query"| DB1
    AS1 -->|"DB_query"| DB2
    AS1 -->|"Triggers_event"| QM1
    AS1 -->|"Integrates_with"| EX1
    AS1 -->|"Integrates_with"| EX2

    %% Internal Database Connections (dashed)
    DB1 -.->|"sync"| DB2
    DB1 -.-> DB3
    DB2 -.-> DB3

    %% Click Events
    click FA1 "https://github.com/richardktran/elteam/tree/develop/public/assets"
    click FA2 "https://github.com/richardktran/elteam/tree/develop/resources/js/src"
    click AM1 "https://github.com/richardktran/elteam/blob/develop/webpack.mix.js"
    click WS1 "https://github.com/richardktran/elteam/blob/develop/docker/nginx/nginx.conf"
    click AS1 "https://github.com/richardktran/elteam/tree/develop/app"
    click DB1 "https://github.com/richardktran/elteam/blob/develop/config/database.php"
    click DB2 "https://github.com/richardktran/elteam/tree/develop/database/migrations"
    click DB3 "https://github.com/richardktran/elteam/blob/develop/docker/mysql/my.cnf"
    click QM1 "https://github.com/richardktran/elteam/tree/develop/docker/rabbitmq"
    click EX1 "https://github.com/richardktran/elteam/blob/develop/app/Http/Controllers/Auth/GoogleController.php"
    click EX2 "https://github.com/richardktran/elteam/tree/develop/app/Mail"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#1f78b4,stroke-width:2px;
    classDef server fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef backend fill:#FFECB3,stroke:#F57F17,stroke-width:2px;
    classDef database fill:#ECEFF1,stroke:#607D8B,stroke-width:2px;
    classDef queue fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef external fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef tools fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;
```
