A full-stack application for creating custom canvas designs with shapes, text, and images, and exporting them as optimized PDF files.
- Canvas Initialization: Create canvases with custom dimensions
- Shape Drawing: Add rectangles and circles with customizable colors and strokes
- Text Support: Add text with various fonts, sizes, and colors
- Image Upload: Upload and position images on the canvas
- Live Preview: Real-time preview of your canvas
- PDF Export: Export your design as a high-quality, optimized PDF
- Size Optimization: Automatic compression and optimization for smaller PDF files
- Node.js with Express.js
- canvas - HTML5 Canvas API for Node.js
- pdfkit - PDF generation
- sharp - Image optimization
- multer - File upload handling
- React with Vite
- Axios - HTTP client
- CSS3 - Modern styling with gradients and animations
rocketium/
βββ backend/
β βββ controllers/
β β βββ canvasController.js # Canvas manipulation logic
β βββ middleware/
β β βββ upload.js # File upload configuration
β βββ routes/
β β βββ canvas.js # API routes
β βββ uploads/ # Uploaded images storage
β βββ server.js # Express server
β βββ package.json
βββ frontend/
β βββ src/
β β βββ App.jsx # Main React component
β β βββ App.css # Styling
β β βββ main.jsx # Entry point
β β βββ index.css # Global styles
β βββ index.html
β βββ vite.config.js
β βββ package.json
βββ vercel.json # Vercel deployment config
βββ README.md
- Node.js (v16 or higher)
- npm or yarn
- Clone the repository
git clone <your-repo-url>
cd rocketium- Install Backend Dependencies
cd backend
npm install- Install Frontend Dependencies
cd ../frontend
npm install- Start the Backend Server
cd backend
npm start
# Or for development with auto-reload:
npm run devBackend will run on http://localhost:5000
- Start the Frontend Development Server
cd frontend
npm run devFrontend will run on http://localhost:3000
- Open your browser and navigate to
http://localhost:3000
POST /api/canvas/initialize
Content-Type: application/json
{
"width": 800,
"height": 600
}POST /api/canvas/add-rectangle
Content-Type: application/json
{
"sessionId": "string",
"x": 50,
"y": 50,
"width": 200,
"height": 100,
"fillColor": "#3498db",
"strokeColor": "#2c3e50",
"strokeWidth": 2
}POST /api/canvas/add-circle
Content-Type: application/json
{
"sessionId": "string",
"x": 400,
"y": 300,
"radius": 80,
"fillColor": "#e74c3c",
"strokeColor": "#c0392b",
"strokeWidth": 2
}POST /api/canvas/add-text
Content-Type: application/json
{
"sessionId": "string",
"text": "Hello Canvas!",
"x": 300,
"y": 500,
"fontSize": 32,
"fontFamily": "Arial",
"color": "#2c3e50"
}POST /api/canvas/add-image
Content-Type: multipart/form-data
{
"sessionId": "string",
"image": <file>,
"x": 550,
"y": 50,
"width": 200,
"height": 150
}POST /api/canvas/preview
Content-Type: application/json
{
"sessionId": "string"
}POST /api/canvas/export-pdf
Content-Type: application/json
{
"sessionId": "string",
"optimize": true
}- Initialize Canvas: Set your desired canvas dimensions and click "Initialize Canvas"
- Add Elements: Use the form controls to add rectangles, circles, text, or images
- Preview: See your design update in real-time in the preview panel
- Export: Click "Export as PDF" to download your design as an optimized PDF file
Create a .env file in the backend directory:
PORT=5000
NODE_ENV=developmentCreate a .env file in the frontend directory:
VITE_API_URL=http://localhost:5000/api- Install Vercel CLI
npm install -g vercel- Deploy
vercel- Set Environment Variables in Vercel Dashboard if needed
cd backend
git init
git add .
git commit -m "Initial commit"
# Follow your hosting provider's deployment instructionscd frontend
npm run build
# Deploy the 'dist' folder to your hosting providerThe application implements several optimization techniques:
- Image Compression: Uses Sharp library to compress images before adding to PDF
- PDF Compression: Enables built-in PDF compression in PDFKit
- Progressive Rendering: Optimizes PNG images for web delivery
- Quality Control: Balances quality and file size (80% quality, compression level 9)
- In-memory session storage for development
- Each canvas instance gets a unique session ID
- Session data includes canvas context, dimensions, and element history
On Windows, you may need to install build tools:
npm install --global windows-build-toolsChange the port in backend/server.js or set PORT environment variable
Ensure CORS is properly configured in backend/server.js
This project is created for educational purposes.
Built as an assignment project demonstrating full-stack development skills.
- Canvas API - Node Canvas Library
- PDFKit - PDF generation
- Sharp - Image processing
- React & Vite - Frontend framework and build tool