A full-stack blog editor application with auto-save functionality built with React, TypeScript, and Node.js.
- Blog editor with rich text editing
- Auto-save drafts after 5 seconds of inactivity
- Save as draft and publish functionality
- Tags support
- Separate views for published blogs and drafts
- Full CRUD operations for blog posts
- Responsive design for all devices
- React 18
- TypeScript
- TailwindCSS for styling
- React Router for navigation
- TinyMCE for rich text editing
- React Toastify for notifications
- Lucide React for icons
- Node.js
- Express.js
- File-based JSON storage (can be replaced with a database)
- Node.js (v14 or higher)
- npm or yarn
-
Clone the repository
-
Install frontend dependencies:
npm install -
Install backend dependencies:
cd server npm install cd ..
-
Start the backend server:
cd server npm run dev -
In a new terminal, start the frontend development server:
npm run dev -
Open your browser and navigate to the URL shown in your terminal (typically http://localhost:5173)
GET /api/blogs- Retrieve all blogsGET /api/blogs/:id- Retrieve a blog by IDPOST /api/blogs/save-draft- Save a new draftPOST /api/blogs/:id/save-draft- Update an existing draftPOST /api/blogs/publish- Publish a new blogPOST /api/blogs/:id/publish- Publish an existing blog
The auto-save feature is implemented using a debounce mechanism that triggers a save operation after 5 seconds of user inactivity when editing blog content. This helps to prevent data loss and provides a seamless writing experience.
For simplicity, this implementation uses a file-based JSON storage system for the backend. In a production to the environment, we can replace this with a proper database like MongoDB or PostgreSQL.