A complete CDN solution with global edge caching, token-based authentication, on-the-fly image processing, and multi-tenant user management
Features • Quick Start • Documentation • Architecture • CDN Providers
| Category | Capabilities |
|---|---|
| Global CDN Ready | 300+ Points of Presence (PoPs), automatic edge caching, 95% bandwidth reduction, sub-20ms global latency |
| Enterprise Security | Token-based authentication, role-based access control, CSRF protection, SQL injection prevention |
| Smart Image Processing | On-the-fly resizing (?w=800), WebP/AVIF conversion, filters (grayscale, sepia, blur), EXIF orientation |
| Multi-Tenant | User isolation by UUID, per-user storage quotas, bandwidth tracking, soft-delete file system |
| Plan & Credit System | Free/Pro/Business plans, credit-based upgrades, transaction history, automated notifications |
| Developer Friendly | RESTful API, multiple tokens per user, webhook ready, comprehensive documentation |
| Metric | Without CDN | With Ntsava CDN | Improvement |
|---|---|---|---|
| Global Avg Latency | 280ms | 25ms | 91% faster |
| Origin Bandwidth | 100% | 8% | 92% reduction |
| Cache Hit Ratio | 0% | 94% | Infinite |
| Server Load | High | Minimal | 95% less |
| Monthly Cost (100GB) | $15-50 | $0-5 | 90% savings |
Global Edge Network (300+ PoPs)
- PoP Maputo (Mozambique)
- PoP Tokyo (Japan)
- PoP New York (USA)
- PoP London (UK)
- PoP Sao Paulo (Brazil)
|
v
Your Origin Infrastructure
- api.yourdomain.com (PHP API + MySQL)
- cdn.yourdomain.com (Static Files)
User in Maputo
|
v
Cloudflare PoP Maputo (Cache HIT - 95% requests)
| (Cache MISS - 5% requests)
v
Your Origin Server (South Africa or Europe)
|
v
Response + Cache Headers
# Clone the repository
git clone https://github.com/lizzyman04/ntsava-app
cd ntsava-app
# Install dependencies
composer install
# Configure environment
cp .env.example .env
nano .env # Add your database and domain settings
# Run database migrations (Phinx)
composer migrate
# Seed default plans into the database
composer seed
# Set up subdomains in your hosting panel
# - cdn.yourdomain.com -> /storage
# - api.yourdomain.com -> /public
# Start the application
composer devYou're now running Ntsava CDN.
| Document | Description | Topics Covered |
|---|---|---|
| ARCHITECTURE.md | System design & data models | Database schema, Request flow, Component interaction, Security model |
| SETUP.md | Installation & DNS configuration | Requirements, Environment setup, Subdomain config, CDN integration |
| DEPLOYMENT.md | Deployment & PoP strategies | Multiple CDN providers, Edge nodes, Load balancing, Monitoring |
Ntsava is CDN-agnostic - it works with any CDN provider that supports origin pull. The architecture separates static file serving (cdn.yourdomain.com) from dynamic API operations (api.yourdomain.com), making it compatible with:
- Cloudflare (recommended for free tier)
- Bunny.net (best for video)
- AWS CloudFront (for AWS ecosystems)
- Akamai (enterprise)
- Custom Varnish edge nodes
While Ntsava works with any CDN, the documentation and examples focus on Cloudflare because:
- Free tier supports unlimited bandwidth
- 300+ global PoPs
- Built-in DDoS protection
- Automatic HTTPS and HTTP/2
- Simple configuration via DNS proxy
But you can use any provider - see DEPLOYMENT.md for alternative configurations.
| Category | Technology | Version | Purpose |
|---|---|---|---|
| Framework | Fluxor PHP | ^1.0 | File-based routing, MVC pattern, security-first |
| ORM | Cycle ORM | ^2.15 | DataMapper pattern, Entity management |
| Database | MySQL / PostgreSQL | 5.7+ / 12+ | Data persistence (agnostic, tested on both) |
| Image Processing | GD Library | PHP 8.1+ | Resize, filters, format conversion |
| CDN | Any provider | - | Global edge caching (Cloudflare, Bunny, AWS, Akamai) |
| Authentication | Token-based | - | API security |
Image/Media Hosting Platform
Scenario: A photography portfolio website
Solution:
- Users upload high-res images
- CDN serves optimized versions
- On-the-fly resizing for thumbnails
- WebP conversion for modern browsers
- 90% bandwidth savings
Software Distribution
Scenario: Distributing large files (ISOs, updates)
Solution:
- Global edge caching
- Resumable downloads support
- Bandwidth quotas per user
- Analytics dashboard
- 95% reduction in origin load
Authentication:
- Token-based: X-User-UUID + X-Token headers
- Password hashing: bcrypt (cost factor 10+)
- Session management: Secure cookies, HTTP-only
Authorization:
- Granular permissions: upload, delete, read
- Per-token expiration: configurable TTL
- Role-based: admin, moderator, user
Data Protection:
- Input validation: All user inputs sanitized
- SQL injection: ORM parameter binding
- XSS prevention: Output encoding
- CSRF protection: Token validation
File Security:
- MIME type validation: Whitelist approach
- Malware scanning: Content inspection
- Path traversal: Directory sanitization
- PHP execution: Blocked in storage
users ──┬── files (owns)
├── api_tokens (has)
├── credits (has)
├── user_roles (assigned)
└── plans (subscribes)
credits ──┬── credit_transactions (generates)
users ────┴── notifications (receives)
Key tables:
- users: UUID, email, plan_id, storage_used_bytes, bandwidth_used_bytes
- files: user_id, uuid, storage_path, size_bytes, mime_type, deleted_at
- api_tokens: user_id, token_hash, permissions, expires_at
- plans: slug, storage_limit_bytes, bandwidth_limit_bytes, max_file_size_bytes, allowed_mime_types, price
curl -X POST https://api.yourdomain.com/api/v1/upload \
-H "X-User-UUID: 550e8400-e29b-41d4-a716-446655440000" \
-H "X-Token: your-secret-token" \
-F "file=@/path/to/image.jpg" \
-F "path=gallery/2026"Response:
{
"success": true,
"data": {
"url": "https://cdn.yourdomain.com/u/johndoe/gallery/2026/image_a1b2c3.jpg",
"uuid": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"size": 245760,
"size_mb": 0.23,
"mime": "image/jpeg",
"path": "gallery/2026/image_a1b2c3.jpg"
}
}<!-- Original -->
<img src="https://cdn.yourdomain.com/u/johndoe/photo.jpg">
<!-- Thumbnail (200px wide) -->
<img src="https://cdn.yourdomain.com/u/johndoe/photo.jpg?w=200">
<!-- WebP format, 800px, grayscale -->
<img src="https://cdn.yourdomain.com/u/johndoe/photo.jpg?w=800&format=webp&filter=grayscale">
<!-- Circle crop, high quality -->
<img src="https://cdn.yourdomain.com/u/johndoe/photo.jpg?w=400&h=400&crop=center&q=90">We welcome contributions.
# Fork the repository
# Create your feature branch
git checkout -b feature/amazing-feature
# Commit your changes
git commit -m 'feat: add amazing feature'
# Push to the branch
git push origin feature/amazing-feature
# Open a Pull Request- Email: admin@tudocomlizzyman.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
GNU Affero General Public License v3.0 - see LICENSE file for details.
Built with Fluxor PHP Framework by lizzyman04
Empower your content delivery with enterprise-grade CDN technology