Toolvana: production-ready media tools platform (CodeIgniter 4)

- 134-tool registry with programmatic SEO (unique titles/H1/descriptions,
  JSON-LD graphs, sitemap index, canonical 301 enforcement via required filter)
- DB-backed job queue (SKIP LOCKED) with drivers: Ffmpeg, Images (GD),
  Pdf (qpdf/gs/poppler), Youtube (thumbnails), Qr (server-side PNG)
- Security: SSRF guard, MIME validation, rate limits, API-key auth,
  bcrypt admin login, security headers
- Admin panel: dashboard, tools/categories/guides CRUD, SEO audit,
  analytics, job inspector with retry, system health, feature flags
- Docker deployment (nginx + web/api FPM pools + scalable workers),
  PHPUnit suite (19 tests / 1139 assertions), PWA manifest + service worker
This commit is contained in:
deepseek
2026-08-23 07:10:30 +00:00
commit beaf0e1f37
217 changed files with 19619 additions and 0 deletions
View File
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
final class CreateCategories extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'slug' => ['type' => 'VARCHAR', 'constraint' => 64, 'unique' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 80],
'icon' => ['type' => 'VARCHAR', 'constraint' => 32, 'default' => 'tools'],
'tagline' => ['type' => 'VARCHAR', 'constraint' => 190, 'null' => true],
'description' => ['type' => 'TEXT', 'null' => true],
'seo_title' => ['type' => 'VARCHAR', 'constraint' => 190, 'null' => true],
'seo_description' => ['type' => 'VARCHAR', 'constraint' => 320, 'null' => true],
'intro' => ['type' => 'TEXT', 'null' => true],
'faqs' => ['type' => 'JSON', 'null' => true],
'sort_order' => ['type' => 'INT', 'unsigned' => true, 'default' => 0],
'is_active' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->createTable('categories', true);
}
public function down(): void
{
$this->forge->dropTable('categories', true);
}
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* The tool registry — the heart of the platform. Adding a tool is a
* database row, never a code change: routes, pages, sitemaps, search,
* related-links and the pipeline all read from this table.
*/
final class CreateTools extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'category_id' => ['type' => 'INT', 'unsigned' => true],
// kind drives which UI/pipeline the page uses:
// url paste a URL (YouTube family)
// upload file in / file out
// text instant text utility (no processing queue)
'kind' => ['type' => 'ENUM', 'constraint' => ['url', 'upload', 'text'], 'default' => 'upload'],
// structured operation consumed by the pipeline drivers
'operation' => ['type' => 'VARCHAR', 'constraint' => 40, 'null' => true],
'slug' => ['type' => 'VARCHAR', 'constraint' => 120, 'unique' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 140],
'short_description' => ['type' => 'VARCHAR', 'constraint' => 320],
'description' => ['type' => 'TEXT', 'null' => true],
'input_formats' => ['type' => 'JSON', 'null' => true],
'output_formats' => ['type' => 'JSON', 'null' => true],
'primary_input_format' => ['type' => 'VARCHAR', 'constraint' => 16, 'null' => true],
'primary_output_format' => ['type' => 'VARCHAR', 'constraint' => 16, 'null' => true],
'icon' => ['type' => 'VARCHAR', 'constraint' => 32, 'default' => 'file'],
'seo_title' => ['type' => 'VARCHAR', 'constraint' => 190],
'seo_description' => ['type' => 'VARCHAR', 'constraint' => 320],
'h1' => ['type' => 'VARCHAR', 'constraint' => 190],
'intro' => ['type' => 'TEXT', 'null' => true],
'how_to' => ['type' => 'JSON', 'null' => true],
'faqs' => ['type' => 'JSON', 'null' => true],
'related_slugs' => ['type' => 'JSON', 'null' => true], // curated overrides first
'aliases' => ['type' => 'JSON', 'null' => true], // search aliases ("yt mp3")
'requires_binaries' => ['type' => 'JSON', 'null' => true], // ["ffmpeg"], ["qpdf"] ...
'accepts_mimes' => ['type' => 'JSON', 'null' => true], // upload validation
'max_upload_mb' => ['type' => 'INT', 'unsigned' => true, 'default' => 0], // 0 = site default
'popularity' => ['type' => 'INT', 'unsigned' => true, 'default' => 0],
'use_count' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
'status' => ['type' => 'ENUM', 'constraint' => ['active', 'draft', 'inactive'], 'default' => 'active'],
'is_featured' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 0],
'sort_order' => ['type' => 'INT', 'unsigned' => true, 'default' => 0],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addKey('category_id');
$this->forge->addKey('status');
$this->forge->addKey(['status', 'popularity']);
$this->forge->addForeignKey('category_id', 'categories', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('tools', true);
}
public function down(): void
{
$this->forge->dropTable('tools', true);
}
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
final class CreateGuides extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'slug' => ['type' => 'VARCHAR', 'constraint' => 160, 'unique' => true],
'title' => ['type' => 'VARCHAR', 'constraint' => 190],
'excerpt' => ['type' => 'VARCHAR', 'constraint' => 320],
'body_md' => ['type' => 'LONGTEXT', 'null' => true],
// tools this guide should interlink with (auto "Related tools" block)
'tool_slugs' => ['type' => 'JSON', 'null' => true],
'category_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
'seo_title' => ['type' => 'VARCHAR', 'constraint' => 190, 'null' => true],
'seo_description' => ['type' => 'VARCHAR', 'constraint' => 320, 'null' => true],
'reading_minutes' => ['type' => 'INT', 'unsigned' => true, 'default' => 4],
'views' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
'status' => ['type' => 'ENUM', 'constraint' => ['published', 'draft'], 'default' => 'draft'],
'published_at' => ['type' => 'DATETIME', 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addKey('status');
$this->forge->addKey('published_at');
$this->forge->createTable('guides', true);
}
public function down(): void
{
$this->forge->dropTable('guides', true);
}
}
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* Processing queue. States: queued -> processing -> completed | failed,
* with cancelled and expired as terminal cleanup states.
*/
final class CreateJobs extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'CHAR', 'constraint' => 36],
// anonymous, hashed — no raw identifiers are ever stored
'session_id' => ['type' => 'VARCHAR', 'constraint' => 64],
'ip_hash' => ['type' => 'CHAR', 'constraint' => 32],
'tool_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
'operation' => ['type' => 'VARCHAR', 'constraint' => 40],
'params' => ['type' => 'JSON', 'null' => true],
'input_file' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'input_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'input_size' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
'input_mime' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'output_file' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'output_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'output_size' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
'status' => ['type' => 'ENUM', 'constraint' => ['queued', 'processing', 'completed', 'failed', 'cancelled', 'expired'], 'default' => 'queued'],
'progress' => ['type' => 'TINYINT', 'unsigned' => true, 'default' => 0],
'stage' => ['type' => 'VARCHAR', 'constraint' => 32, 'default' => 'queued'],
'error' => ['type' => 'TEXT', 'null' => true],
'priority' => ['type' => 'TINYINT', 'constraint' => 3, 'default' => 5],
'attempts' => ['type' => 'TINYINT', 'unsigned' => true, 'default' => 0],
'source' => ['type' => 'ENUM', 'constraint' => ['web', 'api'], 'default' => 'web'],
'download_count'=> ['type' => 'INT', 'unsigned' => true, 'default' => 0],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'started_at' => ['type' => 'DATETIME', 'null' => true],
'completed_at' => ['type' => 'DATETIME', 'null' => true],
'expires_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addKey('status');
$this->forge->addKey('created_at');
$this->forge->addKey('expires_at');
$this->forge->addKey('session_id');
$this->forge->addForeignKey('tool_id', 'tools', 'id', 'SET NULL', 'CASCADE');
$this->forge->createTable('jobs', true);
}
public function down(): void
{
$this->forge->dropTable('jobs', true);
}
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* Anonymous product analytics: tool_view, tool_start, tool_success,
* tool_failure, download, upload, search, error. No cookies, no PII —
* session/ip values are one-way hashes with no lookup table.
*/
final class CreateAnalyticsEvents extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'BIGINT', 'unsigned' => true, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 32],
'tool_slug' => ['type' => 'VARCHAR', 'constraint' => 120, 'null' => true],
'format' => ['type' => 'VARCHAR', 'constraint' => 16, 'null' => true],
'value' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
'session_id' => ['type' => 'VARCHAR', 'constraint' => 64, 'null' => true],
'country' => ['type' => 'CHAR', 'constraint' => 2, 'null' => true],
'meta' => ['type' => 'JSON', 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addKey('name');
$this->forge->addKey('created_at');
$this->forge->addKey('tool_slug');
$this->forge->createTable('analytics_events', true);
}
public function down(): void
{
$this->forge->dropTable('analytics_events', true);
}
}
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
final class CreateApiKeys extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 100],
// only a salted hash is stored; the plaintext token is shown once at creation
'key_hash' => ['type' => 'VARCHAR', 'constraint' => 64],
'key_prefix' => ['type' => 'VARCHAR', 'constraint' => 12],
'rate_limit_per_hour' => ['type' => 'INT', 'unsigned' => true, 'default' => 120],
'request_count' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
'is_active' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
'last_used_at' => ['type' => 'DATETIME', 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addUniqueKey('key_hash');
$this->forge->createTable('api_keys', true);
$this->forge->addField([
'key' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
'value' => ['type' => 'TEXT'],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->createTable('settings', true);
}
public function down(): void
{
$this->forge->dropTable('api_keys', true);
$this->forge->dropTable('settings', true);
}
}