╔══════════════════════════════════════════════════════════════════════════════╗ ║ TEMPORY - ARCHITECTURE COMPLÈTE ║ ║ Plateforme SaaS de Transfert de Fichiers ║ ╚══════════════════════════════════════════════════════════════════════════════╝ ┌──────────────────────────────────────────────────────────────────────────────┐ │ 1. STACK TECHNIQUE │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────┐ │ CLIENT │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ HTML5 │ │ CSS3 │ │ JavaScript │ │ │ │ Responsive │ │ Tailwind │ │ Vanilla │ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ └─────────────────────────────┬───────────────────────────────┘ │ HTTPS (TLS 1.3) ┌─────────────────────────────▼───────────────────────────────┐ │ NGINX (Reverse Proxy) │ │ • SSL/TLS Termination │ │ • Rate Limiting (10 req/s) │ │ • Static Files Caching │ │ • Security Headers (HSTS, CSP, X-Frame-Options) │ │ • X-Accel-Redirect (Private Files) │ └─────────────────────────────┬───────────────────────────────┘ │ FastCGI ┌─────────────────────────────▼───────────────────────────────┐ │ PHP-FPM 8.4 │ │ ┌──────────────────────────────────────────────────────┐ │ │ │ APPLICATION LAYER │ │ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ │ │Controllers│ │ Services │ │ Models │ │ │ │ │ └──────────┘ └──────────┘ └──────────┘ │ │ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ │ │Middleware│ │Validators│ │ Security │ │ │ │ │ └──────────┘ └──────────┘ └──────────┘ │ │ │ └──────────────────────────────────────────────────────┘ │ └─────────────────────────────┬───────────────────────────────┘ │ ┌───────────────────┴───────────────────┐ │ │ ┌─────────▼──────────┐ ┌─────────▼──────────┐ │ MySQL 8.0 │ │ Storage Layer │ │ ┌────────────┐ │ │ ┌──────────────┐ │ │ │ users │ │ │ │ /files/ │ │ │ │ files │ │ │ │ /invoices/ │ │ │ │subscriptions│ │ │ │ /logs/ │ │ │ │ payments │ │ │ │ /cache/ │ │ │ │promo_codes │ │ │ └──────────────┘ │ │ │ logs │ │ │ (Hors webroot) │ │ └────────────┘ │ └────────────────────┘ └────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────┐ │ 2. STRUCTURE DE FICHIERS │ └──────────────────────────────────────────────────────────────────────────────┘ /var/www/tempory/ │ ├── public/ # Webroot (seul dossier accessible web) │ ├── index.php # Point d'entrée unique │ ├── .htaccess # Config Apache/Nginx │ ├── assets/ │ │ ├── css/ # Styles │ │ ├── js/ # JavaScript │ │ └── media/ # Images, icônes │ └── download.php # Page téléchargement │ ├── app/ # Code application (HORS WEBROOT) │ ├── Config/ │ │ ├── Database.php # Connexion BDD │ │ ├── App.php # Config app │ │ └── Security.php # Config sécurité │ │ │ ├── Controllers/ │ │ ├── AuthController.php # Authentification │ │ ├── FileController.php # Gestion fichiers │ │ ├── UserController.php # Gestion utilisateurs │ │ └── AdminController.php # Admin panel │ │ │ ├── Models/ │ │ ├── BaseModel.php # Modèle de base │ │ ├── User.php # Modèle utilisateur │ │ ├── File.php # Modèle fichier │ │ └── Subscription.php # Modèle abonnement │ │ │ ├── Services/ │ │ ├── AuthService.php # Logique auth │ │ ├── FileService.php # Logique fichiers │ │ ├── PaymentService.php # Paiements │ │ └── WebhookService.php # Webhooks │ │ │ ├── Middleware/ │ │ ├── AuthMiddleware.php # Vérif auth │ │ ├── RoleMiddleware.php # RBAC │ │ ├── CsrfMiddleware.php # Protection CSRF │ │ └── RateLimitMiddleware.php # Rate limiting │ │ │ ├── Security/ │ │ ├── Sanitizer.php # Nettoyage données │ │ ├── AuditLogger.php # Logs sécurité │ │ └── Encryption.php # Chiffrement │ │ │ └── Utils/ │ ├── Response.php # Réponses HTTP │ ├── Mailer.php # Envoi emails │ └── FileHelper.php # Utilitaires fichiers │ ├── storage/ # Stockage (HORS WEBROOT) │ ├── files/ # Fichiers uploadés │ │ ├── 00/ # Sharding │ │ ├── 01/ │ │ └── ... │ ├── invoices/ # Factures PDF │ ├── logs/ # Logs applicatifs │ ├── cache/ # Cache │ └── temp/ # Fichiers temporaires │ ├── config/ │ ├── .env # Variables environnement │ └── .env.example # Template .env │ ├── database/ │ ├── complete_schema.sql # Schéma complet BDD │ └── migrations/ # Migrations │ ├── cron/ │ ├── cleanup_files.php # Nettoyage fichiers │ └── expire_subscriptions.php # Expiration abonnements │ └── docs/ # Documentation ├── README.md ├── ARCHITECTURE_BACKEND.php └── GUIDE_COMPLET.md ┌──────────────────────────────────────────────────────────────────────────────┐ │ 3. FLUX DE DONNÉES │ └──────────────────────────────────────────────────────────────────────────────┘ ╔═══════════════════════════════════════════════════════════════════════════╗ ║ UPLOAD DE FICHIER ║ ╚═══════════════════════════════════════════════════════════════════════════╝ Client Nginx PHP-FPM MySQL Storage │ │ │ │ │ │──POST /api/upload───▶│ │ │ │ │ │──FastCGI──────────▶│ │ │ │ │ │ │ │ │ │ │──Auth Check─────▶│ │ │ │ │◀─User Data───────│ │ │ │ │ │ │ │ │ │──Validate File───│ │ │ │ │ (MIME, Size) │ │ │ │ │ │ │ │ │ │──Check Limits───▶│ │ │ │ │◀─User Stats──────│ │ │ │ │ │ │ │ │ │──Store File─────────────────▶│ │ │ │ │ (UUID) │ │ │ │ │ │ │ │──Insert Record──▶│ │ │ │ │◀─File ID─────────│ │ │ │ │ │ │ │ │ │──Webhook─────────│ │ │ │ │ (Discord) │ │ │ │ │ │ │ │ │◀─JSON Response─────│ │ │ │◀─200 OK──────────────│ │ │ │ │ {file_id, link} │ │ │ │ ╔═══════════════════════════════════════════════════════════════════════════╗ ║ TÉLÉCHARGEMENT DE FICHIER ║ ╚═══════════════════════════════════════════════════════════════════════════╝ Client Nginx PHP-FPM MySQL Storage │ │ │ │ │ │──GET /d/:uuid────────▶│ │ │ │ │ │──FastCGI──────────▶│ │ │ │ │ │ │ │ │ │ │──Find File──────▶│ │ │ │ │◀─File Data───────│ │ │ │ │ │ │ │ │ │──Check Expiry────│ │ │ │ │──Check Limits────│ │ │ │ │ │ │ │ │ ┌───Password?───┤ │ │ │ │ │ │ │ │ │◀──Password Form──────│◀───┘ │ │ │ │ │ │ │ │ │──POST password───────▶│──FastCGI──────────▶│ │ │ │ │ │──Verify Hash─────│ │ │ │ │ │ │ │ │ │──Generate Token──│ │ │ │ │ (5 min, APCu) │ │ │ │ │ │ │ │ │◀─Download URL──────│ │ │ │◀─Redirect────────────│ │ │ │ │ │ │ │ │ │──GET /serve?token────▶│ │ │ │ │ │──FastCGI──────────▶│ │ │ │ │ │──Verify Token────│ │ │ │ │ (APCu) │ │ │ │ │ │ │ │ │ │──X-Accel-Redirect────────────▶│ │ │◀──────────────────────────────────────────────────│ │◀─File Stream─────────│ │ │ (Read) │ │ │ │ │ │ │ │──Increment Count▶│ │ │ │ │──Log Download───▶│ │ ╔═══════════════════════════════════════════════════════════════════════════╗ ║ ABONNEMENT PAYPAL ║ ╚═══════════════════════════════════════════════════════════════════════════╝ Client Frontend Backend PayPal MySQL │ │ │ │ │ │──Click Premium────▶│ │ │ │ │ │──Load PayPal SDK──▶│ │ │ │ │ │──API Request────▶│ │ │ │ │◀─Plan Details────│ │ │ │ │ │ │ │◀─PayPal Buttons────│ │ │ │ │ │ │ │ │ │──Approve───────────────────────────────────────────────▶│ │ │ │ │ │ │ │ │ │◀─Subscription ID─│ │ │ │◀─Success───────────│ │ │ │ │ │──Create Sub─────────────────▶│ │ │ │ │ (pending) │ │ │ │ │ │ │ │ ┌─────────────────Webhook────────│ │ │ │ │ │ (ACTIVATED) │ │ │ │ │ │ │ │ │ │ └────────────▶│──Update Status──────────────▶│ │ │ │ │ (active) │ │ │ │──Send Email─────▶│ │ │ │ │ │ │ │◀─Confirmation Email────────────────────│ │ │ ┌──────────────────────────────────────────────────────────────────────────────┐ │ 4. MODÈLE DE SÉCURITÉ │ └──────────────────────────────────────────────────────────────────────────────┘ ╔═══════════════════════════════════════════════════════════════════════════╗ ║ COUCHES DE SÉCURITÉ ║ ╚═══════════════════════════════════════════════════════════════════════════╝ ┌─────────────────────────────────────────────────────────────────────────┐ │ Layer 1: Network Security │ │ ├─ Firewall (UFW): Ports 80/443 only │ │ ├─ DDoS Protection: CloudFlare (optionnel) │ │ └─ SSL/TLS 1.3: Let's Encrypt │ └─────────────────────────────────────────────────────────────────────────┘ │ ┌──────────────────────────────────▼──────────────────────────────────────┐ │ Layer 2: Web Server Security (Nginx) │ │ ├─ Rate Limiting: 10 req/s global, 5 req/m auth │ │ ├─ Headers: HSTS, CSP, X-Frame-Options, X-Content-Type-Options │ │ ├─ Hide Version: server_tokens off │ │ └─ Access Control: Block .env, .sql, .log files │ └─────────────────────────────────────────────────────────────────────────┘ │ ┌──────────────────────────────────▼──────────────────────────────────────┐ │ Layer 3: Application Security (PHP) │ │ ├─ Authentication: Argon2id password hashing │ │ ├─ Session: httponly, secure, samesite=strict cookies │ │ ├─ CSRF: Token validation on all POST/PUT/DELETE │ │ ├─ XSS: htmlspecialchars() on all output │ │ ├─ SQL Injection: Prepared statements ONLY │ │ ├─ File Upload: MIME validation + extension whitelist │ │ └─ Rate Limiting: APCu-based per user/IP │ └─────────────────────────────────────────────────────────────────────────┘ │ ┌──────────────────────────────────▼──────────────────────────────────────┐ │ Layer 4: Data Security │ │ ├─ Database: Least privilege user, prepared statements │ │ ├─ Files: Stored outside webroot, UUID naming │ │ ├─ Passwords: Argon2id with salt │ │ ├─ Tokens: Cryptographically secure (random_bytes) │ │ └─ Logs: Audit trail for all sensitive operations │ └─────────────────────────────────────────────────────────────────────────┘ │ ┌──────────────────────────────────▼──────────────────────────────────────┐ │ Layer 5: Monitoring & Response │ │ ├─ Logging: Nginx, PHP-FPM, Application, Audit │ │ ├─ Alerts: Disk space, RAM, Error rates │ │ ├─ Backup: Daily DB, Weekly files │ │ └─ Updates: Security patches within 24h │ └─────────────────────────────────────────────────────────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────┐ │ 5. PERMISSIONS & RÔLES (RBAC) │ └──────────────────────────────────────────────────────────────────────────────┘ ╔═══════════════════════════════════════════════════════════════════════════╗ ║ MATRICE DE PERMISSIONS ║ ╚═══════════════════════════════════════════════════════════════════════════╝ ┌────────────────────────┬──────────┬──────────┬──────────┬──────────┐ │ PERMISSION │ Guest │ Free │ Premium │ Admin │ ├────────────────────────┼──────────┼──────────┼──────────┼──────────┤ │ Voir fichiers publics │ ✅ │ ✅ │ ✅ │ ✅ │ │ Télécharger fichiers │ ✅ │ ✅ │ ✅ │ ✅ │ │ S'inscrire │ ✅ │ ✅ │ ✅ │ ❌ │ │ │ │ │ │ │ │ Upload fichiers │ ❌ │ ✅ │ ✅ │ ✅ │ │ Max fichiers actifs │ - │ 2 │ 15 │ ∞ │ │ Taille max fichier │ - │ 100 MB │ 10 GB │ ∞ │ │ Rétention max │ - │ 3 jours │ 14 jours │ ∞ │ │ │ │ │ │ │ │ Lien personnalisé │ ❌ │ ❌ │ ✅ │ ✅ │ │ Mot de passe fichier │ ❌ │ ❌ │ ✅ │ ✅ │ │ Limite téléchargements │ ❌ │ ❌ │ ✅ │ ✅ │ │ Statistiques détaillées│ ❌ │ ❌ │ ✅ │ ✅ │ │ │ │ │ │ │ │ Gérer tous fichiers │ ❌ │ ❌ │ ❌ │ ✅ │ │ Gérer utilisateurs │ ❌ │ ❌ │ ❌ │ ✅ │ │ Voir paiements │ ❌ │ ❌ │ ❌ │ ✅ │ │ Créer codes promo │ ❌ │ ❌ │ ❌ │ ✅ │ │ Modifier paramètres │ ❌ │ ❌ │ ❌ │ ✅ │ │ Accès logs système │ ❌ │ ❌ │ ❌ │ ✅ │ └────────────────────────┴──────────┴──────────┴──────────┴──────────┘ ┌──────────────────────────────────────────────────────────────────────────────┐ │ 6. PERFORMANCE & SCALABILITÉ │ └──────────────────────────────────────────────────────────────────────────────┘ ╔═══════════════════════════════════════════════════════════════════════════╗ ║ OPTIMISATIONS APPLIQUÉES ║ ╚═══════════════════════════════════════════════════════════════════════════╝ Database: ├─ Index optimisés sur toutes les colonnes fréquemment requêtées ├─ Connexions persistantes (PDO persistent) ├─ Query caching (MySQL query cache) └─ Pagination sur toutes les listes Caching: ├─ APCu pour sessions et rate limiting ├─ Static files caching (Nginx) ├─ Browser caching (Cache-Control headers) └─ OpCache PHP activé Files: ├─ Sharding par préfixe UUID (256 dossiers) ├─ X-Accel-Redirect pour envoi fichiers volumineux ├─ Compression GZIP (Nginx) └─ Lazy loading des images Code: ├─ Autoloading PSR-4 ├─ Lazy initialization des services ├─ Prepared statements (réutilisables) └─ Éviter les N+1 queries Monitoring: ├─ Slow query log (MySQL) ├─ PHP-FPM status page ├─ Nginx status page └─ Application metrics (custom) ╔═══════════════════════════════════════════════════════════════════════════╗ ║ CAPACITÉ PRÉVUE ║ ╚═══════════════════════════════════════════════════════════════════════════╝ Configuration VPS Standard (4 Go RAM, 2 vCPU, 80 Go SSD): • Utilisateurs simultanés : ~500 • Uploads/heure : ~1000 • Downloads/heure : ~5000 • Stockage total : ~50-100 Go (selon fichiers) • Trafic/mois : ~1-2 To Scaling Options: ├─ Vertical : Augmenter RAM/CPU (jusqu'à 16 Go RAM) ├─ Horizontal : Load balancer + plusieurs serveurs web ├─ CDN : CloudFlare pour static assets └─ Stockage : S3/Wasabi pour fichiers volumineux ╔═══════════════════════════════════════════════════════════════════════════╗ ║ FIN DU DIAGRAMME ║ ╚═══════════════════════════════════════════════════════════════════════════╝ Documentation générée le 22 décembre 2025 Version 2.0 - Production Ready Pour plus d'informations, consultez: - docs/README.md - Index documentation - docs/GUIDE_COMPLET.md - Guide détaillé - docs/ARCHITECTURE_BACKEND.php - Architecture code - database/complete_schema.sql - Schéma BDD Bon courage pour le développement ! 🚀