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