Skip to content

Enterprise multi-tenant learning platform | DDD + Event Sourcing | HyPerf 3.1 + PHP 8.4 + Swoole | Docker + PostgreSQL + Redis | Course management, student tracking & certification workflows

Notifications You must be signed in to change notification settings

the-php-training/phptrain-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Training - Online Learning Platform - Backend (HyPerf + Docker)

This project is a scalable, multi-tenant online learning platform built with HyPerf and powered by a containerized infrastructure using Docker. It includes support for i18n, async jobs, secure API access, content delivery, and user certification management.


⚙️ Tech Stack

Layer Stack/Tools
Backend HyPerf 3.1, PHP 8.4, Swoole
Frontend Nuxt by Vue.js (with Firebase or Cloudflare)
Database MySQL 8 (via Docker)
Caching Redis (async-queue)
Media Google Cloud Storage, YouTube/Vimeo
Hosting VPS (Hostinger), Firebase (Frontend)
SSL Certbot + Cloudflare
Container Docker + Docker Compose

🚀 Project Features

  • Multi-tenant architecture (Tenant, Course, Topic, Content)
  • Student enrollment and progress tracking
  • Video-based lessons and activity content
  • Certification generation for completed courses
  • Fully containerized backend + DB + cache
  • Auto-configured non-root user in container
  • Dark/Light theme toggle on frontend
  • Firebase or Cloudflare hosting support
  • Docker-ready for local + production environments

📦 Developer Setup

Requirements

  • Docker + Docker Compose
  • make (optional but recommended)

Quick Start

  1. Copy the environment file:

    cp src/.env.example src/.env
  2. Start the application:

    make go

    This command will:

    • Stop any existing containers
    • Install Composer dependencies
    • Build and start containers
    • Run database migrations
    • Display the API URL
  3. Access the API:

    http://localhost:8087
    

Common Commands

make go          # Full setup (install + build + start + migrate)
make up          # Start containers
make down        # Stop containers
make restart     # Restart containers
make sh          # Open shell in backend container
make logs        # Follow container logs
make log         # Follow application logs
make test        # Run tests

# Database commands
make db-migrate          # Run migrations
make db-rollback         # Rollback last migration
make db-seed             # Run database seeders

# Cache & cleanup
make cache-clear         # Clear Hyperf cache
make autoload            # Regenerate autoload files

📮 API Testing with Postman

A complete Postman collection is available at docs/postman_collection.json with all API endpoints documented and ready to use.

Available Endpoints

Tenant Management

  • POST /api/tenants - Create a new tenant
  • GET /api/tenants - List all tenants (with pagination)
  • GET /api/tenants/{id} - Get tenant by ID

Student Enrollment

  • POST /api/enrollments - Enroll student in course

Quick Start

  1. Import the collection:

    • Open Postman
    • Click "Import" → Select docs/postman_collection.json
  2. Configure variables:

    • Base URL is pre-configured: http://localhost:9501
    • Variables: tenant_id, course_id, student_id (automatically populated from responses)
  3. Start testing:

    • Ensure containers are running: make up
    • Use the requests in the collection

Each endpoint includes:

  • Complete request examples
  • Detailed descriptions
  • Expected response formats
  • Validation error examples
  • DDD bounded context information

🧪 Testing

To run the test suite:

make test

Or generate a coverage report:

make test-report

🔐 SSL

All production traffic is routed via Cloudflare, with Certbot handling SSL provisioning using DNS challenge.


📦 Future Improvements

  • WebSocket real-time updates
  • Notification system
  • Admin dashboard
  • Payment integration (Stripe or MercadoPago)

About

Enterprise multi-tenant learning platform | DDD + Event Sourcing | HyPerf 3.1 + PHP 8.4 + Swoole | Docker + PostgreSQL + Redis | Course management, student tracking & certification workflows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published