Live PREVIEW: https://posts-website.onrender.com/
This backend is built using Node.js, Express, MongoDB, and integrates ImageKit for image uploads. It is connected to a React + Tailwind CSS frontend.
Backend/
│
├── public/
│ ├── db_CRUD.js # CRUD operations using MongoDB (notes model)
│ ├── REST_API.js # REST API using local array (notes)
│
├── src/
│ ├── config/
│ │ └── env.js # Environment configuration (dotenv setup)
│ │
│ ├── db/
│ │ └── db.js # MongoDB connection
│ │
│ ├── models/
│ │ ├── note.model.js # Note schema
│ │ └── post.model.js # Post schema
│ │
│ ├── services/
│ │ └── storage.service.js # ImageKit integration (image upload)
│ │
│ ├── controller/
│ ├── middleware/
│ ├── routes/
│
│ └── app.js # Post CRUD + routes connected to frontend
│
├── .env # Environment variables
├── server.js # Entry point (server start + DB connection)
├── package.json
└── README.md
- db - Connects your application to the database
- models - Defines data structure (schemas, models, relationships)
- services - Reusable helper functions and external integrations
- controller - Handles requests and sends responses
- middleware - Runs before controllers (auth, validation, logging, errors)
- routes - Defines API endpoints and maps them to controllers
-
public/folder contains reference files onlydb_CRUD.js→ MongoDB CRUD examples (notes)REST_API.js→ Local array-based API examples
-
storage.service.jshandles:- Uploading images to ImageKit
- Converting buffer → base64
-
app.js:- Contains Post CRUD operations
- Handles routes used by frontend
-
.env.text_sampleprovides a sample environment configuration.
npm init -ynpm i express mongoose dotenv cors multer @imagekit/nodejs jsonwebtoken cookie-parser bcryptjs express-validatornpx nodemon server.js- Built with React + Tailwind CSS
- Connected to backend APIs for post creation and display
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/user/authentication/register |
Register a new user |
| POST | /api/user/authentication/login |
Login an existing user |
| GET | /api/posts |
Get all posts |
| GET | /api/posts/my-posts |
Get posts for logged-in user |
| POST | /api/posts/create-post |
Create a new post |
| DELETE | /api/posts/delete-post/:id |
Delete a post |