Blogify, is a dynamic blogging platform designed to be simple, fast, and effective. I've structured this to handle content creation reliably without the unnecessary overhead of complex client-side frameworks. It is classic server-side rendering done right.
We made some specific architectural choices here to keep development velocity high while maintaining a robust backend.
- Node.js & Express: The backbone of the application. It is fast, flexible, and handles our HTTP prowess.
- MongoDB & Mongoose: We are using a document store because it fits our data model perfectly. Blog posts and comments are naturally hierarchical.
- EJS (Embedded JavaScript): We render our views on the server. This ensures fast initial page loads and excellent SEO without the complexity of a hydration layer.
- Authentication: A custom JWT implementation using cookies. It is stateless and keeps our session management lightweight.
- Multer: Handles file uploads for blog cover images directly to our public directory.
I have kept the organization clean and predictable so you can jump right in:
models/: Defines our data schemas (User, Blog, Comment).views/: Contains all the server-rendered EJS templates.routes/: Acts as the controller layer, mapping URLs to logic.middlewares/: Handles request processing like authentication checks.services/: Isolates business logic, particularly for auth.
- Clone the repo and navigate into the directory.
- Install dependencies:
npm install
- Environment Setup:
Create a
.envfile in the root directory. You simply need to provide your database connection string:MONGO_URL=mongodb://localhost:27017/blogify - Launch:
The server will spin up on port 8000 by default.
npm start
You might notice the JWT secret is currently hardcoded in the service layer. This is intentional for the development environment to reduce setup friction. For any production deployment, verify you move this to an environment variable immediately.
Dive in, explore the code, and enjoy working with a clean, well-structured Node.js application.