A full-stack blog platform built with Node.js and Express, powered by MongoDB. Create, manage, and share blog posts with a secure authentication system and rich user experience.
- User Authentication: Secure user registration and login with bcrypt password hashing
- Blog Management: Create, read, update, and delete blog posts
- Search Functionality: Search blog posts by keywords
- File Uploads: Upload images and files with posts
- Session Management: Persistent user sessions with express-session
- Responsive Design: Clean and responsive UI with EJS templates
- User Authorization: Middleware-based authentication and validation
- Modern Tech Stack: Built with Express.js, MongoDB, and modern JavaScript
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose ODM
- Template Engine: EJS
- Authentication: bcrypt, express-session
- File Handling: express-fileupload
- Parsing: body-parser
- Development: Nodemon for hot-reloading
├── controllers/ # Route handlers and business logic
│ ├── getPost.js # Retrieve individual posts
│ ├── home.js # Home page logic
│ ├── login.js # Login page
│ ├── loginUser.js # Login processing
│ ├── logout.js # Logout handler
│ ├── newPost.js # New post form
│ ├── newUser.js # Registration form
│ ├── search.js # Search functionality
│ ├── storePost.js # Save new posts
│ └── storeUser.js # Save new users
├── middleware/ # Custom middleware
│ ├── authMiddleware.js
│ └── validationMiddleware.js
├── models/ # Database schemas
│ ├── Blogpost.js
│ └── User.js
├── views/ # EJS templates
│ ├── index.ejs
│ ├── post.ejs
│ ├── create.ejs
│ ├── login.ejs
│ ├── register.ejs
│ ├── about.ejs
│ ├── contact.ejs
│ ├── notfound.ejs
│ └── layouts/ # Layout templates
│ ├── header.ejs
│ ├── navbar.ejs
│ └── footer.ejs
├── public/ # Static files
│ ├── css/
│ ├── js/
│ └── img/
├── server.js # Main server file
└── package.json # Dependencies and scripts
-
Clone the repository
git clone <repository-url> cd blog-post
-
Install dependencies
npm install
-
Configure environment
- Create a
.envfile with your MongoDB connection string and other configurations - Update session secret in
server.jsfor production
- Create a
-
Start the development server
npm run dev
Or start with Node directly:
node server.js
The application will run on http://localhost:3000 (or your configured port)
- Register a new account or log in
- Navigate to "Create Post"
- Fill in the post title, content, and upload an image
- Click "Publish" to save your post
- Use the search functionality to find posts by keywords
- Register for a new account
- Log in with your credentials
- Log out when finished
GET /- Home page with all postsGET /posts/:id- View individual postGET /create- New post formPOST /posts- Store new postGET /register- Registration formPOST /users- Store new userGET /login- Login formPOST /login- Process loginGET /logout- Logout userGET /search- Search postsGET /about- About pageGET /contact- Contact page
- Password hashing with bcrypt
- Session-based authentication
- Input validation middleware
- Protection against common web vulnerabilities
- Post categories and tags
- Comments section
- User profiles with post history
- Social sharing features
- Email notifications
- Admin panel
- Database backups
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
ISC
Created by Burhan

