diff --git a/README.md b/README.md index 7959ce4..063f7b5 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,585 @@ -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: - -```js -export default tseslint.config([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - - // Remove tseslint.configs.recommended and replace with this - ...tseslint.configs.recommendedTypeChecked, - // Alternatively, use this for stricter rules - ...tseslint.configs.strictTypeChecked, - // Optionally, add this for stylistic rules - ...tseslint.configs.stylisticTypeChecked, - - // Other configs... - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) -``` - -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: - -```js -// eslint.config.js -import reactX from 'eslint-plugin-react-x' -import reactDom from 'eslint-plugin-react-dom' - -export default tseslint.config([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - // Enable lint rules for React - reactX.configs['recommended-typescript'], - // Enable lint rules for React DOM - reactDom.configs.recommended, - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) +# πŸš€ FileFlow + +
+ +**A Modern, Feature-Rich File Management System** + +[![React](https://img.shields.io/badge/React-19.1.1-blue.svg)](https://reactjs.org/) +[![TypeScript](https://img.shields.io/badge/TypeScript-5.8.3-blue.svg)](https://www.typescriptlang.org/) +[![Vite](https://img.shields.io/badge/Vite-7.1.2-646CFF.svg)](https://vitejs.dev/) +[![TailwindCSS](https://img.shields.io/badge/TailwindCSS-4.1.12-38B2AC.svg)](https://tailwindcss.com/) + +*Upload, organize, share, and manage your files with ease* + +
+ +--- + +## πŸ“‹ Table of Contents + +- [Overview](#-overview) +- [Features](#-features) +- [Tech Stack](#-tech-stack) +- [Project Structure](#-project-structure) +- [Getting Started](#-getting-started) +- [Environment Variables](#-environment-variables) +- [Core Features](#-core-features) +- [Architecture](#-architecture) +- [Available Scripts](#-available-scripts) +- [Contributing](#-contributing) + +--- + +## 🌟 Overview + +**FileFlow** is a modern, cloud-based file management system built with React and TypeScript. It provides a seamless experience for uploading, organizing, sharing, and managing files with features like real-time notifications, drag-and-drop uploads, video/image preview, and advanced access control. + +### ✨ Why FileFlow? + +- **🎨 Beautiful UI**: Modern, responsive design with smooth animations +- **⚑ Lightning Fast**: Built on Vite for instant hot module replacement +- **πŸ”’ Secure**: Multi-level access control (Public, Protected, Private) +- **πŸ“± Mobile-First**: Fully responsive across all devices +- **🎯 Type-Safe**: 100% TypeScript for better developer experience +- **πŸ”” Real-Time**: Socket.io integration for live notifications +- **🎬 Media Preview**: Built-in video and image viewers + +--- + +## 🎯 Features + +### File Management +- βœ… **Upload Files**: Drag-and-drop or click to upload single/multiple files +- βœ… **Folder Organization**: Create, rename, move folders and files +- βœ… **Smart Search**: Quick file search across all directories +- βœ… **Bulk Operations**: Select and manage multiple files at once +- βœ… **File Sorting**: Sort by size, name, or date +- βœ… **Grid/List Views**: Toggle between grid and list layouts +- βœ… **Breadcrumb Navigation**: Easy navigation through folder hierarchy + +### Access Control +- πŸ” **Three Access Levels**: + - **Public**: Accessible to everyone + - **Protected**: Accessible to authenticated users + - **Private**: PIN-protected, encrypted storage +- πŸ”‘ **PIN Protection**: Secure your private files with a PIN +- πŸ‘₯ **File Sharing**: Share files with specific users with permission levels (View, Edit, Admin) + +### Media Handling +- 🎬 **Video Player**: Built-in video player with controls (Video.js) +- πŸ–ΌοΈ **Image Viewer**: Advanced image viewer with zoom, rotate, and pan +- πŸ“₯ **Smart Downloads**: Downloads with timestamped filenames +- 🎯 **Thumbnail Generation**: Automatic thumbnail creation for media files + +### User Experience +- πŸ”” **Real-Time Notifications**: Instant updates for file operations +- πŸ“Š **Upload Progress**: Real-time upload progress with pause/resume +- πŸ—‘οΈ **Trash Management**: Soft delete with restore functionality +- ⚑ **Infinite Scroll**: Cursor-based pagination for better performance +- πŸŒ“ **Dark Mode**: System-aware theme switching +- πŸ“± **Responsive Design**: Optimized for mobile, tablet, and desktop + +### Additional Features +- πŸ”„ **Recent Files**: Quick access to recently opened files +- πŸ“€ **Shared Files**: View files shared by you or with you +- βš™οΈ **User Settings**: Manage profile, PIN, API tokens +- πŸ”Œ **WebSocket Integration**: Real-time file updates +- 🎨 **Smooth Animations**: Framer Motion for delightful interactions + +--- + +## πŸ› οΈ Tech Stack + +### Core +- **[React 19.1.1](https://reactjs.org/)** - UI Framework +- **[TypeScript 5.8.3](https://www.typescriptlang.org/)** - Type Safety +- **[Vite 7.1.2](https://vitejs.dev/)** - Build Tool & Dev Server + +### Styling & UI +- **[TailwindCSS 4.1.12](https://tailwindcss.com/)** - Utility-First CSS +- **[Radix UI](https://www.radix-ui.com/)** - Headless UI Components +- **[Framer Motion 12.23.12](https://www.framer.com/motion/)** - Animations +- **[Lucide React](https://lucide.dev/)** - Icon Library + +### State Management & Data Fetching +- **[TanStack React Query 5.85.9](https://tanstack.com/query)** - Server State Management +- **[Zustand 5.0.7](https://zustand-demo.pmnd.rs/)** - Client State Management +- **[React Hook Form 7.62.0](https://react-hook-form.com/)** - Form Management + +### Routing & Navigation +- **[React Router DOM 7.8.0](https://reactrouter.com/)** - Client-Side Routing + +### API & Real-Time +- **[Axios 1.11.0](https://axios-http.com/)** - HTTP Client +- **[Socket.io Client 4.8.1](https://socket.io/)** - Real-Time Communication + +### Media & Files +- **[Video.js 8.23.4](https://videojs.com/)** - Video Player +- **Custom Image Viewer** - Advanced image manipulation + +### Validation & Forms +- **[Zod 4.0.17](https://zod.dev/)** - Schema Validation +- **[@hookform/resolvers](https://www.npmjs.com/package/@hookform/resolvers)** - Form Validation Integration + +### Notifications +- **[Sonner 2.0.7](https://sonner.emilkowal.ski/)** - Toast Notifications + +--- + +## πŸ“ Project Structure + +``` +FileFlow/ +β”œβ”€β”€ src/ +β”‚ β”œβ”€β”€ api/ # API client & endpoints +β”‚ β”‚ β”œβ”€β”€ axios.ts # Axios configuration +β”‚ β”‚ β”œβ”€β”€ file.api.ts # File operations API +β”‚ β”‚ β”œβ”€β”€ notification.api.ts # Notification API +β”‚ β”‚ └── auth.api.ts # Authentication API +β”‚ β”‚ +β”‚ β”œβ”€β”€ components/ # React components +β”‚ β”‚ β”œβ”€β”€ custom/ # Custom UI components +β”‚ β”‚ β”‚ β”œβ”€β”€ ImageViewer.tsx # Image preview with zoom/rotate +β”‚ β”‚ β”‚ └── ... +β”‚ β”‚ β”œβ”€β”€ file-manager/ # File management components +β”‚ β”‚ β”‚ β”œβ”€β”€ FileGrid.tsx # Grid view +β”‚ β”‚ β”‚ β”œβ”€β”€ FileList.tsx # List view +β”‚ β”‚ β”‚ β”œβ”€β”€ FileManager.tsx # Main file manager +β”‚ β”‚ β”‚ β”œβ”€β”€ Toolbar.tsx # Search & filters +β”‚ β”‚ β”‚ └── ... +β”‚ β”‚ β”œβ”€β”€ upload/ # Upload-related components +β”‚ β”‚ β”‚ β”œβ”€β”€ UploadPopup.tsx # Upload modal +β”‚ β”‚ β”‚ β”œβ”€β”€ FileUploader.tsx# Drag-drop uploader +β”‚ β”‚ β”‚ └── ... +β”‚ β”‚ β”œβ”€β”€ player/ # Media player components +β”‚ β”‚ β”œβ”€β”€ settings/ # Settings components +β”‚ β”‚ β”œβ”€β”€ session/ # Session & PIN components +β”‚ β”‚ β”œβ”€β”€ sidebar/ # Sidebar navigation +β”‚ β”‚ β”œβ”€β”€ user/ # User-related components +β”‚ β”‚ β”œβ”€β”€ layouts/ # Layout components +β”‚ β”‚ β”œβ”€β”€ error/ # Error components +β”‚ β”‚ └── ui/ # Shadcn UI components +β”‚ β”‚ +β”‚ β”œβ”€β”€ contexts/ # React Context providers +β”‚ β”‚ β”œβ”€β”€ useAuth.tsx # Authentication context +β”‚ β”‚ β”œβ”€β”€ fileContext.tsx # File management state +β”‚ β”‚ β”œβ”€β”€ UploadContext.tsx # Upload state & queue +β”‚ β”‚ β”œβ”€β”€ NotificationContext.tsx # Notification state +β”‚ β”‚ β”œβ”€β”€ SocketContext.tsx # WebSocket connection +β”‚ β”‚ β”œβ”€β”€ ThemeContext.tsx # Theme management +β”‚ β”‚ └── ... +β”‚ β”‚ +β”‚ β”œβ”€β”€ hooks/ # Custom React hooks +β”‚ β”‚ β”œβ”€β”€ useFileDownload.tsx # File download logic +β”‚ β”‚ β”œβ”€β”€ useFileUpload.tsx # Upload logic +β”‚ β”‚ β”œβ”€β”€ useTheme.tsx # Theme hook +β”‚ β”‚ └── ... +β”‚ β”‚ +β”‚ β”œβ”€β”€ pages/ # Page components +β”‚ β”‚ β”œβ”€β”€ all-files-page.tsx # All files view +β”‚ β”‚ β”œβ”€β”€ private-files-page.tsx # Private files +β”‚ β”‚ β”œβ”€β”€ deleted-files-page.tsx # Trash +β”‚ β”‚ β”œβ”€β”€ shared-files-page.tsx # Shared files +β”‚ β”‚ β”œβ”€β”€ notifications-page.tsx # Notifications +β”‚ β”‚ └── ... +β”‚ β”‚ +β”‚ β”œβ”€β”€ routes/ # Route components +β”‚ β”‚ β”œβ”€β”€ auth/ # Authentication routes +β”‚ β”‚ β”œβ”€β”€ Home.tsx # Dashboard +β”‚ β”‚ β”œβ”€β”€ AllFiles.tsx # Files route wrapper +β”‚ β”‚ └── ... +β”‚ β”‚ +β”‚ β”œβ”€β”€ lib/ # Utility libraries +β”‚ β”‚ β”œβ”€β”€ utils.ts # Helper functions +β”‚ β”‚ β”œβ”€β”€ video-utils.ts # Video utilities +β”‚ β”‚ β”œβ”€β”€ image-utils.ts # Image utilities +β”‚ β”‚ └── ... +β”‚ β”‚ +β”‚ β”œβ”€β”€ types/ # TypeScript types +β”‚ β”‚ β”œβ”€β”€ file.types.ts # File-related types +β”‚ β”‚ β”œβ”€β”€ file-manager.ts # File manager types +β”‚ β”‚ β”œβ”€β”€ user.types.ts # User types +β”‚ β”‚ └── ... +β”‚ β”‚ +β”‚ β”œβ”€β”€ config/ # Configuration files +β”‚ β”‚ └── page-configs.ts # Page configurations +β”‚ β”‚ +β”‚ β”œβ”€β”€ store/ # Zustand stores +β”‚ β”‚ └── auth.store.ts # Auth state +β”‚ β”‚ +β”‚ β”œβ”€β”€ css/ # Stylesheets +β”‚ β”‚ └── App.css # Global styles +β”‚ β”‚ +β”‚ β”œβ”€β”€ App.tsx # Root component +β”‚ └── main.tsx # Entry point +β”‚ +β”œβ”€β”€ public/ # Static assets +β”œβ”€β”€ components.json # Shadcn UI config +β”œβ”€β”€ tailwind.config.js # Tailwind configuration +β”œβ”€β”€ tsconfig.json # TypeScript config +β”œβ”€β”€ vite.config.ts # Vite configuration +β”œβ”€β”€ package.json # Dependencies +└── README.md # This file +``` + +--- + +## πŸš€ Getting Started + +### Prerequisites + +- **Bun.js** >= 1.0.0 +- **Backend API** running (FileFlow Backend) + +### Installation + +1. **Clone the repository** + ```bash + git clone https://github.com/venu123143/fileflow.git + cd fileflow/FileFlow + ``` + +2. **Install dependencies** + ```bash + npm install + # or + yarn install + ``` + +3. **Set up environment variables** + ```bash + cp .env.example .env + ``` + Edit `.env` with your configuration (see [Environment Variables](#-environment-variables)) + +4. **Start development server** + ```bash + npm run dev + # or + yarn dev + ``` + +5. **Open your browser** + ``` + http://localhost:5173 + ``` + +--- + +## πŸ” Environment Variables + +Create a `.env` file in the root directory: + +```env +# API Configuration +VITE_API_BASE_URL=http://localhost:3000/api/v1 +VITE_API_CDN_URL=https://cdn.yourdomain.com + +# WebSocket Configuration +VITE_SOCKET_URL=http://localhost:3000 + +# Optional: Feature Flags +VITE_ENABLE_VIDEO_PLAYER=true +VITE_ENABLE_IMAGE_VIEWER=true +``` + +### Variable Descriptions + +| Variable | Description | Default | +|----------|-------------|---------| +| `VITE_API_BASE_URL` | Backend API base URL | - | +| `VITE_API_CDN_URL` | CDN URL for file storage | - | +| `VITE_SOCKET_URL` | WebSocket server URL | - | + +--- + +## πŸ’‘ Core Features + +### 1. File Upload System + +```typescript +// Multi-file upload with drag & drop +- Chunked upload for large files +- Real-time progress tracking +- Pause/resume functionality +- Automatic retry on failure +- Thumbnail generation +``` + +### 2. Access Level Management + +```typescript +export const ACCESS_LEVEL = { + PUBLIC: 'public', // Anyone can access + PROTECTED: 'protected', // Authenticated users + PRIVATE: 'private' // PIN-protected +} +``` + +### 3. File Download + +```typescript +// Download with timestamped filenames +// Example: document.pdf β†’ document_17234.pdf +- CORS-aware fallback mechanism +- Folder download prevention +- Batch download support +``` + +### 4. Real-Time Notifications + +```typescript +// Socket.io events +- 'notification:new' β†’ New notification +- 'last_accessed' β†’ File access tracking +- Cursor-based pagination for performance +``` + +--- + +## πŸ—οΈ Architecture + +### State Management + +**Context API + React Query + Zustand** + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Application State β”‚ +β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ AuthContext (Zustand) β”‚ +β”‚ β”œβ”€ User authentication β”‚ +β”‚ └─ Session management β”‚ +β”‚ β”‚ +β”‚ FileContext (React Query) β”‚ +β”‚ β”œβ”€ File CRUD operations β”‚ +β”‚ β”œβ”€ Folder navigation β”‚ +β”‚ └─ Cache management β”‚ +β”‚ β”‚ +β”‚ UploadContext (React Context) β”‚ +β”‚ β”œβ”€ Upload queue β”‚ +β”‚ β”œβ”€ Progress tracking β”‚ +β”‚ └─ Chunk management β”‚ +β”‚ β”‚ +β”‚ NotificationContext (React Query) β”‚ +β”‚ β”œβ”€ Notification list β”‚ +β”‚ β”œβ”€ Unread count β”‚ +β”‚ └─ Mark as read β”‚ +β”‚ β”‚ +β”‚ SocketContext (WebSocket) β”‚ +β”‚ └─ Real-time events β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +### Data Flow + +``` +User Action β†’ Component β†’ Context/Hook β†’ API Client β†’ Backend + ↓ ↓ + UI Update ← React Query Cache ← Response β†β”€β”€β”˜ + ↓ + WebSocket Event β†’ Update State β†’ Re-render +``` + +### Routing Strategy + +```typescript +// Protected Routes + + β”œβ”€ / # Dashboard + β”œβ”€ /all-files # All files + β”œβ”€ /private-files # Private files (PIN required) + β”œβ”€ /deleted-files # Trash + β”œβ”€ /shared-files # Shared files + β”œβ”€ /notifications # Notifications + └─ /settings # User settings + + +// Public Routes +β”œβ”€ /login # Login page +β”œβ”€ /register # Registration +└─ /unauthorized # Access denied +``` + +--- + +## πŸ“œ Available Scripts + +### Development + +```bash +npm run dev # Start development server (http://localhost:5173) +npm run build # Build for production +npm run preview # Preview production build +npm run lint # Run ESLint +``` + +### Build + +```bash +npm run build # TypeScript check + Vite build +# Output: dist/ +``` + +--- + +## 🎨 Component Examples + +### File Manager Integration + +```tsx +import { FileManager } from '@/components/file-manager/FileManager'; + + +``` + +### Upload Integration + +```tsx +import { useUpload } from '@/contexts/UploadContext'; + +const { addToQueue, uploadFiles } = useUpload(); + +// Add files to queue +addToQueue(files, { + folder_id: currentFolderId, + access_level: ACCESS_LEVEL.PROTECTED +}); +``` + +### Custom Hooks Usage + +```tsx +import { useFileDownload } from '@/hooks/useFileDownload'; + +const { downloadFile, downloadMultipleFiles } = useFileDownload(); + +// Download single file +await downloadFile(fileItem); + +// Download multiple files +await downloadMultipleFiles([file1, file2, file3]); +``` + +--- + +## πŸ”’ Security Features + +- βœ… JWT-based authentication +- βœ… PIN protection for private files +- βœ… Role-based access control (RBAC) +- βœ… Secure file storage with access levels +- βœ… API token management +- βœ… Session timeout handling +- βœ… CORS protection +- βœ… XSS prevention + +--- + +## 🌐 Browser Support + +| Browser | Version | +|---------|---------| +| Chrome | Latest | +| Firefox | Latest | +| Safari | Latest | +| Edge | Latest | + +--- + +## πŸ“± Responsive Breakpoints + +```typescript +sm: 640px // Mobile landscape / Tablet +md: 768px // Tablet +lg: 1024px // Desktop +xl: 1280px // Large desktop +2xl: 1536px // Extra large desktop ``` + +--- + +## 🀝 Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. + +1. Fork the project +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) +4. Push to the branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request + +--- + +## πŸ“ Code Style + +This project uses: +- **ESLint** for linting +- **TypeScript** for type checking +- **Prettier** (recommended) for code formatting + +--- + +## πŸ› Known Issues & Limitations + +- CORS issues with some CDN configurations (fallback mechanism in place) +- Large file uploads (>1GB) may require chunking optimization +- Mobile pinch-to-zoom on image viewer needs refinement + +--- + +## πŸ—ΊοΈ Roadmap + +- [ ] Offline mode support +- [ ] File versioning +- [ ] Advanced search filters +- [ ] Collaborative editing +- [ ] File encryption at rest +- [ ] Integration with cloud storage (Google Drive, Dropbox) +- [ ] Mobile app (React Native) +- [ ] AI-powered file tagging + +--- + +## πŸ“„ License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +--- + +## πŸ‘¨β€πŸ’» Author + +**Your Name** +- GitHub: [@yourusername](https://github.com/yourusername) +- Email: your.email@example.com + +--- + +## πŸ™ Acknowledgments + +- [Radix UI](https://www.radix-ui.com/) for accessible components +- [Shadcn UI](https://ui.shadcn.com/) for component inspiration +- [TanStack](https://tanstack.com/) for amazing developer tools +- The React community for continuous innovation + +--- + +
+ +**Built with ❀️ using React + TypeScript + Vite** + +[⬆ Back to Top](#-fileflow) + +