# qsnh/meedu architecture

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

- Interactive diagram: https://gitdiagram.com/qsnh/meedu
- Repository: https://github.com/qsnh/meedu

## Overview

##### First, clearly identify the main components
- API Backend (xyz.meedu.api) – A Laravel-based service handling business logic, API endpoints, authentication, course management, orders, and so on.
- Admin Panel (xyz.meedu.admin) – A separate frontend application for backend management, likely communicating with the API.
- Frontend Clients:
– PC client (xyz.meedu.pc)
– Mobile/H5 client (xyz.meedu.h5)
- Infrastructure Components:
– Docker containers: one for PHP-FPM (PHP runtime) and one for Nginx (reverse proxy/web server), with configuration files in the docker/ directory.
– Database(s): MySQL as the primary RDBMS (evident in the migrations and configuration files).
– Caching and session management via Redis.
– Other supporting services such as file storage for uploads and logs.

##### Overall separation of concerns
- Frontends (PC, H5, and Admin) on one side as “client applications” that consume the API.
- Infrastructure components (Nginx reverse proxy, PHP-FPM container, database & Redis, etc.) and illustrate the communication between these layers.
- A “Docker orchestration” environment that ties the containers together (as indicated by Dockerfile, compose.yml, and docker configuration directories).

##### Out interactions and dependencies
- Within the API backend, indicate the following interactions:
- The Laravel application’s controllers (various versioned routes like Api/V2 and Api/V3) processing requests.
- Access to MySQL for persistent data (courses, users, orders, etc.) and Redis for caching/session management.
- Integration with external services such as payment gateways (Alipay, WeChat) or third-party APIs (Tencent, Aliyun) for video services, as seen in the codebase.
- That the web server (Nginx) sits at the front end of the Dockerized environment, routing requests to the PHP-FPM backend.
- Security boundaries (firewalls, encrypted communication for sensitive endpoints) and note that the project has security guidelines for reporting vulnerabilities.

##### Architectural patterns/design principles
- The system is built on a modular monolith architecture where the API provides a clear separation from the client applications (a kind of front/back separation).
- The frontends are built as single‐page applications with React (or similar, indicated by .tsx and scss files), which implies emphasis on client-side interactivity and state management.
- The use of Docker ensures containerization for development and production, so container orchestration is an important element.
- The system leverages event-driven processes (see extensive use of events & listeners in the API code) for asynchronous processing like payment success handling, media updates, etc.

- HTTP/HTTPS data flow from the frontend clients to the backend API.
- Internal API calls from the Laravel backend to MySQL and Redis.
- Docker orchestration flows (e.g., from docker-compose to containers).
- Backend/API elements (e.g., rectangles),
- Annotations for specific technologies like “PHP7.4 + Laravel8”, “MySQL”, “Redis”, “Docker”, “Nginx”, and integrations with “Aliyun/Tencent”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Applications Layer
    subgraph "Client Applications"
        admin["Admin Panel (React/TSX)"]:::client
        pc["PC Client"]:::client
        h5["H5/Mobile Client"]:::client
    end

    %% Backend API Layer
    subgraph "Backend API Layer"
        api["Laravel API Backend"]:::backend
        controllers["API Controllers (V2/V3)"]:::backend
        api -->|"Handles"| controllers
    end

    %% Infrastructure and Services Layer
    subgraph "Infrastructure & Services"
        subgraph "Docker Containers"
            nginx["Nginx Container"]:::infra
            php["PHP‑FPM Container"]:::infra
        end
        dockerOrch["Docker Orchestration"]:::infra
        db["MySQL Database"]:::db
        redis["Redis Cache"]:::db
        external["External Services (PaymentGateways/VideoProcessing)"]:::external
    end

    %% Connections from Clients to Backend
    admin -->|"HTTPcalls"| api
    pc -->|"HTTPcalls"| api
    h5 -->|"HTTPcalls"| api

    %% API interactions with Infrastructure
    api -->|"DBqueries"| db
    api -->|"Cacheaccess"| redis
    api -->|"APIcalls"| external
    api -.->|"EventNotifications"| external

    %% Docker and Container interactions
    dockerOrch --> nginx
    dockerOrch --> php
    nginx -->|"Routes"| php
    php -->|"Executes"| api

    %% Click Events for Component Mapping
    click api "https://github.com/qsnh/meedu/tree/main/xyz.meedu.api/"
    click admin "https://github.com/qsnh/meedu/tree/main/xyz.meedu.admin/"
    click pc "https://github.com/qsnh/meedu/tree/main/xyz.meedu.pc/"
    click h5 "https://github.com/qsnh/meedu/tree/main/xyz.meedu.h5/"
    click dockerOrch "https://github.com/qsnh/meedu/tree/main/docker/"

    %% Styles
    classDef client fill:#ffefef,stroke:#d9534f,stroke-width:2px;
    classDef backend fill:#e6f7ff,stroke:#5bc0de,stroke-width:2px;
    classDef infra fill:#f2f2f2,stroke:#aaaaaa,stroke-width:2px;
    classDef db fill:#fff2cc,stroke:#f0ad4e,stroke-width:2px;
    classDef external fill:#dff0d8,stroke:#5cb85c,stroke-width:2px;
```
