A modern, full-stack personal blogging platform built with Node.js, Express, and MongoDB. Features include blog post creation with image uploads, pagination, GridFS storage, and Blogspot import capabilities.
- Create & Manage Blog Posts: Write and publish blog posts with rich text and images
- MongoDB Atlas Storage: Cloud-based persistent storage for all data
- GridFS Image Storage: Binary image files stored in MongoDB (no filesystem dependency)
- Pagination: Browse posts efficiently with 10 posts per page
- Blogspot Import: Migrate existing posts from Blogspot with original dates
- Chronological Sorting: Newest posts displayed first automatically
- Responsive Design: Clean, modern UI optimized for all devices
- Dynamic Profile Images: Random profile image rotation on page navigation
Blog/
βββ index.js # Express server entry point
βββ package.json # Dependencies and scripts
βββ .env # Environment variables (gitignored)
βββ .gitignore # Git ignore rules
βββ LICENSE # ISC License
βββ README.md # This file
βββ MONGODB_SCHEMA.md # Database schema documentation
βββ BLOGSPOT_MIGRATION.md # Blogspot import guide
β
βββ routes/ # Backend API routes
β βββ db.js # MongoDB connection module
β βββ getdata.js # Blog CRUD operations
β βββ imageroutes.js # Random image endpoint
β
βββ views/ # HTML templates
β βββ entry.html # Blog post creation form
β
βββ public/ # Frontend static files
β βββ Blog.html # Main blog display page
β βββ cons.html # Console/admin page
β βββ contact.html # Contact page
β βββ style.css # Main stylesheet
β βββ server-side.css # Entry form styles
β βββ scripts/
β βββ blog.js # Blog display & pagination
β βββ cons.js # Console functionality
β
βββ photos/ # Profile images (gitignored)
β
βββ scripts/ # Utility scripts
βββ migration/
β βββ migrate-to-mongodb.js # JSON to MongoDB migration
β βββ import-blogspot.js # Blogspot post importer
β βββ fix-migrated-dates.js # Date correction script
βββ check-dates.js # Date verification utility
βββ analyze-manual-posts.js # Post analysis tool
βββ fix-dates.js # Date updater
βββ test-mongodb.js # DB connection test
- Node.js v14+
- MongoDB Atlas account (free tier works)
- npm package manager
-
Clone and install
git clone https://github.com/karan10i/Meig.git cd Blog npm install -
Configure environment
Create
.envfile:MONGODB_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/blogDB?retryWrites=true&w=majority
-
Start the server
node index.js
Server runs at
http://localhost:3000
- Navigate to
http://localhost:3000/entry - Fill in the form:
- Heading: Post title
- Text: Post content (supports line breaks)
- Blog Image: Upload image (optional)
- Click "Post" to publish
- Visit
http://localhost:3000/Blog.html - Browse with Previous/Next pagination controls
- Latest posts appear first
node scripts/migration/import-blogspot.jsFeatures:
- Fetches from Blogspot Atom feed API
- Preserves original publication dates
- Avoids duplicates (checks by title)
- Marks posts with
source: 'blogspot'
{
_id: ObjectId,
heading: String, // Post title
text: String, // Post content
imageId: ObjectId, // GridFS image reference
publishedDate: Date, // Publication date (for sorting)
createdAt: Date, // Creation timestamp
source: String, // 'manual' | 'blogspot'
sourceUrl: String // Original URL (if imported)
}images.files: Image metadata (filename, contentType, size)images.chunks: Binary data in 255KB chunks
See MONGODB_SCHEMA.md for detailed documentation.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/getData?page=1&limit=10 |
Paginated posts |
| POST | /api/saveData |
Create post (multipart/form-data) |
| GET | /api/image/:id |
Stream image from GridFS |
| GET | /api/getRandomImage |
Random profile image URL |
| GET | /entry |
Blog entry form |
# Migrate from old JSON file to MongoDB
node scripts/migration/migrate-to-mongodb.js
# Import Blogspot posts
node scripts/migration/import-blogspot.js
# Fix post dates
node scripts/migration/fix-migrated-dates.js# Check post dates
node scripts/check-dates.js
# Test MongoDB connection
node scripts/test-mongodb.jsBackend:
- Express 5.1.0 - Web framework
- MongoDB 6.20.0 - Database driver
- Multer 2.0.2 - File upload handling
- Dotenv 17.2.3 - Environment config
Scraping:
- Axios 1.13.2 - HTTP client
- Cheerio 1.1.2 - HTML parsing
Frontend:
- Vanilla JavaScript (ES6+)
- CSS3 with Flexbox/Grid
- Fetch API for AJAX
-
Push to GitHub
git add . git commit -m "Deploy blog platform" git push origin main
-
Configure Render
- Create new Web Service
- Connect GitHub repository
karan10i/Meig - Build Command:
npm install - Start Command:
node index.js
-
Set Environment Variables
- Add
MONGODB_URIin Render dashboard - Ensure MongoDB Atlas allows Render IPs (0.0.0.0/0 for simplicity)
- Add
-
Deploy
- Render auto-deploys on git push
- Check logs for "β Connected successfully to MongoDB"
.envfile is gitignored (never commit credentials)- MongoDB Atlas: Use strong passwords with URL encoding for special chars
- GridFS: Images stored in database (no public file access)
- CORS enabled for local development
ISC License - See LICENSE file
Personal project, but feedback welcome! Open an issue for suggestions.
Questions? Visit /contact.html or open a GitHub issue.
Built with β€οΈ by Karan Gupta
Powered by Node.js, Express, and MongoDB Atlas