Overview
The Vaniyk Empire API supports three types of digital content: PDFs, videos, and audio files. Content management involves uploading files to Cloudinary, storing metadata in MongoDB, and controlling access based on purchase status.Content Types
The system supports three distinct content types, each with specific handling:Documents and ebooks stored as Cloudinary
image resource typeVideo
Video content with duration tracking, stored as
video resource typeAudio
Audio files with duration tracking, stored as
video resource typeContent Model Schema
Every content item in the database follows this structure:The text search index on
title, description, and tags enables full-text search functionality across content items.File Upload Flow
Content uploads use Multer with Cloudinary storage to handle file uploads directly to the cloud.Upload Configuration
The upload system is configured in/workspace/source/src/config/cloudinary.js:12:
Cloudinary Folder Structure
Files are automatically organized in Cloudinary:Upload Endpoint
Admins can create content via the POST endpoint with multipart form data:Create Content Logic
The controller handles the complete upload and database creation flow:Cloudinary automatically extracts metadata like
duration for video/audio files and bytes for file size. These values are stored in the database for quick access.Content Lifecycle
Content Status
Content can be in one of two states:- Draft
- Published
Draft content:
- Not visible in public listings
- Cannot be purchased
- Visible only to admin users
- Used for content preparation
Access Control
The API implements a three-tier access control system:1. Public Access (Unauthenticated)
Anyone can browse published content metadata:Public endpoints explicitly exclude
fileUrl and filePublicId fields to prevent unauthorized access to content files.2. Authenticated User Access
Authenticated users who have purchased content can access the file:3. Admin Access
Admins have full access to all content, including drafts:Access Flow Diagram
Updating Content
Admins can update content, including replacing files:Deleting Content
Deleting content removes both database records and Cloudinary files:Search and Filtering
The list endpoint supports powerful filtering:User Purchase History
Users can retrieve their purchased content:Best Practices
Use Drafts
Create content as drafts first, review, then publish to avoid exposing incomplete content
Add Thumbnails
Always upload thumbnails for better user experience in content listings
Tag Appropriately
Use descriptive tags to improve searchability and content discovery
Set Correct Types
Ensure content type matches file type for proper Cloudinary handling
Next Steps
Payment Flow
Learn how payments work for content purchases
Content API Reference
Explore the complete Content API documentation