Skip to content

Vishwaslad8549/PostifyBE

Repository files navigation

Postify Backend 🛠️

REST API for the Postify Social Media Platform

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.


🌟 Features

  • 🔐 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

🛠️ Tech Stack

Layer Technology
Runtime Node.js
Framework Express.js
Database MongoDB (Mongoose ODM)
Authentication JWT, Google OAuth 2.0
Media Storage Cloudinary
Deployment Vercel

📁 Project Structure

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

🚀 Getting Started

# 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 dev

Server runs at http://localhost:3000


🔐 Environment Variables

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 .env file. It is listed in .gitignore.


📡 API Endpoints

Auth

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

Posts

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

Users

Method Endpoint Description
GET /api/users/:id Get user profile
PUT /api/users/:id Update user profile

🔗 Related Repository

🖥️ Frontend repo: PostifyFE

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors