This is the backend service for Postify, a full-stack social media platform. Built with Node.js and Express.js, it handles authentication, post management, image uploads, and data persistence.
- 🔐 JWT Authentication — Secure token-based login and signup
- 🟠 Google OAuth 2.0 — Sign in with Google integration
- 👤 Role-Based Access Control — Manage user permissions
- 📝 Post CRUD — Create, read, update, and delete posts
- ❤️ Likes & Comments — Engage with posts in real time
- 🖼️ Image Uploads — Cloud media storage via Cloudinary
- 🗄️ MongoDB — Flexible NoSQL data persistence with Mongoose
| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express.js |
| Database | MongoDB (Mongoose ODM) |
| Authentication | JWT, Google OAuth 2.0 |
| Media Storage | Cloudinary |
| Deployment | Vercel |
PostifyBE/
├── config/
│ └── db.js # MongoDB connection
├── controllers/
│ ├── auth.controller.js # Login, signup, OAuth
│ ├── post.controller.js # Post CRUD operations
│ └── user.controller.js # User profile management
├── middleware/
│ ├── auth.middleware.js # JWT verification
│ └── upload.middleware.js # Cloudinary upload handler
├── models/
│ ├── user.model.js # User schema
│ └── post.model.js # Post schema
├── routes/
│ ├── auth.routes.js # /api/auth
│ ├── post.routes.js # /api/posts
│ └── user.routes.js # /api/users
├── .env.example # Environment variable template
├── .gitignore
├── package.json
└── server.js # App entry point
# Clone the repository
git clone https://github.com/Vishwaslad8549/PostifyBE.git
cd PostifyBE
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Fill in your values in .env
# Start the development server
npm run devServer runs at http://localhost:3000
Create a .env file in the root directory:
PORT=3000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=7d
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
CLIENT_URL=http://localhost:4200
⚠️ Never commit your.envfile. It is listed in.gitignore.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/signup |
Register new user |
| POST | /api/auth/login |
Login with email |
| GET | /api/auth/google |
Google OAuth login |
| GET | /api/auth/google/callback |
Google OAuth callback |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/posts |
Get all posts |
| POST | /api/posts |
Create a new post |
| PUT | /api/posts/:id |
Update a post |
| DELETE | /api/posts/:id |
Delete a post |
| POST | /api/posts/:id/like |
Like / unlike a post |
| POST | /api/posts/:id/comment |
Comment on a post |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users/:id |
Get user profile |
| PUT | /api/users/:id |
Update user profile |
🖥️ Frontend repo: PostifyFE