Skip to content

ahmedsaadawi13/splash-courses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SplashCourses - Multi-Tenant Online Learning Management System

Overview

SplashCourses is a complete multi-tenant SaaS platform for online courses and knowledge businesses, built with pure PHP and MySQL. Similar in spirit to Teachable, Kajabi, and Thinkific, it provides everything needed to run an online course business at scale.

Target Users

  • Course creators & online educators
  • Training academies & universities
  • Corporate training departments
  • Coaching & consulting businesses

Key Features

🏢 Multi-Tenant Architecture

  • Fully isolated tenant data with single shared database
  • Subscription plans with quota enforcement
  • Usage tracking (courses, students, storage, API calls)
  • Customizable branding per tenant

📚 Learning Management System (LMS)

  • Unlimited courses, modules, and lessons
  • Multiple content types: video, text, downloads, quizzes
  • Progress tracking and course completion
  • Certificates of completion
  • Preview lessons for marketing

🎓 Quizzes & Assessments

  • Multiple question types (MCQ single/multi, true/false, short text)
  • Configurable passing scores
  • Attempt limits
  • Auto-grading with detailed results

💳 Monetization

  • One-time course purchases
  • Subscription memberships
  • Course bundles
  • Free courses
  • Simulated payment processing (ready for Stripe/PayPal integration)

🤝 Affiliate System

  • Referral tracking with unique codes
  • Configurable commission rates (percent or fixed)
  • Click tracking and conversion attribution
  • Commission management

📊 Analytics & Reporting

  • Student progress dashboards
  • Instructor revenue tracking
  • Course performance metrics
  • Platform-wide admin analytics

🔌 REST API

  • Public API for integrations
  • API key authentication
  • Course catalog access
  • Enrollment management
  • Progress tracking

Tech Stack

  • Backend: PHP 7.0+ (compatible with 7.x - 8.x)
  • Database: MySQL 5.7+ / MariaDB 10.2+
  • Architecture: Custom lightweight MVC (no frameworks)
  • Frontend: Vanilla JavaScript + responsive CSS
  • Security: PDO prepared statements, CSRF protection, password hashing

Requirements

  • PHP 7.0 or higher
  • MySQL 5.7+ or MariaDB 10.2+
  • Apache/Nginx web server
  • PHP Extensions:
    • pdo_mysql
    • mbstring
    • openssl
    • json
    • fileinfo

Installation

1. Clone the Repository

git clone https://github.com/ahmedsaadawi13/splashcourses.git
cd splashcourses

2. Configure Environment

cp .env.example .env

Edit .env with your database credentials:

APP_ENV=development
APP_DEBUG=true
APP_URL=http://localhost

DB_HOST=localhost
DB_DATABASE=splashcourses
DB_USERNAME=root
DB_PASSWORD=your_password_here

3. Create Database

mysql -u root -p
CREATE DATABASE splashcourses CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

4. Import Database Schema

mysql -u root -p splashcourses < database.sql

This will create all tables and insert seed data including:

  • Demo tenant ("Demo Academy")
  • Sample users with different roles
  • Example courses with content
  • Quiz questions and certificates

5. Set File Permissions

chmod -R 755 storage/
chmod -R 755 storage/uploads/
chmod -R 755 storage/logs/

6. Configure Web Server

Apache

Ensure mod_rewrite is enabled and set DocumentRoot to /path/to/splashcourses/public

Example VirtualHost:

<VirtualHost *:80>
    ServerName splashcourses.local
    DocumentRoot /var/www/splashcourses/public

    <Directory /var/www/splashcourses/public>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/splashcourses_error.log
    CustomLog ${APACHE_LOG_DIR}/splashcourses_access.log combined
</VirtualHost>

Nginx

server {
    listen 80;
    server_name splashcourses.local;
    root /var/www/splashcourses/public;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

7. Access the Application

Open your browser and navigate to:

Default Credentials

Platform Admin

Demo Tenant Owner

Demo Instructor

Demo Students

⚠️ IMPORTANT: Change all default passwords immediately after installation!

Project Structure

splashcourses/
├── app/
│   ├── core/               # MVC framework core
│   │   ├── Database.php
│   │   ├── Router.php
│   │   ├── Controller.php
│   │   ├── Model.php
│   │   ├── View.php
│   │   ├── Auth.php
│   │   ├── Session.php
│   │   ├── Request.php
│   │   ├── Response.php
│   │   └── CSRF.php
│   ├── controllers/        # Application controllers
│   ├── models/            # Database models
│   ├── views/             # View templates
│   └── helpers/           # Helper utilities
├── config/                # Configuration files
├── public/                # Public web root
│   ├── index.php         # Application entry point
│   ├── .htaccess         # Apache rewrite rules
│   └── assets/           # CSS, JS, images
├── storage/
│   ├── uploads/          # User uploaded files
│   └── logs/             # Application logs
├── tests/                # Test scripts
├── database.sql          # Database schema & seed data
├── .env.example          # Environment template
└── README.md             # This file

Usage Guide

Creating a Course

  1. Login as instructor or tenant owner
  2. Navigate to "My Courses" or "Manage Courses"
  3. Click "Create New Course"
  4. Fill in course details:
    • Title, subtitle, description
    • Level (beginner/intermediate/advanced)
    • Category
    • Pricing (free or paid)
  5. Save as draft
  6. Add modules and lessons
  7. Publish when ready

Course Structure

Course
├── Module 1
│   ├── Lesson 1 (Video)
│   ├── Lesson 2 (Text)
│   └── Lesson 3 (Quiz)
├── Module 2
│   ├── Lesson 4 (Video)
│   └── Lesson 5 (Download)
└── ...

Student Enrollment Flow

  1. Browse courses at /demo/courses
  2. Click on a course to view details
  3. Click "Enroll Now"
  4. For free courses: instant enrollment
  5. For paid courses: simulated checkout process
  6. Access course from student dashboard
  7. Track progress automatically
  8. Earn certificate upon completion

Certificates

Certificates are automatically generated when students complete all lessons in a course. Each certificate has:

  • Unique verification code
  • Public verification URL: /certificate/{code}
  • Downloadable HTML (PDF generation can be added)

Affiliate Marketing

  1. Create affiliate account in tenant admin
  2. Generate unique referral code
  3. Share referral link: /demo?ref={code}
  4. Track clicks and conversions
  5. Earn commissions on sales
  6. View earnings in affiliate dashboard

REST API

Authentication

All API requests require an API key in the header:

X-API-KEY: your_api_key_here

Endpoints

Get All Published Courses

GET /api/courses

Query parameters:

  • category - Filter by category ID
  • free_only - Show only free courses (1/0)
  • search - Search in title/description

Response:

{
  "success": true,
  "data": [...],
  "count": 2
}

Get Course Details

GET /api/courses/{id or slug}

Response:

{
  "success": true,
  "data": {
    "course": {...},
    "modules": [...]
  }
}

Create Enrollment

POST /api/enrollments/create

Body:

{
  "student": {
    "email": "john@example.com",
    "name": "John Doe"
  },
  "course_id": 1
}

Get Student Progress

GET /api/students/{student_id}/courses/{course_id}/progress

API Example

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "http://localhost/api/courses",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-API-KEY: demo_api_key_1234567890abcdef1234567890abcdef1234567890abcdef"
    ]
]);

$response = curl_exec($curl);
curl_close($curl);

$data = json_decode($response, true);

Testing

Run the included test scripts to verify installation:

# Test database connection
php tests/test_db_connection.php

# Test course creation
php tests/test_course_creation.php

# Test enrollment flow
php tests/test_enrollment_flow.php

# Test API (requires running server)
php tests/test_api.php

Security Features

  • Password Hashing: BCrypt via password_hash()
  • SQL Injection Prevention: PDO prepared statements only
  • XSS Protection: htmlspecialchars() on all outputs
  • CSRF Protection: Token validation on all forms
  • Session Security: session_regenerate_id() on login
  • Login Throttling: Brute force protection with lockout
  • Tenant Isolation: Strict filtering on all queries
  • File Upload Validation: MIME type and size checks
  • API Rate Limiting: Via usage tracking

Quota Enforcement

Each subscription plan has quotas for:

  • Maximum courses
  • Maximum students
  • Maximum instructors
  • Maximum storage (bytes)
  • Maximum membership tiers
  • API calls per month

The system automatically enforces these limits and provides clear error messages when quotas are exceeded.

Email System

Emails are currently logged to /storage/logs/email_log.txt.

To integrate real email service:

  1. Install PHPMailer or use built-in mail()
  2. Update app/helpers/MailerHelper.php
  3. Configure SMTP settings in .env

Triggered emails:

  • Enrollment confirmation
  • Payment receipts
  • Certificate issuance
  • Password reset
  • Welcome messages

Payment Integration

The payment system is currently simulated. To integrate real payments:

Stripe Integration

// In app/helpers/PaymentHelper.php
require_once 'vendor/autoload.php';

\Stripe\Stripe::setApiKey('your_secret_key');

$charge = \Stripe\Charge::create([
    'amount' => $amount * 100,
    'currency' => 'usd',
    'source' => $token,
    'description' => 'Course purchase'
]);

PayPal Integration

Similar integration can be done with PayPal REST API or other payment gateways like Braintree, Square, or Paddle.

Scaling Recommendations

Database Optimization

  • Add indexes on frequently queried columns
  • Implement query caching
  • Use read replicas for analytics
  • Consider partitioning large tables

File Storage

  • Move uploads to S3/CloudFlare R2/DigitalOcean Spaces
  • Implement CDN for static assets
  • Use cloud storage for videos

Performance

  • Add Redis/Memcached for session storage
  • Implement application-level caching
  • Use queue systems (Redis Queue, RabbitMQ) for emails
  • Enable OPcache for PHP

High Availability

  • Load balancer (HAProxy, Nginx)
  • Multiple web servers
  • Database clustering
  • Automated backups

Customization

Adding New User Roles

  1. Add role to users table enum
  2. Update permissions in controllers
  3. Create role-specific dashboard view
  4. Update navigation menus

Custom Themes

  1. Edit /public/assets/css/style.css
  2. Or add per-tenant theme CSS in database
  3. Load custom CSS based on tenant.theme_settings_json

Adding Content Types

  1. Add type to course_lessons.content_type enum
  2. Create handler in LessonController
  3. Add view template
  4. Update lesson creation form

Troubleshooting

Database Connection Errors

  • Check .env credentials
  • Verify MySQL is running
  • Test connection: php tests/test_db_connection.php

404 Errors on All Pages

  • Ensure mod_rewrite is enabled (Apache)
  • Check .htaccess is in /public
  • Verify DocumentRoot points to /public

File Upload Errors

  • Check storage directory permissions
  • Verify upload_max_filesize in php.ini
  • Ensure post_max_size is sufficient

Session Issues

  • Check session directory is writable
  • Verify session.save_path in php.ini
  • Clear browser cookies

License

This project is provided as-is for educational and commercial use.

Support

For issues, feature requests, or contributions:

Credits

Built with:

  • Custom PHP MVC Architecture
  • MySQL Database
  • Vanilla JavaScript
  • Pure CSS

Changelog

Version 1.0.0 (Initial Release)

  • Multi-tenant architecture
  • Complete LMS functionality
  • Quiz system
  • Certificate generation
  • Affiliate program
  • REST API
  • Payment simulation
  • 50+ database tables
  • Responsive UI
  • Security hardening
  • Comprehensive documentation

Happy Teaching! 🎓

About

SplashCourses is a complete multi-tenant SaaS platform for online courses and knowledge businesses, built with pure PHP and MySQL. Similar in spirit to Teachable, Kajabi, and Thinkific, it provides everything needed to run an online course business at scale.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors