A complete, full-stack blogging platform built with Node.js, Express, and MongoDB. This application allows users to create accounts, log securely into the system, publish blog posts with cover images, and interact with other users' posts through comments.
- User Authentication: Secure sign up and login using JSON Web Tokens (JWT) stored in HTTP-only cookies.
- Blog Publishing: Authenticated users can create, read, and manage blog posts.
- Image Uploads: Seamless cover image uploading for blog posts managed by Multer.
- Commenting System: Users can leave public comments on any blog post.
- Dynamic Views: Server-side rendering using EJS templating engine.
- Responsive Design: Styled using Bootstrap for a clean and mobile-friendly user interface.
- Backend: Node.js, Express.js
- Database: MongoDB, Mongoose
- Authentication: jsonwebtoken (JWT), cookie-parser
- File Storage: Multer
- Frontend: EJS, Bootstrap
-
Clone the repository
git clone <your-repository-url> cd blog-app
-
Install dependencies Ensure you have Node.js installed, then run:
npm install
-
Environment Variables Create a
.envfile in the root directory and add your MongoDB connection string and a secret key for JWT:MONGO_URL="mongodb://127.0.0.1:27017/blogApp" PORT=8000(Note: Ensure you do not commit your
.envfile to version control. It should be listed in your.gitignore) -
Start the Server To run the application in production mode:
npm start
To run the application in development mode (with auto-reloading):
npm run dev
-
Access the Application Open your browser and navigate to
http://localhost:8000
/models- Mongoose database schemas (User, Blog, Comment)/routes- Express route handlers for different endpoints/controllers- Core business logic for the application/views- EJS templates for frontend rendering/public- Static assets (uploaded images, CSS files)/services- Helper services (like JWT generation and validation)/middlewares- Custom Express middlewares for authentication checks