Based on the analysis of the frontend code, here's a comprehensive plan for the backend API functionality needed to support the FileFlow application.
- User Authentication: Support Auth0 integration for user authentication
- Storage Quota Management: Track and manage user storage limits and usage
- File Upload: Support single and multiple file uploads
- File Download: Allow downloading individual files
- File Metadata: Store and retrieve file metadata (name, type, size)
- File Content: Store and serve file content
- File Renaming: Allow renaming files
- File Moving: Support moving files between folders
- File Deletion: Move files to trash and permanent deletion
- Folder Creation: Create new folders
- Folder Renaming: Rename existing folders
- Folder Moving: Move folders to different locations
- Folder Deletion: Move folders to trash and permanent deletion
- Starred Items: Mark/unmark files and folders as starred
- Recent Items: Track and retrieve recently accessed files
- Trash Management: Store deleted items and support restoration or permanent deletion
{
"id": "string",
"userId": "string",
"maxSpace": "number", // In MB
"usedSpace": "number", // In MB
"storageBreakdown": {
"documents": "number", // In MB
"images": "number", // In MB
"videos": "number", // In MB
"other": "number" // In MB
}
}{
"id": "string",
"userId": "string",
"name": "string", // Includes extension (for files)
"type": "string", // "file" or "folder"
"isStarred": "boolean",
"parentId": "number | null", // ID of parent folder, null if in root
"path": "string", // Full path to the item (includes name)
"size": "number | null", // Size in MB (for files)
"mimeType": "string | null", // MIME type (for files)
"isInTrash": "boolean"
}- Integrate with Auth0 for authentication
- Implement necessary endpoints for user registration and profile management
GET /api/users/storage: Get user storage
POST /api/files: Upload new fileGET /api/files/{id}: Get file metadataGET /api/files/{id}/download: Download file contentGET /api/files/{id}/preview: Preview file contentPUT /api/files/{id}: Update file metadata (rename)DELETE /api/files/{id}: Move file to trashPOST /api/files/{id}/restore: Restore file from trashDELETE /api/files/{id}/permanent: Permanently delete file
POST /api/folders: Create new folderGET /api/folders/{id}: Get folder metadataPUT /api/folders/{id}: Update folder metadata (rename)DELETE /api/folders/{id}: Move folder to trashPOST /api/folders/{id}/restore: Restore folder from trashDELETE /api/folders/{id}/permanent: Permanently delete folder
GET /api/items: Get all files and folders (with optional filtering)GET /api/items/starred: Get starred files and foldersPOST /api/items/{id}/star: Star an itemDELETE /api/items/{id}/star: Unstar an itemGET /api/items/recent: Get recently accessed itemsGET /api/items/trash: Get items in trashPOST /api/trash/empty: Empty trash (permanently delete all items in trash)POST /api/items/{id}/move: Move item to another folder
- File Storage: Implement secure file storage with proper access controls
- Performance: Optimize for handling large files and numerous small files
- Security: Ensure proper authentication and authorization for all endpoints
- Scalability: Design the API to handle growing user bases and storage requirements
- Error Handling: Implement comprehensive error handling and status codes
This API structure will support all the functionality shown in the frontend code while providing a clean, RESTful interface for the application to interact with.