A modern web application for file preview and conversion, built with React and Node.js.
- Drag and drop file upload
- Multiple file selection
- File preview generation
- File size display with automatic unit conversion
- Supported formats:
- Markdown (.md)
- HTML (.html)
- PDF (.pdf) - Preview only
-
Format-specific preview
-
File metadata display:
- Format type
- File size (B to GB)
- Preview content
-
PDF Files
- Page count display
- Text content preview (first 128 characters)
- Supports text-based PDFs
- Fast preview generation
-
Text Files
- Content preview (first 128 characters)
- Supports various encodings
- Clean, formatted display
- Markdown to HTML
- HTML to Markdown
- PDF support coming soon
- Real-time progress tracking
- Batch file conversion
- Error handling and reporting
- Preview before conversion
- Automatic format detection
- React 18.2
- TypeScript
- Vite
- PDF.js 3.11.174
- React Dropzone
- React Query
- Material-UI (MUI)
- Node.js
- Express
- Multer (file upload handling)
- Sharp (image processing)
- Markdown-it (markdown processing)
The application follows a client-server architecture with React on the frontend and Node.js on the backend.
- Location:
/client/src/components/FileUpload/
- Files:
FileUpload.tsx
FileUpload.css
- Responsibilities:
- File selection and drag-drop handling
- Initial file validation
- Preview generation for multiple file types
- File metadata extraction
- Dependencies:
- External: react-dropzone, pdfjs-dist, Material-UI
- Internal: conversion types
- State Management: Local component state for:
- Selected files
- Preview content
- Upload status
- Location:
/client/src/components/FileConversion/
- Files:
FileConversion.tsx
- Responsibilities:
- Conversion queue management
- Format selection interface
- Progress tracking
- Preview display
- Error state handling
- Dependencies:
- External: Material-UI
- Internal: conversion types
- State Management: Local state for:
- Conversion queue
- Progress tracking
- Format selection
- Location:
/client/src/components/ErrorBoundary/
- Files:
ErrorBoundary.tsx
ErrorBoundary.css
- Responsibilities:
- Global error catching
- Error UI rendering
- Error logging
- Dependencies:
- External: Material-UI
- State Management: Local error state for:
- Error information
- Recovery options
/src
App.tsx
- Main application componentmain.tsx
- Application entry pointApp.css
- Global styles/components
- React components/assets
- Static assets/types
- TypeScript type definitions
vite.config.ts
- Vite build configurationtsconfig.json
- TypeScript configurationpackage.json
- Dependencies and scripts
- Files:
fileRoutes.ts
- File upload endpointsconversion.ts
- Conversion endpoints
- Responsibilities:
- Route handling for file operations
- Conversion request processing
- Response formatting
- Files:
fileController.ts
- File operation handlers
- Responsibilities:
- File upload handling
- Conversion process management
- Error handling
- Files:
ConversionService.ts
- Core conversion logic
- Responsibilities:
- File format conversion
- Progress tracking
- Temporary file management
- Files:
errorHandler.ts
- Global error handlingupload.ts
- File upload middleware
- Responsibilities:
- Request validation
- Error processing
- File upload processing
/src
index.ts
- Server entry point/routes
- API route definitions/controllers
- Request handlers/services
- Business logic/middleware
- Express middleware/errors
- Custom error definitions/utils
- Utility functions
/uploads
- Temporary file storage/logs
- Application logs.env
- Environment configurationtsconfig.json
- TypeScript configurationpackage.json
- Dependencies and scripts
.gitignore
- Git ignore rules.env.example
- Environment variables template
- Client-side validation and file preview generation
- Secure file upload to server's temporary storage
- Server-side format validation
- Preview generation and metadata extraction
- File format detection and validation
- Conversion service selection based on file type:
- Markdown to HTML using marked
- HTML to Markdown using custom DOM parsing
- PDF processing using pdf-lib
- Progress tracking through server events
- Queue management for multiple conversions
- Error handling and cleanup
- Client-side validation with user feedback
- Server-side error middleware for consistent error responses
- Automatic cleanup of temporary files
- Detailed error logging
- Node.js >= 18
- npm >= 9
- Clone the repository:
git clone [repository-url]
cd file-converter
- Install dependencies:
For the client:
cd client
npm install --ignore-scripts
For the server:
cd server
npm install
- Set up environment variables:
# In the server directory
cp .env.example .env
Required environment variables:
PORT=7842
NODE_ENV=development
UPLOAD_DIR=uploads
MAX_FILE_SIZE=10485760
- Start the server:
cd server
npm run dev
- Start the client:
cd client
npm run dev
- Open http://localhost:5173 in your browser
- Currently limited to preview only
- Conversion to/from PDF not yet supported
- Complex layouts may affect text extraction
- Preview limited to first 128 characters
- Fixed preview container size
For a complete list of known issues and limitations, see BUGS.md.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a detailed list of changes and updates.